babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238
  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. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** 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 */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** 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 */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** 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 */
  4473. static readonly GEQUAL: number;
  4474. /** 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 */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * 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.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @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
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. 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);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** 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 */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @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)
  7392. * @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)
  7393. * @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)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * 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.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * 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
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * 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)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * 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)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * 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).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @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
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * 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.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @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
  7840. * @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
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the current object class name.
  7943. * @return the class name
  7944. */
  7945. getClassName(): string;
  7946. /**
  7947. * Gets the parent skeleton
  7948. * @returns a skeleton
  7949. */
  7950. getSkeleton(): Skeleton;
  7951. /**
  7952. * Gets parent bone
  7953. * @returns a bone or null if the bone is the root of the bone hierarchy
  7954. */
  7955. getParent(): Nullable<Bone>;
  7956. /**
  7957. * Returns an array containing the root bones
  7958. * @returns an array containing the root bones
  7959. */
  7960. getChildren(): Array<Bone>;
  7961. /**
  7962. * Sets the parent bone
  7963. * @param parent defines the parent (can be null if the bone is the root)
  7964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7965. */
  7966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7967. /**
  7968. * Gets the local matrix
  7969. * @returns a matrix
  7970. */
  7971. getLocalMatrix(): Matrix;
  7972. /**
  7973. * Gets the base matrix (initial matrix which remains unchanged)
  7974. * @returns a matrix
  7975. */
  7976. getBaseMatrix(): Matrix;
  7977. /**
  7978. * Gets the rest pose matrix
  7979. * @returns a matrix
  7980. */
  7981. getRestPose(): Matrix;
  7982. /**
  7983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7984. */
  7985. getWorldMatrix(): Matrix;
  7986. /**
  7987. * Sets the local matrix to rest pose matrix
  7988. */
  7989. returnToRest(): void;
  7990. /**
  7991. * Gets the inverse of the absolute transform matrix.
  7992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7993. * @returns a matrix
  7994. */
  7995. getInvertedAbsoluteTransform(): Matrix;
  7996. /**
  7997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7998. * @returns a matrix
  7999. */
  8000. getAbsoluteTransform(): Matrix;
  8001. /**
  8002. * Links with the given transform node.
  8003. * The local matrix of this bone is copied from the transform node every frame.
  8004. * @param transformNode defines the transform node to link to
  8005. */
  8006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8007. /** Gets or sets current position (in local space) */
  8008. position: Vector3;
  8009. /** Gets or sets current rotation (in local space) */
  8010. rotation: Vector3;
  8011. /** Gets or sets current rotation quaternion (in local space) */
  8012. rotationQuaternion: Quaternion;
  8013. /** Gets or sets current scaling (in local space) */
  8014. scaling: Vector3;
  8015. /**
  8016. * Gets the animation properties override
  8017. */
  8018. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8019. private _decompose;
  8020. private _compose;
  8021. /**
  8022. * Update the base and local matrices
  8023. * @param matrix defines the new base or local matrix
  8024. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8025. * @param updateLocalMatrix defines if the local matrix should be updated
  8026. */
  8027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8028. /** @hidden */
  8029. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8030. /**
  8031. * Flag the bone as dirty (Forcing it to update everything)
  8032. */
  8033. markAsDirty(): void;
  8034. private _markAsDirtyAndCompose;
  8035. private _markAsDirtyAndDecompose;
  8036. /**
  8037. * Translate the bone in local or world space
  8038. * @param vec The amount to translate the bone
  8039. * @param space The space that the translation is in
  8040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8041. */
  8042. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8043. /**
  8044. * Set the postion of the bone in local or world space
  8045. * @param position The position to set the bone
  8046. * @param space The space that the position is in
  8047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8048. */
  8049. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8050. /**
  8051. * Set the absolute position of the bone (world space)
  8052. * @param position The position to set the bone
  8053. * @param mesh The mesh that this bone is attached to
  8054. */
  8055. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8056. /**
  8057. * Scale the bone on the x, y and z axes (in local space)
  8058. * @param x The amount to scale the bone on the x axis
  8059. * @param y The amount to scale the bone on the y axis
  8060. * @param z The amount to scale the bone on the z axis
  8061. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8062. */
  8063. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8064. /**
  8065. * Set the bone scaling in local space
  8066. * @param scale defines the scaling vector
  8067. */
  8068. setScale(scale: Vector3): void;
  8069. /**
  8070. * Gets the current scaling in local space
  8071. * @returns the current scaling vector
  8072. */
  8073. getScale(): Vector3;
  8074. /**
  8075. * Gets the current scaling in local space and stores it in a target vector
  8076. * @param result defines the target vector
  8077. */
  8078. getScaleToRef(result: Vector3): void;
  8079. /**
  8080. * Set the yaw, pitch, and roll of the bone in local or world space
  8081. * @param yaw The rotation of the bone on the y axis
  8082. * @param pitch The rotation of the bone on the x axis
  8083. * @param roll The rotation of the bone on the z axis
  8084. * @param space The space that the axes of rotation are in
  8085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8086. */
  8087. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8088. /**
  8089. * Add a rotation to the bone on an axis in local or world space
  8090. * @param axis The axis to rotate the bone on
  8091. * @param amount The amount to rotate the bone
  8092. * @param space The space that the axis is in
  8093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8094. */
  8095. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8096. /**
  8097. * Set the rotation of the bone to a particular axis angle in local or world space
  8098. * @param axis The axis to rotate the bone on
  8099. * @param angle The angle that the bone should be rotated to
  8100. * @param space The space that the axis is in
  8101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8102. */
  8103. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8104. /**
  8105. * Set the euler rotation of the bone in local of world space
  8106. * @param rotation The euler rotation that the bone should be set to
  8107. * @param space The space that the rotation is in
  8108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8109. */
  8110. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8111. /**
  8112. * Set the quaternion rotation of the bone in local of world space
  8113. * @param quat The quaternion rotation that the bone should be set to
  8114. * @param space The space that the rotation is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation matrix of the bone in local of world space
  8120. * @param rotMat The rotation matrix that the bone should be set to
  8121. * @param space The space that the rotation is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8125. private _rotateWithMatrix;
  8126. private _getNegativeRotationToRef;
  8127. /**
  8128. * Get the position of the bone in local or world space
  8129. * @param space The space that the returned position is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. * @returns The position of the bone
  8132. */
  8133. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8134. /**
  8135. * Copy the position of the bone to a vector3 in local or world space
  8136. * @param space The space that the returned position is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. * @param result The vector3 to copy the position to
  8139. */
  8140. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8141. /**
  8142. * Get the absolute position of the bone (world space)
  8143. * @param mesh The mesh that this bone is attached to
  8144. * @returns The absolute position of the bone
  8145. */
  8146. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8147. /**
  8148. * Copy the absolute position of the bone (world space) to the result param
  8149. * @param mesh The mesh that this bone is attached to
  8150. * @param result The vector3 to copy the absolute position to
  8151. */
  8152. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8153. /**
  8154. * Compute the absolute transforms of this bone and its children
  8155. */
  8156. computeAbsoluteTransforms(): void;
  8157. /**
  8158. * Get the world direction from an axis that is in the local space of the bone
  8159. * @param localAxis The local direction that is used to compute the world direction
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @returns The world direction
  8162. */
  8163. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8164. /**
  8165. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8166. * @param localAxis The local direction that is used to compute the world direction
  8167. * @param mesh The mesh that this bone is attached to
  8168. * @param result The vector3 that the world direction will be copied to
  8169. */
  8170. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8171. /**
  8172. * Get the euler rotation of the bone in local or world space
  8173. * @param space The space that the rotation should be in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. * @returns The euler rotation
  8176. */
  8177. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8178. /**
  8179. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8180. * @param space The space that the rotation should be in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. * @param result The vector3 that the rotation should be copied to
  8183. */
  8184. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8185. /**
  8186. * Get the quaternion rotation of the bone in either local or world space
  8187. * @param space The space that the rotation should be in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. * @returns The quaternion rotation
  8190. */
  8191. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8192. /**
  8193. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8194. * @param space The space that the rotation should be in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. * @param result The quaternion that the rotation should be copied to
  8197. */
  8198. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8199. /**
  8200. * Get the rotation matrix of the bone in local or world space
  8201. * @param space The space that the rotation should be in
  8202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8203. * @returns The rotation matrix
  8204. */
  8205. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8206. /**
  8207. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8208. * @param space The space that the rotation should be in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. * @param result The quaternion that the rotation should be copied to
  8211. */
  8212. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8213. /**
  8214. * Get the world position of a point that is in the local space of the bone
  8215. * @param position The local position
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The world position
  8218. */
  8219. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8222. * @param position The local position
  8223. * @param mesh The mesh that this bone is attached to
  8224. * @param result The vector3 that the world position should be copied to
  8225. */
  8226. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8227. /**
  8228. * Get the local position of a point that is in world space
  8229. * @param position The world position
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @returns The local position
  8232. */
  8233. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8234. /**
  8235. * Get the local position of a point that is in world space and copy it to the result param
  8236. * @param position The world position
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @param result The vector3 that the local position should be copied to
  8239. */
  8240. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8241. }
  8242. }
  8243. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8244. import { Nullable } from "babylonjs/types";
  8245. import { Scene } from "babylonjs/scene";
  8246. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8248. /**
  8249. * Class for creating a cube texture
  8250. */
  8251. export class CubeTexture extends BaseTexture {
  8252. private _delayedOnLoad;
  8253. /**
  8254. * The url of the texture
  8255. */
  8256. url: string;
  8257. /**
  8258. * Gets or sets the center of the bounding box associated with the cube texture.
  8259. * It must define where the camera used to render the texture was set
  8260. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8261. */
  8262. boundingBoxPosition: Vector3;
  8263. private _boundingBoxSize;
  8264. /**
  8265. * Gets or sets the size of the bounding box associated with the cube texture
  8266. * When defined, the cubemap will switch to local mode
  8267. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8268. * @example https://www.babylonjs-playground.com/#RNASML
  8269. */
  8270. /**
  8271. * Returns the bounding box size
  8272. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8273. */
  8274. boundingBoxSize: Vector3;
  8275. protected _rotationY: number;
  8276. /**
  8277. * Sets texture matrix rotation angle around Y axis in radians.
  8278. */
  8279. /**
  8280. * Gets texture matrix rotation angle around Y axis radians.
  8281. */
  8282. rotationY: number;
  8283. /**
  8284. * Are mip maps generated for this texture or not.
  8285. */
  8286. readonly noMipmap: boolean;
  8287. private _noMipmap;
  8288. private _files;
  8289. private _extensions;
  8290. private _textureMatrix;
  8291. private _format;
  8292. private _createPolynomials;
  8293. /** @hidden */
  8294. _prefiltered: boolean;
  8295. /**
  8296. * Creates a cube texture from an array of image urls
  8297. * @param files defines an array of image urls
  8298. * @param scene defines the hosting scene
  8299. * @param noMipmap specifies if mip maps are not used
  8300. * @returns a cube texture
  8301. */
  8302. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8303. /**
  8304. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8305. * @param url defines the url of the prefiltered texture
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param forcedExtension defines the extension of the file if different from the url
  8308. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8309. * @return the prefiltered texture
  8310. */
  8311. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8312. /**
  8313. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8314. * as prefiltered data.
  8315. * @param rootUrl defines the url of the texture or the root name of the six images
  8316. * @param scene defines the scene the texture is attached to
  8317. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8318. * @param noMipmap defines if mipmaps should be created or not
  8319. * @param files defines the six files to load for the different faces
  8320. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8321. * @param onError defines a callback triggered in case of error during load
  8322. * @param format defines the internal format to use for the texture once loaded
  8323. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8324. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8325. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8328. * @return the cube texture
  8329. */
  8330. 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);
  8331. /**
  8332. * Get the current class name of the texture useful for serialization or dynamic coding.
  8333. * @returns "CubeTexture"
  8334. */
  8335. getClassName(): string;
  8336. /**
  8337. * Update the url (and optional buffer) of this texture if url was null during construction.
  8338. * @param url the url of the texture
  8339. * @param forcedExtension defines the extension to use
  8340. * @param onLoad callback called when the texture is loaded (defaults to null)
  8341. */
  8342. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8343. /**
  8344. * Delays loading of the cube texture
  8345. * @param forcedExtension defines the extension to use
  8346. */
  8347. delayLoad(forcedExtension?: string): void;
  8348. /**
  8349. * Returns the reflection texture matrix
  8350. * @returns the reflection texture matrix
  8351. */
  8352. getReflectionTextureMatrix(): Matrix;
  8353. /**
  8354. * Sets the reflection texture matrix
  8355. * @param value Reflection texture matrix
  8356. */
  8357. setReflectionTextureMatrix(value: Matrix): void;
  8358. /**
  8359. * Parses text to create a cube texture
  8360. * @param parsedTexture define the serialized text to read from
  8361. * @param scene defines the hosting scene
  8362. * @param rootUrl defines the root url of the cube texture
  8363. * @returns a cube texture
  8364. */
  8365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8366. /**
  8367. * Makes a clone, or deep copy, of the cube texture
  8368. * @returns a new cube texture
  8369. */
  8370. clone(): CubeTexture;
  8371. }
  8372. }
  8373. declare module "babylonjs/Shaders/postprocess.vertex" {
  8374. /** @hidden */
  8375. export var postprocessVertexShader: {
  8376. name: string;
  8377. shader: string;
  8378. };
  8379. }
  8380. declare module "babylonjs/Cameras/targetCamera" {
  8381. import { Nullable } from "babylonjs/types";
  8382. import { Camera } from "babylonjs/Cameras/camera";
  8383. import { Scene } from "babylonjs/scene";
  8384. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8385. /**
  8386. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8387. * This is the base of the follow, arc rotate cameras and Free camera
  8388. * @see http://doc.babylonjs.com/features/cameras
  8389. */
  8390. export class TargetCamera extends Camera {
  8391. private static _RigCamTransformMatrix;
  8392. private static _TargetTransformMatrix;
  8393. private static _TargetFocalPoint;
  8394. /**
  8395. * Define the current direction the camera is moving to
  8396. */
  8397. cameraDirection: Vector3;
  8398. /**
  8399. * Define the current rotation the camera is rotating to
  8400. */
  8401. cameraRotation: Vector2;
  8402. /**
  8403. * When set, the up vector of the camera will be updated by the rotation of the camera
  8404. */
  8405. updateUpVectorFromRotation: boolean;
  8406. private _tmpQuaternion;
  8407. /**
  8408. * Define the current rotation of the camera
  8409. */
  8410. rotation: Vector3;
  8411. /**
  8412. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8413. */
  8414. rotationQuaternion: Quaternion;
  8415. /**
  8416. * Define the current speed of the camera
  8417. */
  8418. speed: number;
  8419. /**
  8420. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8421. * around all axis.
  8422. */
  8423. noRotationConstraint: boolean;
  8424. /**
  8425. * Define the current target of the camera as an object or a position.
  8426. */
  8427. lockedTarget: any;
  8428. /** @hidden */
  8429. _currentTarget: Vector3;
  8430. /** @hidden */
  8431. _initialFocalDistance: number;
  8432. /** @hidden */
  8433. _viewMatrix: Matrix;
  8434. /** @hidden */
  8435. _camMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraTransformMatrix: Matrix;
  8438. /** @hidden */
  8439. _cameraRotationMatrix: Matrix;
  8440. /** @hidden */
  8441. _referencePoint: Vector3;
  8442. /** @hidden */
  8443. _transformedReferencePoint: Vector3;
  8444. protected _globalCurrentTarget: Vector3;
  8445. protected _globalCurrentUpVector: Vector3;
  8446. /** @hidden */
  8447. _reset: () => void;
  8448. private _defaultUp;
  8449. /**
  8450. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8451. * This is the base of the follow, arc rotate cameras and Free camera
  8452. * @see http://doc.babylonjs.com/features/cameras
  8453. * @param name Defines the name of the camera in the scene
  8454. * @param position Defines the start position of the camera in the scene
  8455. * @param scene Defines the scene the camera belongs to
  8456. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8457. */
  8458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8459. /**
  8460. * Gets the position in front of the camera at a given distance.
  8461. * @param distance The distance from the camera we want the position to be
  8462. * @returns the position
  8463. */
  8464. getFrontPosition(distance: number): Vector3;
  8465. /** @hidden */
  8466. _getLockedTargetPosition(): Nullable<Vector3>;
  8467. private _storedPosition;
  8468. private _storedRotation;
  8469. private _storedRotationQuaternion;
  8470. /**
  8471. * Store current camera state of the camera (fov, position, rotation, etc..)
  8472. * @returns the camera
  8473. */
  8474. storeState(): Camera;
  8475. /**
  8476. * Restored camera state. You must call storeState() first
  8477. * @returns whether it was successful or not
  8478. * @hidden
  8479. */
  8480. _restoreStateValues(): boolean;
  8481. /** @hidden */
  8482. _initCache(): void;
  8483. /** @hidden */
  8484. _updateCache(ignoreParentClass?: boolean): void;
  8485. /** @hidden */
  8486. _isSynchronizedViewMatrix(): boolean;
  8487. /** @hidden */
  8488. _computeLocalCameraSpeed(): number;
  8489. /**
  8490. * Defines the target the camera should look at.
  8491. * This will automatically adapt alpha beta and radius to fit within the new target.
  8492. * @param target Defines the new target as a Vector or a mesh
  8493. */
  8494. setTarget(target: Vector3): void;
  8495. /**
  8496. * Return the current target position of the camera. This value is expressed in local space.
  8497. * @returns the target position
  8498. */
  8499. getTarget(): Vector3;
  8500. /** @hidden */
  8501. _decideIfNeedsToMove(): boolean;
  8502. /** @hidden */
  8503. _updatePosition(): void;
  8504. /** @hidden */
  8505. _checkInputs(): void;
  8506. protected _updateCameraRotationMatrix(): void;
  8507. /**
  8508. * 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)
  8509. * @returns the current camera
  8510. */
  8511. private _rotateUpVectorWithCameraRotationMatrix;
  8512. private _cachedRotationZ;
  8513. private _cachedQuaternionRotationZ;
  8514. /** @hidden */
  8515. _getViewMatrix(): Matrix;
  8516. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8517. /**
  8518. * @hidden
  8519. */
  8520. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8521. /**
  8522. * @hidden
  8523. */
  8524. _updateRigCameras(): void;
  8525. private _getRigCamPositionAndTarget;
  8526. /**
  8527. * Gets the current object class name.
  8528. * @return the class name
  8529. */
  8530. getClassName(): string;
  8531. }
  8532. }
  8533. declare module "babylonjs/Cameras/cameraInputsManager" {
  8534. import { Nullable } from "babylonjs/types";
  8535. import { Camera } from "babylonjs/Cameras/camera";
  8536. /**
  8537. * @ignore
  8538. * This is a list of all the different input types that are available in the application.
  8539. * Fo instance: ArcRotateCameraGamepadInput...
  8540. */
  8541. export var CameraInputTypes: {};
  8542. /**
  8543. * This is the contract to implement in order to create a new input class.
  8544. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8545. */
  8546. export interface ICameraInput<TCamera extends Camera> {
  8547. /**
  8548. * Defines the camera the input is attached to.
  8549. */
  8550. camera: Nullable<TCamera>;
  8551. /**
  8552. * Gets the class name of the current intput.
  8553. * @returns the class name
  8554. */
  8555. getClassName(): string;
  8556. /**
  8557. * Get the friendly name associated with the input class.
  8558. * @returns the input friendly name
  8559. */
  8560. getSimpleName(): string;
  8561. /**
  8562. * Attach the input controls to a specific dom element to get the input from.
  8563. * @param element Defines the element the controls should be listened from
  8564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8565. */
  8566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8567. /**
  8568. * Detach the current controls from the specified dom element.
  8569. * @param element Defines the element to stop listening the inputs from
  8570. */
  8571. detachControl(element: Nullable<HTMLElement>): void;
  8572. /**
  8573. * Update the current camera state depending on the inputs that have been used this frame.
  8574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8575. */
  8576. checkInputs?: () => void;
  8577. }
  8578. /**
  8579. * Represents a map of input types to input instance or input index to input instance.
  8580. */
  8581. export interface CameraInputsMap<TCamera extends Camera> {
  8582. /**
  8583. * Accessor to the input by input type.
  8584. */
  8585. [name: string]: ICameraInput<TCamera>;
  8586. /**
  8587. * Accessor to the input by input index.
  8588. */
  8589. [idx: number]: ICameraInput<TCamera>;
  8590. }
  8591. /**
  8592. * This represents the input manager used within a camera.
  8593. * It helps dealing with all the different kind of input attached to a camera.
  8594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8595. */
  8596. export class CameraInputsManager<TCamera extends Camera> {
  8597. /**
  8598. * Defines the list of inputs attahed to the camera.
  8599. */
  8600. attached: CameraInputsMap<TCamera>;
  8601. /**
  8602. * Defines the dom element the camera is collecting inputs from.
  8603. * This is null if the controls have not been attached.
  8604. */
  8605. attachedElement: Nullable<HTMLElement>;
  8606. /**
  8607. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8608. */
  8609. noPreventDefault: boolean;
  8610. /**
  8611. * Defined the camera the input manager belongs to.
  8612. */
  8613. camera: TCamera;
  8614. /**
  8615. * Update the current camera state depending on the inputs that have been used this frame.
  8616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8617. */
  8618. checkInputs: () => void;
  8619. /**
  8620. * Instantiate a new Camera Input Manager.
  8621. * @param camera Defines the camera the input manager blongs to
  8622. */
  8623. constructor(camera: TCamera);
  8624. /**
  8625. * Add an input method to a camera
  8626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8627. * @param input camera input method
  8628. */
  8629. add(input: ICameraInput<TCamera>): void;
  8630. /**
  8631. * Remove a specific input method from a camera
  8632. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8633. * @param inputToRemove camera input method
  8634. */
  8635. remove(inputToRemove: ICameraInput<TCamera>): void;
  8636. /**
  8637. * Remove a specific input type from a camera
  8638. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8639. * @param inputType the type of the input to remove
  8640. */
  8641. removeByType(inputType: string): void;
  8642. private _addCheckInputs;
  8643. /**
  8644. * Attach the input controls to the currently attached dom element to listen the events from.
  8645. * @param input Defines the input to attach
  8646. */
  8647. attachInput(input: ICameraInput<TCamera>): void;
  8648. /**
  8649. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8650. * @param element Defines the dom element to collect the events from
  8651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8652. */
  8653. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8654. /**
  8655. * Detach the current manager inputs controls from a specific dom element.
  8656. * @param element Defines the dom element to collect the events from
  8657. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8658. */
  8659. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8660. /**
  8661. * Rebuild the dynamic inputCheck function from the current list of
  8662. * defined inputs in the manager.
  8663. */
  8664. rebuildInputCheck(): void;
  8665. /**
  8666. * Remove all attached input methods from a camera
  8667. */
  8668. clear(): void;
  8669. /**
  8670. * Serialize the current input manager attached to a camera.
  8671. * This ensures than once parsed,
  8672. * the input associated to the camera will be identical to the current ones
  8673. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8674. */
  8675. serialize(serializedCamera: any): void;
  8676. /**
  8677. * Parses an input manager serialized JSON to restore the previous list of inputs
  8678. * and states associated to a camera.
  8679. * @param parsedCamera Defines the JSON to parse
  8680. */
  8681. parse(parsedCamera: any): void;
  8682. }
  8683. }
  8684. declare module "babylonjs/Events/keyboardEvents" {
  8685. /**
  8686. * Gather the list of keyboard event types as constants.
  8687. */
  8688. export class KeyboardEventTypes {
  8689. /**
  8690. * The keydown event is fired when a key becomes active (pressed).
  8691. */
  8692. static readonly KEYDOWN: number;
  8693. /**
  8694. * The keyup event is fired when a key has been released.
  8695. */
  8696. static readonly KEYUP: number;
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8700. */
  8701. export class KeyboardInfo {
  8702. /**
  8703. * Defines the type of event (KeyboardEventTypes)
  8704. */
  8705. type: number;
  8706. /**
  8707. * Defines the related dom event
  8708. */
  8709. event: KeyboardEvent;
  8710. /**
  8711. * Instantiates a new keyboard info.
  8712. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8713. * @param type Defines the type of event (KeyboardEventTypes)
  8714. * @param event Defines the related dom event
  8715. */
  8716. constructor(
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number,
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent);
  8725. }
  8726. /**
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8729. */
  8730. export class KeyboardInfoPre extends KeyboardInfo {
  8731. /**
  8732. * Defines the type of event (KeyboardEventTypes)
  8733. */
  8734. type: number;
  8735. /**
  8736. * Defines the related dom event
  8737. */
  8738. event: KeyboardEvent;
  8739. /**
  8740. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8741. */
  8742. skipOnPointerObservable: boolean;
  8743. /**
  8744. * Instantiates a new keyboard pre info.
  8745. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8746. * @param type Defines the type of event (KeyboardEventTypes)
  8747. * @param event Defines the related dom event
  8748. */
  8749. constructor(
  8750. /**
  8751. * Defines the type of event (KeyboardEventTypes)
  8752. */
  8753. type: number,
  8754. /**
  8755. * Defines the related dom event
  8756. */
  8757. event: KeyboardEvent);
  8758. }
  8759. }
  8760. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8761. import { Nullable } from "babylonjs/types";
  8762. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8763. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8764. /**
  8765. * Manage the keyboard inputs to control the movement of a free camera.
  8766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8767. */
  8768. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8769. /**
  8770. * Defines the camera the input is attached to.
  8771. */
  8772. camera: FreeCamera;
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8775. */
  8776. keysUp: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8779. */
  8780. keysDown: number[];
  8781. /**
  8782. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8783. */
  8784. keysLeft: number[];
  8785. /**
  8786. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8787. */
  8788. keysRight: number[];
  8789. private _keys;
  8790. private _onCanvasBlurObserver;
  8791. private _onKeyboardObserver;
  8792. private _engine;
  8793. private _scene;
  8794. /**
  8795. * Attach the input controls to a specific dom element to get the input from.
  8796. * @param element Defines the element the controls should be listened from
  8797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8798. */
  8799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8800. /**
  8801. * Detach the current controls from the specified dom element.
  8802. * @param element Defines the element to stop listening the inputs from
  8803. */
  8804. detachControl(element: Nullable<HTMLElement>): void;
  8805. /**
  8806. * Update the current camera state depending on the inputs that have been used this frame.
  8807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8808. */
  8809. checkInputs(): void;
  8810. /**
  8811. * Gets the class name of the current intput.
  8812. * @returns the class name
  8813. */
  8814. getClassName(): string;
  8815. /** @hidden */
  8816. _onLostFocus(): void;
  8817. /**
  8818. * Get the friendly name associated with the input class.
  8819. * @returns the input friendly name
  8820. */
  8821. getSimpleName(): string;
  8822. }
  8823. }
  8824. declare module "babylonjs/Lights/shadowLight" {
  8825. import { Camera } from "babylonjs/Cameras/camera";
  8826. import { Scene } from "babylonjs/scene";
  8827. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8829. import { Light } from "babylonjs/Lights/light";
  8830. /**
  8831. * Interface describing all the common properties and methods a shadow light needs to implement.
  8832. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8833. * as well as binding the different shadow properties to the effects.
  8834. */
  8835. export interface IShadowLight extends Light {
  8836. /**
  8837. * The light id in the scene (used in scene.findLighById for instance)
  8838. */
  8839. id: string;
  8840. /**
  8841. * The position the shdow will be casted from.
  8842. */
  8843. position: Vector3;
  8844. /**
  8845. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8846. */
  8847. direction: Vector3;
  8848. /**
  8849. * The transformed position. Position of the light in world space taking parenting in account.
  8850. */
  8851. transformedPosition: Vector3;
  8852. /**
  8853. * The transformed direction. Direction of the light in world space taking parenting in account.
  8854. */
  8855. transformedDirection: Vector3;
  8856. /**
  8857. * The friendly name of the light in the scene.
  8858. */
  8859. name: string;
  8860. /**
  8861. * Defines the shadow projection clipping minimum z value.
  8862. */
  8863. shadowMinZ: number;
  8864. /**
  8865. * Defines the shadow projection clipping maximum z value.
  8866. */
  8867. shadowMaxZ: number;
  8868. /**
  8869. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8870. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8871. */
  8872. computeTransformedInformation(): boolean;
  8873. /**
  8874. * Gets the scene the light belongs to.
  8875. * @returns The scene
  8876. */
  8877. getScene(): Scene;
  8878. /**
  8879. * Callback defining a custom Projection Matrix Builder.
  8880. * This can be used to override the default projection matrix computation.
  8881. */
  8882. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8883. /**
  8884. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8885. * @param matrix The materix to updated with the projection information
  8886. * @param viewMatrix The transform matrix of the light
  8887. * @param renderList The list of mesh to render in the map
  8888. * @returns The current light
  8889. */
  8890. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8891. /**
  8892. * Gets the current depth scale used in ESM.
  8893. * @returns The scale
  8894. */
  8895. getDepthScale(): number;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /**
  8911. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8912. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8913. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8914. */
  8915. getShadowDirection(faceIndex?: number): Vector3;
  8916. /**
  8917. * Gets the minZ used for shadow according to both the scene and the light.
  8918. * @param activeCamera The camera we are returning the min for
  8919. * @returns the depth min z
  8920. */
  8921. getDepthMinZ(activeCamera: Camera): number;
  8922. /**
  8923. * Gets the maxZ used for shadow according to both the scene and the light.
  8924. * @param activeCamera The camera we are returning the max for
  8925. * @returns the depth max z
  8926. */
  8927. getDepthMaxZ(activeCamera: Camera): number;
  8928. }
  8929. /**
  8930. * Base implementation IShadowLight
  8931. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8932. */
  8933. export abstract class ShadowLight extends Light implements IShadowLight {
  8934. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8935. protected _position: Vector3;
  8936. protected _setPosition(value: Vector3): void;
  8937. /**
  8938. * Sets the position the shadow will be casted from. Also use as the light position for both
  8939. * point and spot lights.
  8940. */
  8941. /**
  8942. * Sets the position the shadow will be casted from. Also use as the light position for both
  8943. * point and spot lights.
  8944. */
  8945. position: Vector3;
  8946. protected _direction: Vector3;
  8947. protected _setDirection(value: Vector3): void;
  8948. /**
  8949. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8950. * Also use as the light direction on spot and directional lights.
  8951. */
  8952. /**
  8953. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8954. * Also use as the light direction on spot and directional lights.
  8955. */
  8956. direction: Vector3;
  8957. private _shadowMinZ;
  8958. /**
  8959. * Gets the shadow projection clipping minimum z value.
  8960. */
  8961. /**
  8962. * Sets the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. private _shadowMaxZ;
  8966. /**
  8967. * Sets the shadow projection clipping maximum z value.
  8968. */
  8969. /**
  8970. * Gets the shadow projection clipping maximum z value.
  8971. */
  8972. shadowMaxZ: number;
  8973. /**
  8974. * Callback defining a custom Projection Matrix Builder.
  8975. * This can be used to override the default projection matrix computation.
  8976. */
  8977. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8978. /**
  8979. * The transformed position. Position of the light in world space taking parenting in account.
  8980. */
  8981. transformedPosition: Vector3;
  8982. /**
  8983. * The transformed direction. Direction of the light in world space taking parenting in account.
  8984. */
  8985. transformedDirection: Vector3;
  8986. private _needProjectionMatrixCompute;
  8987. /**
  8988. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8989. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8990. */
  8991. computeTransformedInformation(): boolean;
  8992. /**
  8993. * Return the depth scale used for the shadow map.
  8994. * @returns the depth scale.
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8999. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9000. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9001. */
  9002. getShadowDirection(faceIndex?: number): Vector3;
  9003. /**
  9004. * Returns the ShadowLight absolute position in the World.
  9005. * @returns the position vector in world space
  9006. */
  9007. getAbsolutePosition(): Vector3;
  9008. /**
  9009. * Sets the ShadowLight direction toward the passed target.
  9010. * @param target The point to target in local space
  9011. * @returns the updated ShadowLight direction
  9012. */
  9013. setDirectionToTarget(target: Vector3): Vector3;
  9014. /**
  9015. * Returns the light rotation in euler definition.
  9016. * @returns the x y z rotation in local space.
  9017. */
  9018. getRotation(): Vector3;
  9019. /**
  9020. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9021. * @returns true if a cube texture needs to be use
  9022. */
  9023. needCube(): boolean;
  9024. /**
  9025. * Detects if the projection matrix requires to be recomputed this frame.
  9026. * @returns true if it requires to be recomputed otherwise, false.
  9027. */
  9028. needProjectionMatrixCompute(): boolean;
  9029. /**
  9030. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9031. */
  9032. forceProjectionMatrixCompute(): void;
  9033. /** @hidden */
  9034. _initCache(): void;
  9035. /** @hidden */
  9036. _isSynchronized(): boolean;
  9037. /**
  9038. * Computes the world matrix of the node
  9039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9040. * @returns the world matrix
  9041. */
  9042. computeWorldMatrix(force?: boolean): Matrix;
  9043. /**
  9044. * Gets the minZ used for shadow according to both the scene and the light.
  9045. * @param activeCamera The camera we are returning the min for
  9046. * @returns the depth min z
  9047. */
  9048. getDepthMinZ(activeCamera: Camera): number;
  9049. /**
  9050. * Gets the maxZ used for shadow according to both the scene and the light.
  9051. * @param activeCamera The camera we are returning the max for
  9052. * @returns the depth max z
  9053. */
  9054. getDepthMaxZ(activeCamera: Camera): number;
  9055. /**
  9056. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9057. * @param matrix The materix to updated with the projection information
  9058. * @param viewMatrix The transform matrix of the light
  9059. * @param renderList The list of mesh to render in the map
  9060. * @returns The current light
  9061. */
  9062. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9063. }
  9064. }
  9065. declare module "babylonjs/Materials/materialHelper" {
  9066. import { Nullable } from "babylonjs/types";
  9067. import { Scene } from "babylonjs/scene";
  9068. import { Engine } from "babylonjs/Engines/engine";
  9069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9070. import { Light } from "babylonjs/Lights/light";
  9071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9072. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9074. /**
  9075. * "Static Class" containing the most commonly used helper while dealing with material for
  9076. * rendering purpose.
  9077. *
  9078. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9079. *
  9080. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9081. */
  9082. export class MaterialHelper {
  9083. /**
  9084. * Bind the current view position to an effect.
  9085. * @param effect The effect to be bound
  9086. * @param scene The scene the eyes position is used from
  9087. */
  9088. static BindEyePosition(effect: Effect, scene: Scene): void;
  9089. /**
  9090. * Helps preparing the defines values about the UVs in used in the effect.
  9091. * UVs are shared as much as we can accross channels in the shaders.
  9092. * @param texture The texture we are preparing the UVs for
  9093. * @param defines The defines to update
  9094. * @param key The channel key "diffuse", "specular"... used in the shader
  9095. */
  9096. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9097. /**
  9098. * Binds a texture matrix value to its corrsponding uniform
  9099. * @param texture The texture to bind the matrix for
  9100. * @param uniformBuffer The uniform buffer receivin the data
  9101. * @param key The channel key "diffuse", "specular"... used in the shader
  9102. */
  9103. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9104. /**
  9105. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9106. * @param mesh defines the current mesh
  9107. * @param scene defines the current scene
  9108. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9109. * @param pointsCloud defines if point cloud rendering has to be turned on
  9110. * @param fogEnabled defines if fog has to be turned on
  9111. * @param alphaTest defines if alpha testing has to be turned on
  9112. * @param defines defines the current list of defines
  9113. */
  9114. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9115. /**
  9116. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9117. * @param scene defines the current scene
  9118. * @param engine defines the current engine
  9119. * @param defines specifies the list of active defines
  9120. * @param useInstances defines if instances have to be turned on
  9121. * @param useClipPlane defines if clip plane have to be turned on
  9122. */
  9123. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9124. /**
  9125. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9126. * @param mesh The mesh containing the geometry data we will draw
  9127. * @param defines The defines to update
  9128. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9129. * @param useBones Precise whether bones should be used or not (override mesh info)
  9130. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9131. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9132. * @returns false if defines are considered not dirty and have not been checked
  9133. */
  9134. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9135. /**
  9136. * Prepares the defines related to the light information passed in parameter
  9137. * @param scene The scene we are intending to draw
  9138. * @param mesh The mesh the effect is compiling for
  9139. * @param defines The defines to update
  9140. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9141. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9142. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9143. * @returns true if normals will be required for the rest of the effect
  9144. */
  9145. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9146. /**
  9147. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9148. * that won t be acctive due to defines being turned off.
  9149. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9150. * @param samplersList The samplers list
  9151. * @param defines The defines helping in the list generation
  9152. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9153. */
  9154. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9155. /**
  9156. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9157. * @param defines The defines to update while falling back
  9158. * @param fallbacks The authorized effect fallbacks
  9159. * @param maxSimultaneousLights The maximum number of lights allowed
  9160. * @param rank the current rank of the Effect
  9161. * @returns The newly affected rank
  9162. */
  9163. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9164. /**
  9165. * Prepares the list of attributes required for morph targets according to the effect defines.
  9166. * @param attribs The current list of supported attribs
  9167. * @param mesh The mesh to prepare the morph targets attributes for
  9168. * @param defines The current Defines of the effect
  9169. */
  9170. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9171. /**
  9172. * Prepares the list of attributes required for bones according to the effect defines.
  9173. * @param attribs The current list of supported attribs
  9174. * @param mesh The mesh to prepare the bones attributes for
  9175. * @param defines The current Defines of the effect
  9176. * @param fallbacks The current efffect fallback strategy
  9177. */
  9178. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9179. /**
  9180. * Prepares the list of attributes required for instances according to the effect defines.
  9181. * @param attribs The current list of supported attribs
  9182. * @param defines The current Defines of the effect
  9183. */
  9184. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9185. /**
  9186. * Binds the light shadow information to the effect for the given mesh.
  9187. * @param light The light containing the generator
  9188. * @param scene The scene the lights belongs to
  9189. * @param mesh The mesh we are binding the information to render
  9190. * @param lightIndex The light index in the effect used to render the mesh
  9191. * @param effect The effect we are binding the data to
  9192. */
  9193. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9194. /**
  9195. * Binds the light information to the effect.
  9196. * @param light The light containing the generator
  9197. * @param effect The effect we are binding the data to
  9198. * @param lightIndex The light index in the effect used to render
  9199. */
  9200. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9201. /**
  9202. * Binds the lights information from the scene to the effect for the given mesh.
  9203. * @param scene The scene the lights belongs to
  9204. * @param mesh The mesh we are binding the information to render
  9205. * @param effect The effect we are binding the data to
  9206. * @param defines The generated defines for the effect
  9207. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9208. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9209. */
  9210. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9211. private static _tempFogColor;
  9212. /**
  9213. * Binds the fog information from the scene to the effect for the given mesh.
  9214. * @param scene The scene the lights belongs to
  9215. * @param mesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. * @param linearSpace Defines if the fog effect is applied in linear space
  9218. */
  9219. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9220. /**
  9221. * Binds the bones information from the mesh to the effect.
  9222. * @param mesh The mesh we are binding the information to render
  9223. * @param effect The effect we are binding the data to
  9224. */
  9225. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9226. /**
  9227. * Binds the morph targets information from the mesh to the effect.
  9228. * @param abstractMesh The mesh we are binding the information to render
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9232. /**
  9233. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9234. * @param defines The generated defines used in the effect
  9235. * @param effect The effect we are binding the data to
  9236. * @param scene The scene we are willing to render with logarithmic scale for
  9237. */
  9238. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Binds the clip plane information from the scene to the effect.
  9241. * @param scene The scene the clip plane information are extracted from
  9242. * @param effect The effect we are binding the data to
  9243. */
  9244. static BindClipPlane(effect: Effect, scene: Scene): void;
  9245. }
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9248. /** @hidden */
  9249. export var kernelBlurVaryingDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9255. /** @hidden */
  9256. export var kernelBlurFragment: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9262. /** @hidden */
  9263. export var kernelBlurFragment2: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9269. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9270. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9272. /** @hidden */
  9273. export var kernelBlurPixelShader: {
  9274. name: string;
  9275. shader: string;
  9276. };
  9277. }
  9278. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9279. /** @hidden */
  9280. export var kernelBlurVertex: {
  9281. name: string;
  9282. shader: string;
  9283. };
  9284. }
  9285. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9286. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9287. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9288. /** @hidden */
  9289. export var kernelBlurVertexShader: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9295. import { Vector2 } from "babylonjs/Maths/math";
  9296. import { Nullable } from "babylonjs/types";
  9297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9298. import { Camera } from "babylonjs/Cameras/camera";
  9299. import { Effect } from "babylonjs/Materials/effect";
  9300. import { Engine } from "babylonjs/Engines/engine";
  9301. import "babylonjs/Shaders/kernelBlur.fragment";
  9302. import "babylonjs/Shaders/kernelBlur.vertex";
  9303. /**
  9304. * The Blur Post Process which blurs an image based on a kernel and direction.
  9305. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9306. */
  9307. export class BlurPostProcess extends PostProcess {
  9308. /** The direction in which to blur the image. */
  9309. direction: Vector2;
  9310. private blockCompilation;
  9311. protected _kernel: number;
  9312. protected _idealKernel: number;
  9313. protected _packedFloat: boolean;
  9314. private _staticDefines;
  9315. /**
  9316. * Sets the length in pixels of the blur sample region
  9317. */
  9318. /**
  9319. * Gets the length in pixels of the blur sample region
  9320. */
  9321. kernel: number;
  9322. /**
  9323. * Sets wether or not the blur needs to unpack/repack floats
  9324. */
  9325. /**
  9326. * Gets wether or not the blur is unpacking/repacking floats
  9327. */
  9328. packedFloat: boolean;
  9329. /**
  9330. * Creates a new instance BlurPostProcess
  9331. * @param name The name of the effect.
  9332. * @param direction The direction in which to blur the image.
  9333. * @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.
  9334. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9335. * @param camera The camera to apply the render pass to.
  9336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9337. * @param engine The engine which the post process will be applied. (default: current engine)
  9338. * @param reusable If the post process can be reused on the same frame. (default: false)
  9339. * @param textureType Type of textures used when performing the post process. (default: 0)
  9340. * @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)
  9341. */
  9342. constructor(name: string,
  9343. /** The direction in which to blur the image. */
  9344. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9345. /**
  9346. * Updates the effect with the current post process compile time values and recompiles the shader.
  9347. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9348. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9349. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9350. * @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
  9351. * @param onCompiled Called when the shader has been compiled.
  9352. * @param onError Called if there is an error when compiling a shader.
  9353. */
  9354. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9355. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9356. /**
  9357. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9358. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9359. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9360. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9361. * The gaps between physical kernels are compensated for in the weighting of the samples
  9362. * @param idealKernel Ideal blur kernel.
  9363. * @return Nearest best kernel.
  9364. */
  9365. protected _nearestBestKernel(idealKernel: number): number;
  9366. /**
  9367. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9368. * @param x The point on the Gaussian distribution to sample.
  9369. * @return the value of the Gaussian function at x.
  9370. */
  9371. protected _gaussianWeight(x: number): number;
  9372. /**
  9373. * Generates a string that can be used as a floating point number in GLSL.
  9374. * @param x Value to print.
  9375. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9376. * @return GLSL float string.
  9377. */
  9378. protected _glslFloat(x: number, decimalFigures?: number): string;
  9379. }
  9380. }
  9381. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9382. /** @hidden */
  9383. export var shadowMapPixelShader: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9389. /** @hidden */
  9390. export var bonesDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9396. /** @hidden */
  9397. export var morphTargetsVertexGlobalDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9403. /** @hidden */
  9404. export var morphTargetsVertexDeclaration: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9410. /** @hidden */
  9411. export var instancesDeclaration: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9417. /** @hidden */
  9418. export var helperFunctions: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9424. /** @hidden */
  9425. export var morphTargetsVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9431. /** @hidden */
  9432. export var instancesVertex: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9438. /** @hidden */
  9439. export var bonesVertex: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9445. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9450. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9451. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9452. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9453. /** @hidden */
  9454. export var shadowMapVertexShader: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9460. /** @hidden */
  9461. export var depthBoxBlurPixelShader: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9467. import { Nullable } from "babylonjs/types";
  9468. import { Scene } from "babylonjs/scene";
  9469. import { Matrix } from "babylonjs/Maths/math";
  9470. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9472. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9473. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9474. import { Effect } from "babylonjs/Materials/effect";
  9475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9476. import "babylonjs/Shaders/shadowMap.fragment";
  9477. import "babylonjs/Shaders/shadowMap.vertex";
  9478. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9479. import { Observable } from "babylonjs/Misc/observable";
  9480. /**
  9481. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9482. */
  9483. export interface ICustomShaderOptions {
  9484. /**
  9485. * Gets or sets the custom shader name to use
  9486. */
  9487. shaderName: string;
  9488. /**
  9489. * The list of attribute names used in the shader
  9490. */
  9491. attributes?: string[];
  9492. /**
  9493. * The list of unifrom names used in the shader
  9494. */
  9495. uniforms?: string[];
  9496. /**
  9497. * The list of sampler names used in the shader
  9498. */
  9499. samplers?: string[];
  9500. /**
  9501. * The list of defines used in the shader
  9502. */
  9503. defines?: string[];
  9504. }
  9505. /**
  9506. * Interface to implement to create a shadow generator compatible with BJS.
  9507. */
  9508. export interface IShadowGenerator {
  9509. /**
  9510. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9511. * @returns The render target texture if present otherwise, null
  9512. */
  9513. getShadowMap(): Nullable<RenderTargetTexture>;
  9514. /**
  9515. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9516. * @returns The render target texture if the shadow map is present otherwise, null
  9517. */
  9518. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9519. /**
  9520. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9521. * @param subMesh The submesh we want to render in the shadow map
  9522. * @param useInstances Defines wether will draw in the map using instances
  9523. * @returns true if ready otherwise, false
  9524. */
  9525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9526. /**
  9527. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9528. * @param defines Defines of the material we want to update
  9529. * @param lightIndex Index of the light in the enabled light list of the material
  9530. */
  9531. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9532. /**
  9533. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9534. * defined in the generator but impacting the effect).
  9535. * It implies the unifroms available on the materials are the standard BJS ones.
  9536. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9537. * @param effect The effect we are binfing the information for
  9538. */
  9539. bindShadowLight(lightIndex: string, effect: Effect): void;
  9540. /**
  9541. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9542. * (eq to shadow prjection matrix * light transform matrix)
  9543. * @returns The transform matrix used to create the shadow map
  9544. */
  9545. getTransformMatrix(): Matrix;
  9546. /**
  9547. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9548. * Cube and 2D textures for instance.
  9549. */
  9550. recreateShadowMap(): void;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Serializes the shadow generator setup to a json object.
  9569. * @returns The serialized JSON object
  9570. */
  9571. serialize(): any;
  9572. /**
  9573. * Disposes the Shadow map and related Textures and effects.
  9574. */
  9575. dispose(): void;
  9576. }
  9577. /**
  9578. * Default implementation IShadowGenerator.
  9579. * This is the main object responsible of generating shadows in the framework.
  9580. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9581. */
  9582. export class ShadowGenerator implements IShadowGenerator {
  9583. /**
  9584. * Shadow generator mode None: no filtering applied.
  9585. */
  9586. static readonly FILTER_NONE: number;
  9587. /**
  9588. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9589. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9590. */
  9591. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9592. /**
  9593. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9594. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9595. */
  9596. static readonly FILTER_POISSONSAMPLING: number;
  9597. /**
  9598. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9599. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9600. */
  9601. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9602. /**
  9603. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9604. * edge artifacts on steep falloff.
  9605. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9606. */
  9607. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9608. /**
  9609. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9610. * edge artifacts on steep falloff.
  9611. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9612. */
  9613. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9614. /**
  9615. * Shadow generator mode PCF: Percentage Closer Filtering
  9616. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9617. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9618. */
  9619. static readonly FILTER_PCF: number;
  9620. /**
  9621. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9622. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9623. * Contact Hardening
  9624. */
  9625. static readonly FILTER_PCSS: number;
  9626. /**
  9627. * Reserved for PCF and PCSS
  9628. * Highest Quality.
  9629. *
  9630. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9631. *
  9632. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9633. */
  9634. static readonly QUALITY_HIGH: number;
  9635. /**
  9636. * Reserved for PCF and PCSS
  9637. * Good tradeoff for quality/perf cross devices
  9638. *
  9639. * Execute PCF on a 3*3 kernel.
  9640. *
  9641. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9642. */
  9643. static readonly QUALITY_MEDIUM: number;
  9644. /**
  9645. * Reserved for PCF and PCSS
  9646. * The lowest quality but the fastest.
  9647. *
  9648. * Execute PCF on a 1*1 kernel.
  9649. *
  9650. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9651. */
  9652. static readonly QUALITY_LOW: number;
  9653. /** Gets or sets the custom shader name to use */
  9654. customShaderOptions: ICustomShaderOptions;
  9655. /**
  9656. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9657. */
  9658. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9659. private _bias;
  9660. /**
  9661. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9662. */
  9663. /**
  9664. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9665. */
  9666. bias: number;
  9667. private _normalBias;
  9668. /**
  9669. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9670. */
  9671. /**
  9672. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9673. */
  9674. normalBias: number;
  9675. private _blurBoxOffset;
  9676. /**
  9677. * Gets the blur box offset: offset applied during the blur pass.
  9678. * Only useful if useKernelBlur = false
  9679. */
  9680. /**
  9681. * Sets the blur box offset: offset applied during the blur pass.
  9682. * Only useful if useKernelBlur = false
  9683. */
  9684. blurBoxOffset: number;
  9685. private _blurScale;
  9686. /**
  9687. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9688. * 2 means half of the size.
  9689. */
  9690. /**
  9691. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9692. * 2 means half of the size.
  9693. */
  9694. blurScale: number;
  9695. private _blurKernel;
  9696. /**
  9697. * Gets the blur kernel: kernel size of the blur pass.
  9698. * Only useful if useKernelBlur = true
  9699. */
  9700. /**
  9701. * Sets the blur kernel: kernel size of the blur pass.
  9702. * Only useful if useKernelBlur = true
  9703. */
  9704. blurKernel: number;
  9705. private _useKernelBlur;
  9706. /**
  9707. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9708. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9709. */
  9710. /**
  9711. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9712. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9713. */
  9714. useKernelBlur: boolean;
  9715. private _depthScale;
  9716. /**
  9717. * Gets the depth scale used in ESM mode.
  9718. */
  9719. /**
  9720. * Sets the depth scale used in ESM mode.
  9721. * This can override the scale stored on the light.
  9722. */
  9723. depthScale: number;
  9724. private _filter;
  9725. /**
  9726. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9727. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9728. */
  9729. /**
  9730. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9731. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9732. */
  9733. filter: number;
  9734. /**
  9735. * Gets if the current filter is set to Poisson Sampling.
  9736. */
  9737. /**
  9738. * Sets the current filter to Poisson Sampling.
  9739. */
  9740. usePoissonSampling: boolean;
  9741. /**
  9742. * Gets if the current filter is set to ESM.
  9743. */
  9744. /**
  9745. * Sets the current filter is to ESM.
  9746. */
  9747. useExponentialShadowMap: boolean;
  9748. /**
  9749. * Gets if the current filter is set to filtered ESM.
  9750. */
  9751. /**
  9752. * Gets if the current filter is set to filtered ESM.
  9753. */
  9754. useBlurExponentialShadowMap: boolean;
  9755. /**
  9756. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9757. * exponential to prevent steep falloff artifacts).
  9758. */
  9759. /**
  9760. * Sets the current filter to "close ESM" (using the inverse of the
  9761. * exponential to prevent steep falloff artifacts).
  9762. */
  9763. useCloseExponentialShadowMap: boolean;
  9764. /**
  9765. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9766. * exponential to prevent steep falloff artifacts).
  9767. */
  9768. /**
  9769. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9770. * exponential to prevent steep falloff artifacts).
  9771. */
  9772. useBlurCloseExponentialShadowMap: boolean;
  9773. /**
  9774. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9775. */
  9776. /**
  9777. * Sets the current filter to "PCF" (percentage closer filtering).
  9778. */
  9779. usePercentageCloserFiltering: boolean;
  9780. private _filteringQuality;
  9781. /**
  9782. * Gets the PCF or PCSS Quality.
  9783. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9784. */
  9785. /**
  9786. * Sets the PCF or PCSS Quality.
  9787. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9788. */
  9789. filteringQuality: number;
  9790. /**
  9791. * Gets if the current filter is set to "PCSS" (contact hardening).
  9792. */
  9793. /**
  9794. * Sets the current filter to "PCSS" (contact hardening).
  9795. */
  9796. useContactHardeningShadow: boolean;
  9797. private _contactHardeningLightSizeUVRatio;
  9798. /**
  9799. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9800. * Using a ratio helps keeping shape stability independently of the map size.
  9801. *
  9802. * It does not account for the light projection as it was having too much
  9803. * instability during the light setup or during light position changes.
  9804. *
  9805. * Only valid if useContactHardeningShadow is true.
  9806. */
  9807. /**
  9808. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9809. * Using a ratio helps keeping shape stability independently of the map size.
  9810. *
  9811. * It does not account for the light projection as it was having too much
  9812. * instability during the light setup or during light position changes.
  9813. *
  9814. * Only valid if useContactHardeningShadow is true.
  9815. */
  9816. contactHardeningLightSizeUVRatio: number;
  9817. private _darkness;
  9818. /**
  9819. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9820. * 0 means strongest and 1 would means no shadow.
  9821. * @returns the darkness.
  9822. */
  9823. getDarkness(): number;
  9824. /**
  9825. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9826. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9827. * @returns the shadow generator allowing fluent coding.
  9828. */
  9829. setDarkness(darkness: number): ShadowGenerator;
  9830. private _transparencyShadow;
  9831. /**
  9832. * Sets the ability to have transparent shadow (boolean).
  9833. * @param transparent True if transparent else False
  9834. * @returns the shadow generator allowing fluent coding
  9835. */
  9836. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9837. private _shadowMap;
  9838. private _shadowMap2;
  9839. /**
  9840. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9841. * @returns The render target texture if present otherwise, null
  9842. */
  9843. getShadowMap(): Nullable<RenderTargetTexture>;
  9844. /**
  9845. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9846. * @returns The render target texture if the shadow map is present otherwise, null
  9847. */
  9848. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9849. /**
  9850. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9851. * @param mesh Mesh to add
  9852. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9853. * @returns the Shadow Generator itself
  9854. */
  9855. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9856. /**
  9857. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9858. * @param mesh Mesh to remove
  9859. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9860. * @returns the Shadow Generator itself
  9861. */
  9862. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9863. /**
  9864. * Controls the extent to which the shadows fade out at the edge of the frustum
  9865. * Used only by directionals and spots
  9866. */
  9867. frustumEdgeFalloff: number;
  9868. private _light;
  9869. /**
  9870. * Returns the associated light object.
  9871. * @returns the light generating the shadow
  9872. */
  9873. getLight(): IShadowLight;
  9874. /**
  9875. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9876. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9877. * It might on the other hand introduce peter panning.
  9878. */
  9879. forceBackFacesOnly: boolean;
  9880. private _scene;
  9881. private _lightDirection;
  9882. private _effect;
  9883. private _viewMatrix;
  9884. private _projectionMatrix;
  9885. private _transformMatrix;
  9886. private _cachedPosition;
  9887. private _cachedDirection;
  9888. private _cachedDefines;
  9889. private _currentRenderID;
  9890. private _boxBlurPostprocess;
  9891. private _kernelBlurXPostprocess;
  9892. private _kernelBlurYPostprocess;
  9893. private _blurPostProcesses;
  9894. private _mapSize;
  9895. private _currentFaceIndex;
  9896. private _currentFaceIndexCache;
  9897. private _textureType;
  9898. private _defaultTextureMatrix;
  9899. /** @hidden */
  9900. static _SceneComponentInitialization: (scene: Scene) => void;
  9901. /**
  9902. * Creates a ShadowGenerator object.
  9903. * A ShadowGenerator is the required tool to use the shadows.
  9904. * Each light casting shadows needs to use its own ShadowGenerator.
  9905. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9906. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9907. * @param light The light object generating the shadows.
  9908. * @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.
  9909. */
  9910. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9911. private _initializeGenerator;
  9912. private _initializeShadowMap;
  9913. private _initializeBlurRTTAndPostProcesses;
  9914. private _renderForShadowMap;
  9915. private _renderSubMeshForShadowMap;
  9916. private _applyFilterValues;
  9917. /**
  9918. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9919. * @param onCompiled Callback triggered at the and of the effects compilation
  9920. * @param options Sets of optional options forcing the compilation with different modes
  9921. */
  9922. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9923. useInstances: boolean;
  9924. }>): void;
  9925. /**
  9926. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. * @returns A promise that resolves when the compilation completes
  9929. */
  9930. forceCompilationAsync(options?: Partial<{
  9931. useInstances: boolean;
  9932. }>): Promise<void>;
  9933. /**
  9934. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9935. * @param subMesh The submesh we want to render in the shadow map
  9936. * @param useInstances Defines wether will draw in the map using instances
  9937. * @returns true if ready otherwise, false
  9938. */
  9939. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9940. /**
  9941. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9942. * @param defines Defines of the material we want to update
  9943. * @param lightIndex Index of the light in the enabled light list of the material
  9944. */
  9945. prepareDefines(defines: any, lightIndex: number): void;
  9946. /**
  9947. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9948. * defined in the generator but impacting the effect).
  9949. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9950. * @param effect The effect we are binfing the information for
  9951. */
  9952. bindShadowLight(lightIndex: string, effect: Effect): void;
  9953. /**
  9954. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9955. * (eq to shadow prjection matrix * light transform matrix)
  9956. * @returns The transform matrix used to create the shadow map
  9957. */
  9958. getTransformMatrix(): Matrix;
  9959. /**
  9960. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9961. * Cube and 2D textures for instance.
  9962. */
  9963. recreateShadowMap(): void;
  9964. private _disposeBlurPostProcesses;
  9965. private _disposeRTTandPostProcesses;
  9966. /**
  9967. * Disposes the ShadowGenerator.
  9968. * Returns nothing.
  9969. */
  9970. dispose(): void;
  9971. /**
  9972. * Serializes the shadow generator setup to a json object.
  9973. * @returns The serialized JSON object
  9974. */
  9975. serialize(): any;
  9976. /**
  9977. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9978. * @param parsedShadowGenerator The JSON object to parse
  9979. * @param scene The scene to create the shadow map for
  9980. * @returns The parsed shadow generator
  9981. */
  9982. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9983. }
  9984. }
  9985. declare module "babylonjs/Lights/light" {
  9986. import { Nullable } from "babylonjs/types";
  9987. import { Scene } from "babylonjs/scene";
  9988. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9989. import { Node } from "babylonjs/node";
  9990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9991. import { Effect } from "babylonjs/Materials/effect";
  9992. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9993. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9994. /**
  9995. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9996. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9997. * 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.
  9998. */
  9999. export abstract class Light extends Node {
  10000. /**
  10001. * Falloff Default: light is falling off following the material specification:
  10002. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10003. */
  10004. static readonly FALLOFF_DEFAULT: number;
  10005. /**
  10006. * Falloff Physical: light is falling off following the inverse squared distance law.
  10007. */
  10008. static readonly FALLOFF_PHYSICAL: number;
  10009. /**
  10010. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10011. * to enhance interoperability with other engines.
  10012. */
  10013. static readonly FALLOFF_GLTF: number;
  10014. /**
  10015. * Falloff Standard: light is falling off like in the standard material
  10016. * to enhance interoperability with other materials.
  10017. */
  10018. static readonly FALLOFF_STANDARD: number;
  10019. /**
  10020. * If every light affecting the material is in this lightmapMode,
  10021. * material.lightmapTexture adds or multiplies
  10022. * (depends on material.useLightmapAsShadowmap)
  10023. * after every other light calculations.
  10024. */
  10025. static readonly LIGHTMAP_DEFAULT: number;
  10026. /**
  10027. * material.lightmapTexture as only diffuse lighting from this light
  10028. * adds only specular lighting from this light
  10029. * adds dynamic shadows
  10030. */
  10031. static readonly LIGHTMAP_SPECULAR: number;
  10032. /**
  10033. * material.lightmapTexture as only lighting
  10034. * no light calculation from this light
  10035. * only adds dynamic shadows from this light
  10036. */
  10037. static readonly LIGHTMAP_SHADOWSONLY: number;
  10038. /**
  10039. * Each light type uses the default quantity according to its type:
  10040. * point/spot lights use luminous intensity
  10041. * directional lights use illuminance
  10042. */
  10043. static readonly INTENSITYMODE_AUTOMATIC: number;
  10044. /**
  10045. * lumen (lm)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10048. /**
  10049. * candela (lm/sr)
  10050. */
  10051. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10052. /**
  10053. * lux (lm/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10056. /**
  10057. * nit (cd/m^2)
  10058. */
  10059. static readonly INTENSITYMODE_LUMINANCE: number;
  10060. /**
  10061. * Light type const id of the point light.
  10062. */
  10063. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10064. /**
  10065. * Light type const id of the directional light.
  10066. */
  10067. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10068. /**
  10069. * Light type const id of the spot light.
  10070. */
  10071. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10072. /**
  10073. * Light type const id of the hemispheric light.
  10074. */
  10075. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10076. /**
  10077. * Diffuse gives the basic color to an object.
  10078. */
  10079. diffuse: Color3;
  10080. /**
  10081. * Specular produces a highlight color on an object.
  10082. * Note: This is note affecting PBR materials.
  10083. */
  10084. specular: Color3;
  10085. /**
  10086. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10087. * falling off base on range or angle.
  10088. * This can be set to any values in Light.FALLOFF_x.
  10089. *
  10090. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10091. * other types of materials.
  10092. */
  10093. falloffType: number;
  10094. /**
  10095. * Strength of the light.
  10096. * Note: By default it is define in the framework own unit.
  10097. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10098. */
  10099. intensity: number;
  10100. private _range;
  10101. protected _inverseSquaredRange: number;
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. /**
  10107. * Defines how far from the source the light is impacting in scene units.
  10108. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10109. */
  10110. range: number;
  10111. /**
  10112. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10113. * of light.
  10114. */
  10115. private _photometricScale;
  10116. private _intensityMode;
  10117. /**
  10118. * Gets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. /**
  10122. * Sets the photometric scale used to interpret the intensity.
  10123. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10124. */
  10125. intensityMode: number;
  10126. private _radius;
  10127. /**
  10128. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10129. */
  10130. /**
  10131. * sets the light radius used by PBR Materials to simulate soft area lights.
  10132. */
  10133. radius: number;
  10134. private _renderPriority;
  10135. /**
  10136. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10137. * exceeding the number allowed of the materials.
  10138. */
  10139. renderPriority: number;
  10140. private _shadowEnabled;
  10141. /**
  10142. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. /**
  10146. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10147. * the current shadow generator.
  10148. */
  10149. shadowEnabled: boolean;
  10150. private _includedOnlyMeshes;
  10151. /**
  10152. * Gets the only meshes impacted by this light.
  10153. */
  10154. /**
  10155. * Sets the only meshes impacted by this light.
  10156. */
  10157. includedOnlyMeshes: AbstractMesh[];
  10158. private _excludedMeshes;
  10159. /**
  10160. * Gets the meshes not impacted by this light.
  10161. */
  10162. /**
  10163. * Sets the meshes not impacted by this light.
  10164. */
  10165. excludedMeshes: AbstractMesh[];
  10166. private _excludeWithLayerMask;
  10167. /**
  10168. * Gets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. /**
  10172. * Sets the layer id use to find what meshes are not impacted by the light.
  10173. * Inactive if 0
  10174. */
  10175. excludeWithLayerMask: number;
  10176. private _includeOnlyWithLayerMask;
  10177. /**
  10178. * Gets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. /**
  10182. * Sets the layer id use to find what meshes are impacted by the light.
  10183. * Inactive if 0
  10184. */
  10185. includeOnlyWithLayerMask: number;
  10186. private _lightmapMode;
  10187. /**
  10188. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10189. */
  10190. /**
  10191. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10192. */
  10193. lightmapMode: number;
  10194. /**
  10195. * Shadow generator associted to the light.
  10196. * @hidden Internal use only.
  10197. */
  10198. _shadowGenerator: Nullable<IShadowGenerator>;
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _excludedMeshesIds: string[];
  10203. /**
  10204. * @hidden Internal use only.
  10205. */
  10206. _includedOnlyMeshesIds: string[];
  10207. /**
  10208. * The current light unifom buffer.
  10209. * @hidden Internal use only.
  10210. */
  10211. _uniformBuffer: UniformBuffer;
  10212. /**
  10213. * Creates a Light object in the scene.
  10214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10215. * @param name The firendly name of the light
  10216. * @param scene The scene the light belongs too
  10217. */
  10218. constructor(name: string, scene: Scene);
  10219. protected abstract _buildUniformLayout(): void;
  10220. /**
  10221. * Sets the passed Effect "effect" with the Light information.
  10222. * @param effect The effect to update
  10223. * @param lightIndex The index of the light in the effect to update
  10224. * @returns The light
  10225. */
  10226. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10227. /**
  10228. * Returns the string "Light".
  10229. * @returns the class name
  10230. */
  10231. getClassName(): string;
  10232. /** @hidden */
  10233. readonly _isLight: boolean;
  10234. /**
  10235. * Converts the light information to a readable string for debug purpose.
  10236. * @param fullDetails Supports for multiple levels of logging within scene loading
  10237. * @returns the human readable light info
  10238. */
  10239. toString(fullDetails?: boolean): string;
  10240. /** @hidden */
  10241. protected _syncParentEnabledState(): void;
  10242. /**
  10243. * Set the enabled state of this node.
  10244. * @param value - the new enabled state
  10245. */
  10246. setEnabled(value: boolean): void;
  10247. /**
  10248. * Returns the Light associated shadow generator if any.
  10249. * @return the associated shadow generator.
  10250. */
  10251. getShadowGenerator(): Nullable<IShadowGenerator>;
  10252. /**
  10253. * Returns a Vector3, the absolute light position in the World.
  10254. * @returns the world space position of the light
  10255. */
  10256. getAbsolutePosition(): Vector3;
  10257. /**
  10258. * Specifies if the light will affect the passed mesh.
  10259. * @param mesh The mesh to test against the light
  10260. * @return true the mesh is affected otherwise, false.
  10261. */
  10262. canAffectMesh(mesh: AbstractMesh): boolean;
  10263. /**
  10264. * Sort function to order lights for rendering.
  10265. * @param a First Light object to compare to second.
  10266. * @param b Second Light object to compare first.
  10267. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10268. */
  10269. static CompareLightsPriority(a: Light, b: Light): number;
  10270. /**
  10271. * Releases resources associated with this node.
  10272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10274. */
  10275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10276. /**
  10277. * Returns the light type ID (integer).
  10278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10279. */
  10280. getTypeID(): number;
  10281. /**
  10282. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10283. * @returns the scaled intensity in intensity mode unit
  10284. */
  10285. getScaledIntensity(): number;
  10286. /**
  10287. * Returns a new Light object, named "name", from the current one.
  10288. * @param name The name of the cloned light
  10289. * @returns the new created light
  10290. */
  10291. clone(name: string): Nullable<Light>;
  10292. /**
  10293. * Serializes the current light into a Serialization object.
  10294. * @returns the serialized object.
  10295. */
  10296. serialize(): any;
  10297. /**
  10298. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10299. * This new light is named "name" and added to the passed scene.
  10300. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10301. * @param name The friendly name of the light
  10302. * @param scene The scene the new light will belong to
  10303. * @returns the constructor function
  10304. */
  10305. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10306. /**
  10307. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10308. * @param parsedLight The JSON representation of the light
  10309. * @param scene The scene to create the parsed light in
  10310. * @returns the created light after parsing
  10311. */
  10312. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10313. private _hookArrayForExcluded;
  10314. private _hookArrayForIncludedOnly;
  10315. private _resyncMeshes;
  10316. /**
  10317. * Forces the meshes to update their light related information in their rendering used effects
  10318. * @hidden Internal Use Only
  10319. */
  10320. _markMeshesAsLightDirty(): void;
  10321. /**
  10322. * Recomputes the cached photometric scale if needed.
  10323. */
  10324. private _computePhotometricScale;
  10325. /**
  10326. * Returns the Photometric Scale according to the light type and intensity mode.
  10327. */
  10328. private _getPhotometricScale;
  10329. /**
  10330. * Reorder the light in the scene according to their defined priority.
  10331. * @hidden Internal Use Only
  10332. */
  10333. _reorderLightsInScene(): void;
  10334. /**
  10335. * Prepares the list of defines specific to the light type.
  10336. * @param defines the list of defines
  10337. * @param lightIndex defines the index of the light for the effect
  10338. */
  10339. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10340. }
  10341. }
  10342. declare module "babylonjs/Actions/action" {
  10343. import { Observable } from "babylonjs/Misc/observable";
  10344. import { Condition } from "babylonjs/Actions/condition";
  10345. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10346. import { ActionManager } from "babylonjs/Actions/actionManager";
  10347. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10348. /**
  10349. * Interface used to define Action
  10350. */
  10351. export interface IAction {
  10352. /**
  10353. * Trigger for the action
  10354. */
  10355. trigger: number;
  10356. /** Options of the trigger */
  10357. triggerOptions: any;
  10358. /**
  10359. * Gets the trigger parameters
  10360. * @returns the trigger parameters
  10361. */
  10362. getTriggerParameter(): any;
  10363. /**
  10364. * Internal only - executes current action event
  10365. * @hidden
  10366. */
  10367. _executeCurrent(evt?: ActionEvent): void;
  10368. /**
  10369. * Serialize placeholder for child classes
  10370. * @param parent of child
  10371. * @returns the serialized object
  10372. */
  10373. serialize(parent: any): any;
  10374. /**
  10375. * Internal only
  10376. * @hidden
  10377. */
  10378. _prepare(): void;
  10379. /**
  10380. * Internal only - manager for action
  10381. * @hidden
  10382. */
  10383. _actionManager: AbstractActionManager;
  10384. }
  10385. /**
  10386. * The action to be carried out following a trigger
  10387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10388. */
  10389. export class Action implements IAction {
  10390. /** the trigger, with or without parameters, for the action */
  10391. triggerOptions: any;
  10392. /**
  10393. * Trigger for the action
  10394. */
  10395. trigger: number;
  10396. /**
  10397. * Internal only - manager for action
  10398. * @hidden
  10399. */
  10400. _actionManager: ActionManager;
  10401. private _nextActiveAction;
  10402. private _child;
  10403. private _condition?;
  10404. private _triggerParameter;
  10405. /**
  10406. * An event triggered prior to action being executed.
  10407. */
  10408. onBeforeExecuteObservable: Observable<Action>;
  10409. /**
  10410. * Creates a new Action
  10411. * @param triggerOptions the trigger, with or without parameters, for the action
  10412. * @param condition an optional determinant of action
  10413. */
  10414. constructor(
  10415. /** the trigger, with or without parameters, for the action */
  10416. triggerOptions: any, condition?: Condition);
  10417. /**
  10418. * Internal only
  10419. * @hidden
  10420. */
  10421. _prepare(): void;
  10422. /**
  10423. * Gets the trigger parameters
  10424. * @returns the trigger parameters
  10425. */
  10426. getTriggerParameter(): any;
  10427. /**
  10428. * Internal only - executes current action event
  10429. * @hidden
  10430. */
  10431. _executeCurrent(evt?: ActionEvent): void;
  10432. /**
  10433. * Execute placeholder for child classes
  10434. * @param evt optional action event
  10435. */
  10436. execute(evt?: ActionEvent): void;
  10437. /**
  10438. * Skips to next active action
  10439. */
  10440. skipToNextActiveAction(): void;
  10441. /**
  10442. * Adds action to chain of actions, may be a DoNothingAction
  10443. * @param action defines the next action to execute
  10444. * @returns The action passed in
  10445. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10446. */
  10447. then(action: Action): Action;
  10448. /**
  10449. * Internal only
  10450. * @hidden
  10451. */
  10452. _getProperty(propertyPath: string): string;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */
  10457. _getEffectiveTarget(target: any, propertyPath: string): any;
  10458. /**
  10459. * Serialize placeholder for child classes
  10460. * @param parent of child
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. /**
  10465. * Internal only called by serialize
  10466. * @hidden
  10467. */
  10468. protected _serialize(serializedAction: any, parent?: any): any;
  10469. /**
  10470. * Internal only
  10471. * @hidden
  10472. */
  10473. static _SerializeValueAsString: (value: any) => string;
  10474. /**
  10475. * Internal only
  10476. * @hidden
  10477. */
  10478. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10479. name: string;
  10480. targetType: string;
  10481. value: string;
  10482. };
  10483. }
  10484. }
  10485. declare module "babylonjs/Actions/condition" {
  10486. import { ActionManager } from "babylonjs/Actions/actionManager";
  10487. /**
  10488. * A Condition applied to an Action
  10489. */
  10490. export class Condition {
  10491. /**
  10492. * Internal only - manager for action
  10493. * @hidden
  10494. */
  10495. _actionManager: ActionManager;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _evaluationId: number;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. _currentResult: boolean;
  10506. /**
  10507. * Creates a new Condition
  10508. * @param actionManager the manager of the action the condition is applied to
  10509. */
  10510. constructor(actionManager: ActionManager);
  10511. /**
  10512. * Check if the current condition is valid
  10513. * @returns a boolean
  10514. */
  10515. isValid(): boolean;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. _getProperty(propertyPath: string): string;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. _getEffectiveTarget(target: any, propertyPath: string): any;
  10526. /**
  10527. * Serialize placeholder for child classes
  10528. * @returns the serialized object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */
  10535. protected _serialize(serializedCondition: any): any;
  10536. }
  10537. /**
  10538. * Defines specific conditional operators as extensions of Condition
  10539. */
  10540. export class ValueCondition extends Condition {
  10541. /** path to specify the property of the target the conditional operator uses */
  10542. propertyPath: string;
  10543. /** the value compared by the conditional operator against the current value of the property */
  10544. value: any;
  10545. /** the conditional operator, default ValueCondition.IsEqual */
  10546. operator: number;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private static _IsEqual;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private static _IsDifferent;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private static _IsGreater;
  10562. /**
  10563. * Internal only
  10564. * @hidden
  10565. */
  10566. private static _IsLesser;
  10567. /**
  10568. * returns the number for IsEqual
  10569. */
  10570. static readonly IsEqual: number;
  10571. /**
  10572. * Returns the number for IsDifferent
  10573. */
  10574. static readonly IsDifferent: number;
  10575. /**
  10576. * Returns the number for IsGreater
  10577. */
  10578. static readonly IsGreater: number;
  10579. /**
  10580. * Returns the number for IsLesser
  10581. */
  10582. static readonly IsLesser: number;
  10583. /**
  10584. * Internal only The action manager for the condition
  10585. * @hidden
  10586. */
  10587. _actionManager: ActionManager;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. private _target;
  10593. /**
  10594. * Internal only
  10595. * @hidden
  10596. */
  10597. private _effectiveTarget;
  10598. /**
  10599. * Internal only
  10600. * @hidden
  10601. */
  10602. private _property;
  10603. /**
  10604. * Creates a new ValueCondition
  10605. * @param actionManager manager for the action the condition applies to
  10606. * @param target for the action
  10607. * @param propertyPath path to specify the property of the target the conditional operator uses
  10608. * @param value the value compared by the conditional operator against the current value of the property
  10609. * @param operator the conditional operator, default ValueCondition.IsEqual
  10610. */
  10611. constructor(actionManager: ActionManager, target: any,
  10612. /** path to specify the property of the target the conditional operator uses */
  10613. propertyPath: string,
  10614. /** the value compared by the conditional operator against the current value of the property */
  10615. value: any,
  10616. /** the conditional operator, default ValueCondition.IsEqual */
  10617. operator?: number);
  10618. /**
  10619. * Compares the given value with the property value for the specified conditional operator
  10620. * @returns the result of the comparison
  10621. */
  10622. isValid(): boolean;
  10623. /**
  10624. * Serialize the ValueCondition into a JSON compatible object
  10625. * @returns serialization object
  10626. */
  10627. serialize(): any;
  10628. /**
  10629. * Gets the name of the conditional operator for the ValueCondition
  10630. * @param operator the conditional operator
  10631. * @returns the name
  10632. */
  10633. static GetOperatorName(operator: number): string;
  10634. }
  10635. /**
  10636. * Defines a predicate condition as an extension of Condition
  10637. */
  10638. export class PredicateCondition extends Condition {
  10639. /** defines the predicate function used to validate the condition */
  10640. predicate: () => boolean;
  10641. /**
  10642. * Internal only - manager for action
  10643. * @hidden
  10644. */
  10645. _actionManager: ActionManager;
  10646. /**
  10647. * Creates a new PredicateCondition
  10648. * @param actionManager manager for the action the condition applies to
  10649. * @param predicate defines the predicate function used to validate the condition
  10650. */
  10651. constructor(actionManager: ActionManager,
  10652. /** defines the predicate function used to validate the condition */
  10653. predicate: () => boolean);
  10654. /**
  10655. * @returns the validity of the predicate condition
  10656. */
  10657. isValid(): boolean;
  10658. }
  10659. /**
  10660. * Defines a state condition as an extension of Condition
  10661. */
  10662. export class StateCondition extends Condition {
  10663. /** Value to compare with target state */
  10664. value: string;
  10665. /**
  10666. * Internal only - manager for action
  10667. * @hidden
  10668. */
  10669. _actionManager: ActionManager;
  10670. /**
  10671. * Internal only
  10672. * @hidden
  10673. */
  10674. private _target;
  10675. /**
  10676. * Creates a new StateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param target of the condition
  10679. * @param value to compare with target state
  10680. */
  10681. constructor(actionManager: ActionManager, target: any,
  10682. /** Value to compare with target state */
  10683. value: string);
  10684. /**
  10685. * Gets a boolean indicating if the current condition is met
  10686. * @returns the validity of the state
  10687. */
  10688. isValid(): boolean;
  10689. /**
  10690. * Serialize the StateCondition into a JSON compatible object
  10691. * @returns serialization object
  10692. */
  10693. serialize(): any;
  10694. }
  10695. }
  10696. declare module "babylonjs/Actions/directActions" {
  10697. import { Action } from "babylonjs/Actions/action";
  10698. import { Condition } from "babylonjs/Actions/condition";
  10699. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10700. /**
  10701. * This defines an action responsible to toggle a boolean once triggered.
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10703. */
  10704. export class SwitchBooleanAction extends Action {
  10705. /**
  10706. * The path to the boolean property in the target object
  10707. */
  10708. propertyPath: string;
  10709. private _target;
  10710. private _effectiveTarget;
  10711. private _property;
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param target defines the object containing the boolean
  10716. * @param propertyPath defines the path to the boolean property in the target object
  10717. * @param condition defines the trigger related conditions
  10718. */
  10719. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10720. /** @hidden */
  10721. _prepare(): void;
  10722. /**
  10723. * Execute the action toggle the boolean value.
  10724. */
  10725. execute(): void;
  10726. /**
  10727. * Serializes the actions and its related information.
  10728. * @param parent defines the object to serialize in
  10729. * @returns the serialized object
  10730. */
  10731. serialize(parent: any): any;
  10732. }
  10733. /**
  10734. * This defines an action responsible to set a the state field of the target
  10735. * to a desired value once triggered.
  10736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10737. */
  10738. export class SetStateAction extends Action {
  10739. /**
  10740. * The value to store in the state field.
  10741. */
  10742. value: string;
  10743. private _target;
  10744. /**
  10745. * Instantiate the action
  10746. * @param triggerOptions defines the trigger options
  10747. * @param target defines the object containing the state property
  10748. * @param value defines the value to store in the state field
  10749. * @param condition defines the trigger related conditions
  10750. */
  10751. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10752. /**
  10753. * Execute the action and store the value on the target state property.
  10754. */
  10755. execute(): void;
  10756. /**
  10757. * Serializes the actions and its related information.
  10758. * @param parent defines the object to serialize in
  10759. * @returns the serialized object
  10760. */
  10761. serialize(parent: any): any;
  10762. }
  10763. /**
  10764. * This defines an action responsible to set a property of the target
  10765. * to a desired value once triggered.
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10767. */
  10768. export class SetValueAction extends Action {
  10769. /**
  10770. * The path of the property to set in the target.
  10771. */
  10772. propertyPath: string;
  10773. /**
  10774. * The value to set in the property
  10775. */
  10776. value: any;
  10777. private _target;
  10778. private _effectiveTarget;
  10779. private _property;
  10780. /**
  10781. * Instantiate the action
  10782. * @param triggerOptions defines the trigger options
  10783. * @param target defines the object containing the property
  10784. * @param propertyPath defines the path of the property to set in the target
  10785. * @param value defines the value to set in the property
  10786. * @param condition defines the trigger related conditions
  10787. */
  10788. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10789. /** @hidden */
  10790. _prepare(): void;
  10791. /**
  10792. * Execute the action and set the targetted property to the desired value.
  10793. */
  10794. execute(): void;
  10795. /**
  10796. * Serializes the actions and its related information.
  10797. * @param parent defines the object to serialize in
  10798. * @returns the serialized object
  10799. */
  10800. serialize(parent: any): any;
  10801. }
  10802. /**
  10803. * This defines an action responsible to increment the target value
  10804. * to a desired value once triggered.
  10805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10806. */
  10807. export class IncrementValueAction extends Action {
  10808. /**
  10809. * The path of the property to increment in the target.
  10810. */
  10811. propertyPath: string;
  10812. /**
  10813. * The value we should increment the property by.
  10814. */
  10815. value: any;
  10816. private _target;
  10817. private _effectiveTarget;
  10818. private _property;
  10819. /**
  10820. * Instantiate the action
  10821. * @param triggerOptions defines the trigger options
  10822. * @param target defines the object containing the property
  10823. * @param propertyPath defines the path of the property to increment in the target
  10824. * @param value defines the value value we should increment the property by
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10828. /** @hidden */
  10829. _prepare(): void;
  10830. /**
  10831. * Execute the action and increment the target of the value amount.
  10832. */
  10833. execute(): void;
  10834. /**
  10835. * Serializes the actions and its related information.
  10836. * @param parent defines the object to serialize in
  10837. * @returns the serialized object
  10838. */
  10839. serialize(parent: any): any;
  10840. }
  10841. /**
  10842. * This defines an action responsible to start an animation once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class PlayAnimationAction extends Action {
  10846. /**
  10847. * Where the animation should start (animation frame)
  10848. */
  10849. from: number;
  10850. /**
  10851. * Where the animation should stop (animation frame)
  10852. */
  10853. to: number;
  10854. /**
  10855. * Define if the animation should loop or stop after the first play.
  10856. */
  10857. loop?: boolean;
  10858. private _target;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the target animation or animation name
  10863. * @param from defines from where the animation should start (animation frame)
  10864. * @param end defines where the animation should stop (animation frame)
  10865. * @param loop defines if the animation should loop or stop after the first play
  10866. * @param condition defines the trigger related conditions
  10867. */
  10868. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10869. /** @hidden */
  10870. _prepare(): void;
  10871. /**
  10872. * Execute the action and play the animation.
  10873. */
  10874. execute(): void;
  10875. /**
  10876. * Serializes the actions and its related information.
  10877. * @param parent defines the object to serialize in
  10878. * @returns the serialized object
  10879. */
  10880. serialize(parent: any): any;
  10881. }
  10882. /**
  10883. * This defines an action responsible to stop an animation once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class StopAnimationAction extends Action {
  10887. private _target;
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param target defines the target animation or animation name
  10892. * @param condition defines the trigger related conditions
  10893. */
  10894. constructor(triggerOptions: any, target: any, condition?: Condition);
  10895. /** @hidden */
  10896. _prepare(): void;
  10897. /**
  10898. * Execute the action and stop the animation.
  10899. */
  10900. execute(): void;
  10901. /**
  10902. * Serializes the actions and its related information.
  10903. * @param parent defines the object to serialize in
  10904. * @returns the serialized object
  10905. */
  10906. serialize(parent: any): any;
  10907. }
  10908. /**
  10909. * This defines an action responsible that does nothing once triggered.
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10911. */
  10912. export class DoNothingAction extends Action {
  10913. /**
  10914. * Instantiate the action
  10915. * @param triggerOptions defines the trigger options
  10916. * @param condition defines the trigger related conditions
  10917. */
  10918. constructor(triggerOptions?: any, condition?: Condition);
  10919. /**
  10920. * Execute the action and do nothing.
  10921. */
  10922. execute(): void;
  10923. /**
  10924. * Serializes the actions and its related information.
  10925. * @param parent defines the object to serialize in
  10926. * @returns the serialized object
  10927. */
  10928. serialize(parent: any): any;
  10929. }
  10930. /**
  10931. * This defines an action responsible to trigger several actions once triggered.
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10933. */
  10934. export class CombineAction extends Action {
  10935. /**
  10936. * The list of aggregated animations to run.
  10937. */
  10938. children: Action[];
  10939. /**
  10940. * Instantiate the action
  10941. * @param triggerOptions defines the trigger options
  10942. * @param children defines the list of aggregated animations to run
  10943. * @param condition defines the trigger related conditions
  10944. */
  10945. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10946. /** @hidden */
  10947. _prepare(): void;
  10948. /**
  10949. * Execute the action and executes all the aggregated actions.
  10950. */
  10951. execute(evt: ActionEvent): void;
  10952. /**
  10953. * Serializes the actions and its related information.
  10954. * @param parent defines the object to serialize in
  10955. * @returns the serialized object
  10956. */
  10957. serialize(parent: any): any;
  10958. }
  10959. /**
  10960. * This defines an action responsible to run code (external event) once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class ExecuteCodeAction extends Action {
  10964. /**
  10965. * The callback function to run.
  10966. */
  10967. func: (evt: ActionEvent) => void;
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param func defines the callback function to run
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10975. /**
  10976. * Execute the action and run the attached code.
  10977. */
  10978. execute(evt: ActionEvent): void;
  10979. }
  10980. /**
  10981. * This defines an action responsible to set the parent property of the target once triggered.
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10983. */
  10984. export class SetParentAction extends Action {
  10985. private _parent;
  10986. private _target;
  10987. /**
  10988. * Instantiate the action
  10989. * @param triggerOptions defines the trigger options
  10990. * @param target defines the target containing the parent property
  10991. * @param parent defines from where the animation should start (animation frame)
  10992. * @param condition defines the trigger related conditions
  10993. */
  10994. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10995. /** @hidden */
  10996. _prepare(): void;
  10997. /**
  10998. * Execute the action and set the parent property.
  10999. */
  11000. execute(): void;
  11001. /**
  11002. * Serializes the actions and its related information.
  11003. * @param parent defines the object to serialize in
  11004. * @returns the serialized object
  11005. */
  11006. serialize(parent: any): any;
  11007. }
  11008. }
  11009. declare module "babylonjs/Actions/actionManager" {
  11010. import { Nullable } from "babylonjs/types";
  11011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11012. import { Scene } from "babylonjs/scene";
  11013. import { IAction } from "babylonjs/Actions/action";
  11014. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11015. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11016. /**
  11017. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11018. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11020. */
  11021. export class ActionManager extends AbstractActionManager {
  11022. /**
  11023. * Nothing
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly NothingTrigger: number;
  11027. /**
  11028. * On pick
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnPickTrigger: number;
  11032. /**
  11033. * On left pick
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnLeftPickTrigger: number;
  11037. /**
  11038. * On right pick
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnRightPickTrigger: number;
  11042. /**
  11043. * On center pick
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnCenterPickTrigger: number;
  11047. /**
  11048. * On pick down
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11050. */
  11051. static readonly OnPickDownTrigger: number;
  11052. /**
  11053. * On double pick
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnDoublePickTrigger: number;
  11057. /**
  11058. * On pick up
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnPickUpTrigger: number;
  11062. /**
  11063. * On pick out.
  11064. * This trigger will only be raised if you also declared a OnPickDown
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnPickOutTrigger: number;
  11068. /**
  11069. * On long press
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnLongPressTrigger: number;
  11073. /**
  11074. * On pointer over
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnPointerOverTrigger: number;
  11078. /**
  11079. * On pointer out
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnPointerOutTrigger: number;
  11083. /**
  11084. * On every frame
  11085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11086. */
  11087. static readonly OnEveryFrameTrigger: number;
  11088. /**
  11089. * On intersection enter
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11091. */
  11092. static readonly OnIntersectionEnterTrigger: number;
  11093. /**
  11094. * On intersection exit
  11095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11096. */
  11097. static readonly OnIntersectionExitTrigger: number;
  11098. /**
  11099. * On key down
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11101. */
  11102. static readonly OnKeyDownTrigger: number;
  11103. /**
  11104. * On key up
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11106. */
  11107. static readonly OnKeyUpTrigger: number;
  11108. private _scene;
  11109. /**
  11110. * Creates a new action manager
  11111. * @param scene defines the hosting scene
  11112. */
  11113. constructor(scene: Scene);
  11114. /**
  11115. * Releases all associated resources
  11116. */
  11117. dispose(): void;
  11118. /**
  11119. * Gets hosting scene
  11120. * @returns the hosting scene
  11121. */
  11122. getScene(): Scene;
  11123. /**
  11124. * Does this action manager handles actions of any of the given triggers
  11125. * @param triggers defines the triggers to be tested
  11126. * @return a boolean indicating whether one (or more) of the triggers is handled
  11127. */
  11128. hasSpecificTriggers(triggers: number[]): boolean;
  11129. /**
  11130. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11131. * speed.
  11132. * @param triggerA defines the trigger to be tested
  11133. * @param triggerB defines the trigger to be tested
  11134. * @return a boolean indicating whether one (or more) of the triggers is handled
  11135. */
  11136. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11137. /**
  11138. * Does this action manager handles actions of a given trigger
  11139. * @param trigger defines the trigger to be tested
  11140. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11141. * @return whether the trigger is handled
  11142. */
  11143. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11144. /**
  11145. * Does this action manager has pointer triggers
  11146. */
  11147. readonly hasPointerTriggers: boolean;
  11148. /**
  11149. * Does this action manager has pick triggers
  11150. */
  11151. readonly hasPickTriggers: boolean;
  11152. /**
  11153. * Registers an action to this action manager
  11154. * @param action defines the action to be registered
  11155. * @return the action amended (prepared) after registration
  11156. */
  11157. registerAction(action: IAction): Nullable<IAction>;
  11158. /**
  11159. * Unregisters an action to this action manager
  11160. * @param action defines the action to be unregistered
  11161. * @return a boolean indicating whether the action has been unregistered
  11162. */
  11163. unregisterAction(action: IAction): Boolean;
  11164. /**
  11165. * Process a specific trigger
  11166. * @param trigger defines the trigger to process
  11167. * @param evt defines the event details to be processed
  11168. */
  11169. processTrigger(trigger: number, evt?: IActionEvent): void;
  11170. /** @hidden */
  11171. _getEffectiveTarget(target: any, propertyPath: string): any;
  11172. /** @hidden */
  11173. _getProperty(propertyPath: string): string;
  11174. /**
  11175. * Serialize this manager to a JSON object
  11176. * @param name defines the property name to store this manager
  11177. * @returns a JSON representation of this manager
  11178. */
  11179. serialize(name: string): any;
  11180. /**
  11181. * Creates a new ActionManager from a JSON data
  11182. * @param parsedActions defines the JSON data to read from
  11183. * @param object defines the hosting mesh
  11184. * @param scene defines the hosting scene
  11185. */
  11186. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11187. /**
  11188. * Get a trigger name by index
  11189. * @param trigger defines the trigger index
  11190. * @returns a trigger name
  11191. */
  11192. static GetTriggerName(trigger: number): string;
  11193. }
  11194. }
  11195. declare module "babylonjs/Culling/ray" {
  11196. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11197. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11199. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11200. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11201. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11202. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11203. /**
  11204. * Class representing a ray with position and direction
  11205. */
  11206. export class Ray {
  11207. /** origin point */
  11208. origin: Vector3;
  11209. /** direction */
  11210. direction: Vector3;
  11211. /** length of the ray */
  11212. length: number;
  11213. private static readonly TmpVector3;
  11214. private _tmpRay;
  11215. /**
  11216. * Creates a new ray
  11217. * @param origin origin point
  11218. * @param direction direction
  11219. * @param length length of the ray
  11220. */
  11221. constructor(
  11222. /** origin point */
  11223. origin: Vector3,
  11224. /** direction */
  11225. direction: Vector3,
  11226. /** length of the ray */
  11227. length?: number);
  11228. /**
  11229. * Checks if the ray intersects a box
  11230. * @param minimum bound of the box
  11231. * @param maximum bound of the box
  11232. * @param intersectionTreshold extra extend to be added to the box in all direction
  11233. * @returns if the box was hit
  11234. */
  11235. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11236. /**
  11237. * Checks if the ray intersects a box
  11238. * @param box the bounding box to check
  11239. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * If the ray hits a sphere
  11245. * @param sphere the bounding sphere to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11247. * @returns true if it hits the sphere
  11248. */
  11249. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a triange
  11252. * @param vertex0 triangle vertex
  11253. * @param vertex1 triangle vertex
  11254. * @param vertex2 triangle vertex
  11255. * @returns intersection information if hit
  11256. */
  11257. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11258. /**
  11259. * Checks if ray intersects a plane
  11260. * @param plane the plane to check
  11261. * @returns the distance away it was hit
  11262. */
  11263. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11264. /**
  11265. * Checks if ray intersects a mesh
  11266. * @param mesh the mesh to check
  11267. * @param fastCheck if only the bounding box should checked
  11268. * @returns picking info of the intersecton
  11269. */
  11270. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param meshes the meshes to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @param results array to store result in
  11276. * @returns Array of picking infos
  11277. */
  11278. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11279. private _comparePickingInfo;
  11280. private static smallnum;
  11281. private static rayl;
  11282. /**
  11283. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11284. * @param sega the first point of the segment to test the intersection against
  11285. * @param segb the second point of the segment to test the intersection against
  11286. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11287. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11288. */
  11289. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11290. /**
  11291. * Update the ray from viewport position
  11292. * @param x position
  11293. * @param y y position
  11294. * @param viewportWidth viewport width
  11295. * @param viewportHeight viewport height
  11296. * @param world world matrix
  11297. * @param view view matrix
  11298. * @param projection projection matrix
  11299. * @returns this ray updated
  11300. */
  11301. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Creates a ray with origin and direction of 0,0,0
  11304. * @returns the new ray
  11305. */
  11306. static Zero(): Ray;
  11307. /**
  11308. * Creates a new ray from screen space and viewport
  11309. * @param x position
  11310. * @param y y position
  11311. * @param viewportWidth viewport width
  11312. * @param viewportHeight viewport height
  11313. * @param world world matrix
  11314. * @param view view matrix
  11315. * @param projection projection matrix
  11316. * @returns new ray
  11317. */
  11318. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11319. /**
  11320. * 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
  11321. * transformed to the given world matrix.
  11322. * @param origin The origin point
  11323. * @param end The end point
  11324. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11325. * @returns the new ray
  11326. */
  11327. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11328. /**
  11329. * Transforms a ray by a matrix
  11330. * @param ray ray to transform
  11331. * @param matrix matrix to apply
  11332. * @returns the resulting new ray
  11333. */
  11334. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @param result ray to store result in
  11340. */
  11341. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11342. /**
  11343. * Unproject a ray from screen space to object space
  11344. * @param sourceX defines the screen space x coordinate to use
  11345. * @param sourceY defines the screen space y coordinate to use
  11346. * @param viewportWidth defines the current width of the viewport
  11347. * @param viewportHeight defines the current height of the viewport
  11348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11349. * @param view defines the view matrix to use
  11350. * @param projection defines the projection matrix to use
  11351. */
  11352. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11353. }
  11354. /**
  11355. * Type used to define predicate used to select faces when a mesh intersection is detected
  11356. */
  11357. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11358. module "babylonjs/scene" {
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. }
  11373. declare module "babylonjs/sceneComponent" {
  11374. import { Scene } from "babylonjs/scene";
  11375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11377. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11378. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11382. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11383. import { AbstractScene } from "babylonjs/abstractScene";
  11384. /**
  11385. * Groups all the scene component constants in one place to ease maintenance.
  11386. * @hidden
  11387. */
  11388. export class SceneComponentConstants {
  11389. static readonly NAME_EFFECTLAYER: string;
  11390. static readonly NAME_LAYER: string;
  11391. static readonly NAME_LENSFLARESYSTEM: string;
  11392. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11393. static readonly NAME_PARTICLESYSTEM: string;
  11394. static readonly NAME_GAMEPAD: string;
  11395. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11396. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11397. static readonly NAME_DEPTHRENDERER: string;
  11398. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11399. static readonly NAME_SPRITE: string;
  11400. static readonly NAME_OUTLINERENDERER: string;
  11401. static readonly NAME_PROCEDURALTEXTURE: string;
  11402. static readonly NAME_SHADOWGENERATOR: string;
  11403. static readonly NAME_OCTREE: string;
  11404. static readonly NAME_PHYSICSENGINE: string;
  11405. static readonly NAME_AUDIO: string;
  11406. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11407. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11408. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11409. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11411. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11412. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11413. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11414. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11415. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11416. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11417. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11418. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11419. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11420. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11421. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11422. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11423. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11424. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11425. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11426. static readonly STEP_AFTERRENDER_AUDIO: number;
  11427. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11428. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11431. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11432. static readonly STEP_POINTERMOVE_SPRITE: number;
  11433. static readonly STEP_POINTERDOWN_SPRITE: number;
  11434. static readonly STEP_POINTERUP_SPRITE: number;
  11435. }
  11436. /**
  11437. * This represents a scene component.
  11438. *
  11439. * This is used to decouple the dependency the scene is having on the different workloads like
  11440. * layers, post processes...
  11441. */
  11442. export interface ISceneComponent {
  11443. /**
  11444. * The name of the component. Each component must have a unique name.
  11445. */
  11446. name: string;
  11447. /**
  11448. * The scene the component belongs to.
  11449. */
  11450. scene: Scene;
  11451. /**
  11452. * Register the component to one instance of a scene.
  11453. */
  11454. register(): void;
  11455. /**
  11456. * Rebuilds the elements related to this component in case of
  11457. * context lost for instance.
  11458. */
  11459. rebuild(): void;
  11460. /**
  11461. * Disposes the component and the associated ressources.
  11462. */
  11463. dispose(): void;
  11464. }
  11465. /**
  11466. * This represents a SERIALIZABLE scene component.
  11467. *
  11468. * This extends Scene Component to add Serialization methods on top.
  11469. */
  11470. export interface ISceneSerializableComponent extends ISceneComponent {
  11471. /**
  11472. * Adds all the element from the container to the scene
  11473. * @param container the container holding the elements
  11474. */
  11475. addFromContainer(container: AbstractScene): void;
  11476. /**
  11477. * Removes all the elements in the container from the scene
  11478. * @param container contains the elements to remove
  11479. */
  11480. removeFromContainer(container: AbstractScene): void;
  11481. /**
  11482. * Serializes the component data to the specified json object
  11483. * @param serializationObject The object to serialize to
  11484. */
  11485. serialize(serializationObject: any): void;
  11486. }
  11487. /**
  11488. * Strong typing of a Mesh related stage step action
  11489. */
  11490. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11491. /**
  11492. * Strong typing of a Evaluate Sub Mesh related stage step action
  11493. */
  11494. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11495. /**
  11496. * Strong typing of a Active Mesh related stage step action
  11497. */
  11498. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11499. /**
  11500. * Strong typing of a Camera related stage step action
  11501. */
  11502. export type CameraStageAction = (camera: Camera) => void;
  11503. /**
  11504. * Strong typing of a Render Target related stage step action
  11505. */
  11506. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11507. /**
  11508. * Strong typing of a RenderingGroup related stage step action
  11509. */
  11510. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11511. /**
  11512. * Strong typing of a Mesh Render related stage step action
  11513. */
  11514. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11515. /**
  11516. * Strong typing of a simple stage step action
  11517. */
  11518. export type SimpleStageAction = () => void;
  11519. /**
  11520. * Strong typing of a render target action.
  11521. */
  11522. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11523. /**
  11524. * Strong typing of a pointer move action.
  11525. */
  11526. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11527. /**
  11528. * Strong typing of a pointer up/down action.
  11529. */
  11530. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11531. /**
  11532. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11533. * @hidden
  11534. */
  11535. export class Stage<T extends Function> extends Array<{
  11536. index: number;
  11537. component: ISceneComponent;
  11538. action: T;
  11539. }> {
  11540. /**
  11541. * Hide ctor from the rest of the world.
  11542. * @param items The items to add.
  11543. */
  11544. private constructor();
  11545. /**
  11546. * Creates a new Stage.
  11547. * @returns A new instance of a Stage
  11548. */
  11549. static Create<T extends Function>(): Stage<T>;
  11550. /**
  11551. * Registers a step in an ordered way in the targeted stage.
  11552. * @param index Defines the position to register the step in
  11553. * @param component Defines the component attached to the step
  11554. * @param action Defines the action to launch during the step
  11555. */
  11556. registerStep(index: number, component: ISceneComponent, action: T): void;
  11557. /**
  11558. * Clears all the steps from the stage.
  11559. */
  11560. clear(): void;
  11561. }
  11562. }
  11563. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11564. import { Nullable } from "babylonjs/types";
  11565. import { Observable } from "babylonjs/Misc/observable";
  11566. import { Scene } from "babylonjs/scene";
  11567. import { Sprite } from "babylonjs/Sprites/sprite";
  11568. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11569. import { Ray } from "babylonjs/Culling/ray";
  11570. import { Camera } from "babylonjs/Cameras/camera";
  11571. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11572. import { ISceneComponent } from "babylonjs/sceneComponent";
  11573. module "babylonjs/scene" {
  11574. interface Scene {
  11575. /** @hidden */
  11576. _pointerOverSprite: Nullable<Sprite>;
  11577. /** @hidden */
  11578. _pickedDownSprite: Nullable<Sprite>;
  11579. /** @hidden */
  11580. _tempSpritePickingRay: Nullable<Ray>;
  11581. /**
  11582. * All of the sprite managers added to this scene
  11583. * @see http://doc.babylonjs.com/babylon101/sprites
  11584. */
  11585. spriteManagers: Array<ISpriteManager>;
  11586. /**
  11587. * An event triggered when sprites rendering is about to start
  11588. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11589. */
  11590. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11591. /**
  11592. * An event triggered when sprites rendering is done
  11593. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11594. */
  11595. onAfterSpritesRenderingObservable: Observable<Scene>;
  11596. /** @hidden */
  11597. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11598. /** Launch a ray to try to pick a sprite in the scene
  11599. * @param x position on screen
  11600. * @param y position on screen
  11601. * @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
  11602. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11603. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11604. * @returns a PickingInfo
  11605. */
  11606. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11607. /** Use the given ray to pick a sprite in the scene
  11608. * @param ray The ray (in world space) to use to pick meshes
  11609. * @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
  11610. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11611. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11612. * @returns a PickingInfo
  11613. */
  11614. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11615. /**
  11616. * Force the sprite under the pointer
  11617. * @param sprite defines the sprite to use
  11618. */
  11619. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11620. /**
  11621. * Gets the sprite under the pointer
  11622. * @returns a Sprite or null if no sprite is under the pointer
  11623. */
  11624. getPointerOverSprite(): Nullable<Sprite>;
  11625. }
  11626. }
  11627. /**
  11628. * Defines the sprite scene component responsible to manage sprites
  11629. * in a given scene.
  11630. */
  11631. export class SpriteSceneComponent implements ISceneComponent {
  11632. /**
  11633. * The component name helpfull to identify the component in the list of scene components.
  11634. */
  11635. readonly name: string;
  11636. /**
  11637. * The scene the component belongs to.
  11638. */
  11639. scene: Scene;
  11640. /** @hidden */
  11641. private _spritePredicate;
  11642. /**
  11643. * Creates a new instance of the component for the given scene
  11644. * @param scene Defines the scene to register the component in
  11645. */
  11646. constructor(scene: Scene);
  11647. /**
  11648. * Registers the component in a given scene
  11649. */
  11650. register(): void;
  11651. /**
  11652. * Rebuilds the elements related to this component in case of
  11653. * context lost for instance.
  11654. */
  11655. rebuild(): void;
  11656. /**
  11657. * Disposes the component and the associated ressources.
  11658. */
  11659. dispose(): void;
  11660. private _pickSpriteButKeepRay;
  11661. private _pointerMove;
  11662. private _pointerDown;
  11663. private _pointerUp;
  11664. }
  11665. }
  11666. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11667. /** @hidden */
  11668. export var fogFragmentDeclaration: {
  11669. name: string;
  11670. shader: string;
  11671. };
  11672. }
  11673. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11674. /** @hidden */
  11675. export var fogFragment: {
  11676. name: string;
  11677. shader: string;
  11678. };
  11679. }
  11680. declare module "babylonjs/Shaders/sprites.fragment" {
  11681. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11682. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11683. /** @hidden */
  11684. export var spritesPixelShader: {
  11685. name: string;
  11686. shader: string;
  11687. };
  11688. }
  11689. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11690. /** @hidden */
  11691. export var fogVertexDeclaration: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/sprites.vertex" {
  11697. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11698. /** @hidden */
  11699. export var spritesVertexShader: {
  11700. name: string;
  11701. shader: string;
  11702. };
  11703. }
  11704. declare module "babylonjs/Sprites/spriteManager" {
  11705. import { IDisposable, Scene } from "babylonjs/scene";
  11706. import { Nullable } from "babylonjs/types";
  11707. import { Observable } from "babylonjs/Misc/observable";
  11708. import { Sprite } from "babylonjs/Sprites/sprite";
  11709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11710. import { Camera } from "babylonjs/Cameras/camera";
  11711. import { Texture } from "babylonjs/Materials/Textures/texture";
  11712. import "babylonjs/Shaders/sprites.fragment";
  11713. import "babylonjs/Shaders/sprites.vertex";
  11714. import { Ray } from "babylonjs/Culling/ray";
  11715. /**
  11716. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11717. */
  11718. export interface ISpriteManager extends IDisposable {
  11719. /**
  11720. * Restricts the camera to viewing objects with the same layerMask.
  11721. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11722. */
  11723. layerMask: number;
  11724. /**
  11725. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11726. */
  11727. isPickable: boolean;
  11728. /**
  11729. * Specifies the rendering group id for this mesh (0 by default)
  11730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11731. */
  11732. renderingGroupId: number;
  11733. /**
  11734. * Defines the list of sprites managed by the manager.
  11735. */
  11736. sprites: Array<Sprite>;
  11737. /**
  11738. * Tests the intersection of a sprite with a specific ray.
  11739. * @param ray The ray we are sending to test the collision
  11740. * @param camera The camera space we are sending rays in
  11741. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11742. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11743. * @returns picking info or null.
  11744. */
  11745. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11746. /**
  11747. * Renders the list of sprites on screen.
  11748. */
  11749. render(): void;
  11750. }
  11751. /**
  11752. * Class used to manage multiple sprites on the same spritesheet
  11753. * @see http://doc.babylonjs.com/babylon101/sprites
  11754. */
  11755. export class SpriteManager implements ISpriteManager {
  11756. /** defines the manager's name */
  11757. name: string;
  11758. /** Gets the list of sprites */
  11759. sprites: Sprite[];
  11760. /** Gets or sets the rendering group id (0 by default) */
  11761. renderingGroupId: number;
  11762. /** Gets or sets camera layer mask */
  11763. layerMask: number;
  11764. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11765. fogEnabled: boolean;
  11766. /** Gets or sets a boolean indicating if the sprites are pickable */
  11767. isPickable: boolean;
  11768. /** Defines the default width of a cell in the spritesheet */
  11769. cellWidth: number;
  11770. /** Defines the default height of a cell in the spritesheet */
  11771. cellHeight: number;
  11772. /**
  11773. * An event triggered when the manager is disposed.
  11774. */
  11775. onDisposeObservable: Observable<SpriteManager>;
  11776. private _onDisposeObserver;
  11777. /**
  11778. * Callback called when the manager is disposed
  11779. */
  11780. onDispose: () => void;
  11781. private _capacity;
  11782. private _spriteTexture;
  11783. private _epsilon;
  11784. private _scene;
  11785. private _vertexData;
  11786. private _buffer;
  11787. private _vertexBuffers;
  11788. private _indexBuffer;
  11789. private _effectBase;
  11790. private _effectFog;
  11791. /**
  11792. * Gets or sets the spritesheet texture
  11793. */
  11794. texture: Texture;
  11795. /**
  11796. * Creates a new sprite manager
  11797. * @param name defines the manager's name
  11798. * @param imgUrl defines the sprite sheet url
  11799. * @param capacity defines the maximum allowed number of sprites
  11800. * @param cellSize defines the size of a sprite cell
  11801. * @param scene defines the hosting scene
  11802. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11803. * @param samplingMode defines the smapling mode to use with spritesheet
  11804. */
  11805. constructor(
  11806. /** defines the manager's name */
  11807. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11808. private _appendSpriteVertex;
  11809. /**
  11810. * Intersects the sprites with a ray
  11811. * @param ray defines the ray to intersect with
  11812. * @param camera defines the current active camera
  11813. * @param predicate defines a predicate used to select candidate sprites
  11814. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11815. * @returns null if no hit or a PickingInfo
  11816. */
  11817. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11818. /**
  11819. * Render all child sprites
  11820. */
  11821. render(): void;
  11822. /**
  11823. * Release associated resources
  11824. */
  11825. dispose(): void;
  11826. }
  11827. }
  11828. declare module "babylonjs/Sprites/sprite" {
  11829. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11830. import { Nullable } from "babylonjs/types";
  11831. import { ActionManager } from "babylonjs/Actions/actionManager";
  11832. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11833. /**
  11834. * Class used to represent a sprite
  11835. * @see http://doc.babylonjs.com/babylon101/sprites
  11836. */
  11837. export class Sprite {
  11838. /** defines the name */
  11839. name: string;
  11840. /** Gets or sets the current world position */
  11841. position: Vector3;
  11842. /** Gets or sets the main color */
  11843. color: Color4;
  11844. /** Gets or sets the width */
  11845. width: number;
  11846. /** Gets or sets the height */
  11847. height: number;
  11848. /** Gets or sets rotation angle */
  11849. angle: number;
  11850. /** Gets or sets the cell index in the sprite sheet */
  11851. cellIndex: number;
  11852. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11853. invertU: number;
  11854. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11855. invertV: number;
  11856. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11857. disposeWhenFinishedAnimating: boolean;
  11858. /** Gets the list of attached animations */
  11859. animations: Animation[];
  11860. /** Gets or sets a boolean indicating if the sprite can be picked */
  11861. isPickable: boolean;
  11862. /**
  11863. * Gets or sets the associated action manager
  11864. */
  11865. actionManager: Nullable<ActionManager>;
  11866. private _animationStarted;
  11867. private _loopAnimation;
  11868. private _fromIndex;
  11869. private _toIndex;
  11870. private _delay;
  11871. private _direction;
  11872. private _manager;
  11873. private _time;
  11874. private _onAnimationEnd;
  11875. /**
  11876. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11877. */
  11878. isVisible: boolean;
  11879. /**
  11880. * Gets or sets the sprite size
  11881. */
  11882. size: number;
  11883. /**
  11884. * Creates a new Sprite
  11885. * @param name defines the name
  11886. * @param manager defines the manager
  11887. */
  11888. constructor(
  11889. /** defines the name */
  11890. name: string, manager: ISpriteManager);
  11891. /**
  11892. * Starts an animation
  11893. * @param from defines the initial key
  11894. * @param to defines the end key
  11895. * @param loop defines if the animation must loop
  11896. * @param delay defines the start delay (in ms)
  11897. * @param onAnimationEnd defines a callback to call when animation ends
  11898. */
  11899. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11900. /** Stops current animation (if any) */
  11901. stopAnimation(): void;
  11902. /** @hidden */
  11903. _animate(deltaTime: number): void;
  11904. /** Release associated resources */
  11905. dispose(): void;
  11906. }
  11907. }
  11908. declare module "babylonjs/Collisions/pickingInfo" {
  11909. import { Nullable } from "babylonjs/types";
  11910. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11912. import { Sprite } from "babylonjs/Sprites/sprite";
  11913. import { Ray } from "babylonjs/Culling/ray";
  11914. /**
  11915. * Information about the result of picking within a scene
  11916. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11917. */
  11918. export class PickingInfo {
  11919. /** @hidden */
  11920. _pickingUnavailable: boolean;
  11921. /**
  11922. * If the pick collided with an object
  11923. */
  11924. hit: boolean;
  11925. /**
  11926. * Distance away where the pick collided
  11927. */
  11928. distance: number;
  11929. /**
  11930. * The location of pick collision
  11931. */
  11932. pickedPoint: Nullable<Vector3>;
  11933. /**
  11934. * The mesh corresponding the the pick collision
  11935. */
  11936. pickedMesh: Nullable<AbstractMesh>;
  11937. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11938. bu: number;
  11939. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11940. bv: number;
  11941. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11942. faceId: number;
  11943. /** Id of the the submesh that was picked */
  11944. subMeshId: number;
  11945. /** If a sprite was picked, this will be the sprite the pick collided with */
  11946. pickedSprite: Nullable<Sprite>;
  11947. /**
  11948. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11949. */
  11950. originMesh: Nullable<AbstractMesh>;
  11951. /**
  11952. * The ray that was used to perform the picking.
  11953. */
  11954. ray: Nullable<Ray>;
  11955. /**
  11956. * Gets the normal correspodning to the face the pick collided with
  11957. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11958. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11959. * @returns The normal correspodning to the face the pick collided with
  11960. */
  11961. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11962. /**
  11963. * Gets the texture coordinates of where the pick occured
  11964. * @returns the vector containing the coordnates of the texture
  11965. */
  11966. getTextureCoordinates(): Nullable<Vector2>;
  11967. }
  11968. }
  11969. declare module "babylonjs/Events/pointerEvents" {
  11970. import { Nullable } from "babylonjs/types";
  11971. import { Vector2 } from "babylonjs/Maths/math";
  11972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11973. import { Ray } from "babylonjs/Culling/ray";
  11974. /**
  11975. * Gather the list of pointer event types as constants.
  11976. */
  11977. export class PointerEventTypes {
  11978. /**
  11979. * 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.
  11980. */
  11981. static readonly POINTERDOWN: number;
  11982. /**
  11983. * The pointerup event is fired when a pointer is no longer active.
  11984. */
  11985. static readonly POINTERUP: number;
  11986. /**
  11987. * The pointermove event is fired when a pointer changes coordinates.
  11988. */
  11989. static readonly POINTERMOVE: number;
  11990. /**
  11991. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11992. */
  11993. static readonly POINTERWHEEL: number;
  11994. /**
  11995. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11996. */
  11997. static readonly POINTERPICK: number;
  11998. /**
  11999. * The pointertap event is fired when a the object has been touched and released without drag.
  12000. */
  12001. static readonly POINTERTAP: number;
  12002. /**
  12003. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12004. */
  12005. static readonly POINTERDOUBLETAP: number;
  12006. }
  12007. /**
  12008. * Base class of pointer info types.
  12009. */
  12010. export class PointerInfoBase {
  12011. /**
  12012. * Defines the type of event (PointerEventTypes)
  12013. */
  12014. type: number;
  12015. /**
  12016. * Defines the related dom event
  12017. */
  12018. event: PointerEvent | MouseWheelEvent;
  12019. /**
  12020. * Instantiates the base class of pointers info.
  12021. * @param type Defines the type of event (PointerEventTypes)
  12022. * @param event Defines the related dom event
  12023. */
  12024. constructor(
  12025. /**
  12026. * Defines the type of event (PointerEventTypes)
  12027. */
  12028. type: number,
  12029. /**
  12030. * Defines the related dom event
  12031. */
  12032. event: PointerEvent | MouseWheelEvent);
  12033. }
  12034. /**
  12035. * This class is used to store pointer related info for the onPrePointerObservable event.
  12036. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12037. */
  12038. export class PointerInfoPre extends PointerInfoBase {
  12039. /**
  12040. * Ray from a pointer if availible (eg. 6dof controller)
  12041. */
  12042. ray: Nullable<Ray>;
  12043. /**
  12044. * Defines the local position of the pointer on the canvas.
  12045. */
  12046. localPosition: Vector2;
  12047. /**
  12048. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12049. */
  12050. skipOnPointerObservable: boolean;
  12051. /**
  12052. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12053. * @param type Defines the type of event (PointerEventTypes)
  12054. * @param event Defines the related dom event
  12055. * @param localX Defines the local x coordinates of the pointer when the event occured
  12056. * @param localY Defines the local y coordinates of the pointer when the event occured
  12057. */
  12058. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12059. }
  12060. /**
  12061. * This type contains all the data related to a pointer event in Babylon.js.
  12062. * 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.
  12063. */
  12064. export class PointerInfo extends PointerInfoBase {
  12065. /**
  12066. * Defines the picking info associated to the info (if any)\
  12067. */
  12068. pickInfo: Nullable<PickingInfo>;
  12069. /**
  12070. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12071. * @param type Defines the type of event (PointerEventTypes)
  12072. * @param event Defines the related dom event
  12073. * @param pickInfo Defines the picking info associated to the info (if any)\
  12074. */
  12075. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12076. /**
  12077. * Defines the picking info associated to the info (if any)\
  12078. */
  12079. pickInfo: Nullable<PickingInfo>);
  12080. }
  12081. /**
  12082. * Data relating to a touch event on the screen.
  12083. */
  12084. export interface PointerTouch {
  12085. /**
  12086. * X coordinate of touch.
  12087. */
  12088. x: number;
  12089. /**
  12090. * Y coordinate of touch.
  12091. */
  12092. y: number;
  12093. /**
  12094. * Id of touch. Unique for each finger.
  12095. */
  12096. pointerId: number;
  12097. /**
  12098. * Event type passed from DOM.
  12099. */
  12100. type: any;
  12101. }
  12102. }
  12103. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12104. import { Nullable } from "babylonjs/types";
  12105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12106. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12107. /**
  12108. * Manage the mouse inputs to control the movement of a free camera.
  12109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12110. */
  12111. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12112. /**
  12113. * Define if touch is enabled in the mouse input
  12114. */
  12115. touchEnabled: boolean;
  12116. /**
  12117. * Defines the camera the input is attached to.
  12118. */
  12119. camera: FreeCamera;
  12120. /**
  12121. * Defines the buttons associated with the input to handle camera move.
  12122. */
  12123. buttons: number[];
  12124. /**
  12125. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12126. */
  12127. angularSensibility: number;
  12128. private _pointerInput;
  12129. private _onMouseMove;
  12130. private _observer;
  12131. private previousPosition;
  12132. /**
  12133. * Manage the mouse inputs to control the movement of a free camera.
  12134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12135. * @param touchEnabled Defines if touch is enabled or not
  12136. */
  12137. constructor(
  12138. /**
  12139. * Define if touch is enabled in the mouse input
  12140. */
  12141. touchEnabled?: boolean);
  12142. /**
  12143. * Attach the input controls to a specific dom element to get the input from.
  12144. * @param element Defines the element the controls should be listened from
  12145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12146. */
  12147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12148. /**
  12149. * Detach the current controls from the specified dom element.
  12150. * @param element Defines the element to stop listening the inputs from
  12151. */
  12152. detachControl(element: Nullable<HTMLElement>): void;
  12153. /**
  12154. * Gets the class name of the current intput.
  12155. * @returns the class name
  12156. */
  12157. getClassName(): string;
  12158. /**
  12159. * Get the friendly name associated with the input class.
  12160. * @returns the input friendly name
  12161. */
  12162. getSimpleName(): string;
  12163. }
  12164. }
  12165. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12166. import { Nullable } from "babylonjs/types";
  12167. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12169. /**
  12170. * Manage the touch inputs to control the movement of a free camera.
  12171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12172. */
  12173. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12174. /**
  12175. * Defines the camera the input is attached to.
  12176. */
  12177. camera: FreeCamera;
  12178. /**
  12179. * Defines the touch sensibility for rotation.
  12180. * The higher the faster.
  12181. */
  12182. touchAngularSensibility: number;
  12183. /**
  12184. * Defines the touch sensibility for move.
  12185. * The higher the faster.
  12186. */
  12187. touchMoveSensibility: number;
  12188. private _offsetX;
  12189. private _offsetY;
  12190. private _pointerPressed;
  12191. private _pointerInput;
  12192. private _observer;
  12193. private _onLostFocus;
  12194. /**
  12195. * Attach the input controls to a specific dom element to get the input from.
  12196. * @param element Defines the element the controls should be listened from
  12197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12198. */
  12199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12200. /**
  12201. * Detach the current controls from the specified dom element.
  12202. * @param element Defines the element to stop listening the inputs from
  12203. */
  12204. detachControl(element: Nullable<HTMLElement>): void;
  12205. /**
  12206. * Update the current camera state depending on the inputs that have been used this frame.
  12207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12208. */
  12209. checkInputs(): void;
  12210. /**
  12211. * Gets the class name of the current intput.
  12212. * @returns the class name
  12213. */
  12214. getClassName(): string;
  12215. /**
  12216. * Get the friendly name associated with the input class.
  12217. * @returns the input friendly name
  12218. */
  12219. getSimpleName(): string;
  12220. }
  12221. }
  12222. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12223. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12224. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12225. /**
  12226. * Default Inputs manager for the FreeCamera.
  12227. * It groups all the default supported inputs for ease of use.
  12228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12229. */
  12230. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12231. /**
  12232. * Instantiates a new FreeCameraInputsManager.
  12233. * @param camera Defines the camera the inputs belong to
  12234. */
  12235. constructor(camera: FreeCamera);
  12236. /**
  12237. * Add keyboard input support to the input manager.
  12238. * @returns the current input manager
  12239. */
  12240. addKeyboard(): FreeCameraInputsManager;
  12241. /**
  12242. * Add mouse input support to the input manager.
  12243. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12244. * @returns the current input manager
  12245. */
  12246. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12247. /**
  12248. * Add touch input support to the input manager.
  12249. * @returns the current input manager
  12250. */
  12251. addTouch(): FreeCameraInputsManager;
  12252. }
  12253. }
  12254. declare module "babylonjs/Cameras/freeCamera" {
  12255. import { Vector3 } from "babylonjs/Maths/math";
  12256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12257. import { Scene } from "babylonjs/scene";
  12258. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12259. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12260. /**
  12261. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12262. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12263. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12264. */
  12265. export class FreeCamera extends TargetCamera {
  12266. /**
  12267. * Define the collision ellipsoid of the camera.
  12268. * This is helpful to simulate a camera body like the player body around the camera
  12269. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12270. */
  12271. ellipsoid: Vector3;
  12272. /**
  12273. * Define an offset for the position of the ellipsoid around the camera.
  12274. * This can be helpful to determine the center of the body near the gravity center of the body
  12275. * instead of its head.
  12276. */
  12277. ellipsoidOffset: Vector3;
  12278. /**
  12279. * Enable or disable collisions of the camera with the rest of the scene objects.
  12280. */
  12281. checkCollisions: boolean;
  12282. /**
  12283. * Enable or disable gravity on the camera.
  12284. */
  12285. applyGravity: boolean;
  12286. /**
  12287. * Define the input manager associated to the camera.
  12288. */
  12289. inputs: FreeCameraInputsManager;
  12290. /**
  12291. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. /**
  12295. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12296. * Higher values reduce sensitivity.
  12297. */
  12298. angularSensibility: number;
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12301. */
  12302. keysUp: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12305. */
  12306. keysDown: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12309. */
  12310. keysLeft: number[];
  12311. /**
  12312. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12313. */
  12314. keysRight: number[];
  12315. /**
  12316. * Event raised when the camera collide with a mesh in the scene.
  12317. */
  12318. onCollide: (collidedMesh: AbstractMesh) => void;
  12319. private _collider;
  12320. private _needMoveForGravity;
  12321. private _oldPosition;
  12322. private _diffPosition;
  12323. private _newPosition;
  12324. /** @hidden */
  12325. _localDirection: Vector3;
  12326. /** @hidden */
  12327. _transformedDirection: Vector3;
  12328. /**
  12329. * Instantiates a Free Camera.
  12330. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12331. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12332. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12333. * @param name Define the name of the camera in the scene
  12334. * @param position Define the start position of the camera in the scene
  12335. * @param scene Define the scene the camera belongs to
  12336. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12337. */
  12338. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12339. /**
  12340. * Attached controls to the current camera.
  12341. * @param element Defines the element the controls should be listened from
  12342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12343. */
  12344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12345. /**
  12346. * Detach the current controls from the camera.
  12347. * The camera will stop reacting to inputs.
  12348. * @param element Defines the element to stop listening the inputs from
  12349. */
  12350. detachControl(element: HTMLElement): void;
  12351. private _collisionMask;
  12352. /**
  12353. * Define a collision mask to limit the list of object the camera can collide with
  12354. */
  12355. collisionMask: number;
  12356. /** @hidden */
  12357. _collideWithWorld(displacement: Vector3): void;
  12358. private _onCollisionPositionChange;
  12359. /** @hidden */
  12360. _checkInputs(): void;
  12361. /** @hidden */
  12362. _decideIfNeedsToMove(): boolean;
  12363. /** @hidden */
  12364. _updatePosition(): void;
  12365. /**
  12366. * Destroy the camera and release the current resources hold by it.
  12367. */
  12368. dispose(): void;
  12369. /**
  12370. * Gets the current object class name.
  12371. * @return the class name
  12372. */
  12373. getClassName(): string;
  12374. }
  12375. }
  12376. declare module "babylonjs/Gamepads/gamepad" {
  12377. import { Observable } from "babylonjs/Misc/observable";
  12378. /**
  12379. * Represents a gamepad control stick position
  12380. */
  12381. export class StickValues {
  12382. /**
  12383. * The x component of the control stick
  12384. */
  12385. x: number;
  12386. /**
  12387. * The y component of the control stick
  12388. */
  12389. y: number;
  12390. /**
  12391. * Initializes the gamepad x and y control stick values
  12392. * @param x The x component of the gamepad control stick value
  12393. * @param y The y component of the gamepad control stick value
  12394. */
  12395. constructor(
  12396. /**
  12397. * The x component of the control stick
  12398. */
  12399. x: number,
  12400. /**
  12401. * The y component of the control stick
  12402. */
  12403. y: number);
  12404. }
  12405. /**
  12406. * An interface which manages callbacks for gamepad button changes
  12407. */
  12408. export interface GamepadButtonChanges {
  12409. /**
  12410. * Called when a gamepad has been changed
  12411. */
  12412. changed: boolean;
  12413. /**
  12414. * Called when a gamepad press event has been triggered
  12415. */
  12416. pressChanged: boolean;
  12417. /**
  12418. * Called when a touch event has been triggered
  12419. */
  12420. touchChanged: boolean;
  12421. /**
  12422. * Called when a value has changed
  12423. */
  12424. valueChanged: boolean;
  12425. }
  12426. /**
  12427. * Represents a gamepad
  12428. */
  12429. export class Gamepad {
  12430. /**
  12431. * The id of the gamepad
  12432. */
  12433. id: string;
  12434. /**
  12435. * The index of the gamepad
  12436. */
  12437. index: number;
  12438. /**
  12439. * The browser gamepad
  12440. */
  12441. browserGamepad: any;
  12442. /**
  12443. * Specifies what type of gamepad this represents
  12444. */
  12445. type: number;
  12446. private _leftStick;
  12447. private _rightStick;
  12448. /** @hidden */
  12449. _isConnected: boolean;
  12450. private _leftStickAxisX;
  12451. private _leftStickAxisY;
  12452. private _rightStickAxisX;
  12453. private _rightStickAxisY;
  12454. /**
  12455. * Triggered when the left control stick has been changed
  12456. */
  12457. private _onleftstickchanged;
  12458. /**
  12459. * Triggered when the right control stick has been changed
  12460. */
  12461. private _onrightstickchanged;
  12462. /**
  12463. * Represents a gamepad controller
  12464. */
  12465. static GAMEPAD: number;
  12466. /**
  12467. * Represents a generic controller
  12468. */
  12469. static GENERIC: number;
  12470. /**
  12471. * Represents an XBox controller
  12472. */
  12473. static XBOX: number;
  12474. /**
  12475. * Represents a pose-enabled controller
  12476. */
  12477. static POSE_ENABLED: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12586. import { Observable } from "babylonjs/Misc/observable";
  12587. import { Nullable } from "babylonjs/types";
  12588. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12591. import { Ray } from "babylonjs/Culling/ray";
  12592. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12593. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12594. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12595. /**
  12596. * Defines the types of pose enabled controllers that are supported
  12597. */
  12598. export enum PoseEnabledControllerType {
  12599. /**
  12600. * HTC Vive
  12601. */
  12602. VIVE = 0,
  12603. /**
  12604. * Oculus Rift
  12605. */
  12606. OCULUS = 1,
  12607. /**
  12608. * Windows mixed reality
  12609. */
  12610. WINDOWS = 2,
  12611. /**
  12612. * Samsung gear VR
  12613. */
  12614. GEAR_VR = 3,
  12615. /**
  12616. * Google Daydream
  12617. */
  12618. DAYDREAM = 4,
  12619. /**
  12620. * Generic
  12621. */
  12622. GENERIC = 5
  12623. }
  12624. /**
  12625. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12626. */
  12627. export interface MutableGamepadButton {
  12628. /**
  12629. * Value of the button/trigger
  12630. */
  12631. value: number;
  12632. /**
  12633. * If the button/trigger is currently touched
  12634. */
  12635. touched: boolean;
  12636. /**
  12637. * If the button/trigger is currently pressed
  12638. */
  12639. pressed: boolean;
  12640. }
  12641. /**
  12642. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12643. * @hidden
  12644. */
  12645. export interface ExtendedGamepadButton extends GamepadButton {
  12646. /**
  12647. * If the button/trigger is currently pressed
  12648. */
  12649. readonly pressed: boolean;
  12650. /**
  12651. * If the button/trigger is currently touched
  12652. */
  12653. readonly touched: boolean;
  12654. /**
  12655. * Value of the button/trigger
  12656. */
  12657. readonly value: number;
  12658. }
  12659. /** @hidden */
  12660. export interface _GamePadFactory {
  12661. /**
  12662. * Returns wether or not the current gamepad can be created for this type of controller.
  12663. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12664. * @returns true if it can be created, otherwise false
  12665. */
  12666. canCreate(gamepadInfo: any): boolean;
  12667. /**
  12668. * Creates a new instance of the Gamepad.
  12669. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12670. * @returns the new gamepad instance
  12671. */
  12672. create(gamepadInfo: any): Gamepad;
  12673. }
  12674. /**
  12675. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12676. */
  12677. export class PoseEnabledControllerHelper {
  12678. /** @hidden */
  12679. static _ControllerFactories: _GamePadFactory[];
  12680. /** @hidden */
  12681. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12682. /**
  12683. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12684. * @param vrGamepad the gamepad to initialized
  12685. * @returns a vr controller of the type the gamepad identified as
  12686. */
  12687. static InitiateController(vrGamepad: any): Gamepad;
  12688. }
  12689. /**
  12690. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12691. */
  12692. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12693. private _deviceRoomPosition;
  12694. private _deviceRoomRotationQuaternion;
  12695. /**
  12696. * The device position in babylon space
  12697. */
  12698. devicePosition: Vector3;
  12699. /**
  12700. * The device rotation in babylon space
  12701. */
  12702. deviceRotationQuaternion: Quaternion;
  12703. /**
  12704. * The scale factor of the device in babylon space
  12705. */
  12706. deviceScaleFactor: number;
  12707. /**
  12708. * (Likely devicePosition should be used instead) The device position in its room space
  12709. */
  12710. position: Vector3;
  12711. /**
  12712. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12713. */
  12714. rotationQuaternion: Quaternion;
  12715. /**
  12716. * The type of controller (Eg. Windows mixed reality)
  12717. */
  12718. controllerType: PoseEnabledControllerType;
  12719. protected _calculatedPosition: Vector3;
  12720. private _calculatedRotation;
  12721. /**
  12722. * The raw pose from the device
  12723. */
  12724. rawPose: DevicePose;
  12725. private _trackPosition;
  12726. private _maxRotationDistFromHeadset;
  12727. private _draggedRoomRotation;
  12728. /**
  12729. * @hidden
  12730. */
  12731. _disableTrackPosition(fixedPosition: Vector3): void;
  12732. /**
  12733. * Internal, the mesh attached to the controller
  12734. * @hidden
  12735. */
  12736. _mesh: Nullable<AbstractMesh>;
  12737. private _poseControlledCamera;
  12738. private _leftHandSystemQuaternion;
  12739. /**
  12740. * Internal, matrix used to convert room space to babylon space
  12741. * @hidden
  12742. */
  12743. _deviceToWorld: Matrix;
  12744. /**
  12745. * Node to be used when casting a ray from the controller
  12746. * @hidden
  12747. */
  12748. _pointingPoseNode: Nullable<TransformNode>;
  12749. /**
  12750. * Name of the child mesh that can be used to cast a ray from the controller
  12751. */
  12752. static readonly POINTING_POSE: string;
  12753. /**
  12754. * Creates a new PoseEnabledController from a gamepad
  12755. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12756. */
  12757. constructor(browserGamepad: any);
  12758. private _workingMatrix;
  12759. /**
  12760. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12761. */
  12762. update(): void;
  12763. /**
  12764. * Updates only the pose device and mesh without doing any button event checking
  12765. */
  12766. protected _updatePoseAndMesh(): void;
  12767. /**
  12768. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12769. * @param poseData raw pose fromthe device
  12770. */
  12771. updateFromDevice(poseData: DevicePose): void;
  12772. /**
  12773. * @hidden
  12774. */
  12775. _meshAttachedObservable: Observable<AbstractMesh>;
  12776. /**
  12777. * Attaches a mesh to the controller
  12778. * @param mesh the mesh to be attached
  12779. */
  12780. attachToMesh(mesh: AbstractMesh): void;
  12781. /**
  12782. * Attaches the controllers mesh to a camera
  12783. * @param camera the camera the mesh should be attached to
  12784. */
  12785. attachToPoseControlledCamera(camera: TargetCamera): void;
  12786. /**
  12787. * Disposes of the controller
  12788. */
  12789. dispose(): void;
  12790. /**
  12791. * The mesh that is attached to the controller
  12792. */
  12793. readonly mesh: Nullable<AbstractMesh>;
  12794. /**
  12795. * Gets the ray of the controller in the direction the controller is pointing
  12796. * @param length the length the resulting ray should be
  12797. * @returns a ray in the direction the controller is pointing
  12798. */
  12799. getForwardRay(length?: number): Ray;
  12800. }
  12801. }
  12802. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12803. import { Observable } from "babylonjs/Misc/observable";
  12804. import { Scene } from "babylonjs/scene";
  12805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12806. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12807. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12808. /**
  12809. * Defines the WebVRController object that represents controllers tracked in 3D space
  12810. */
  12811. export abstract class WebVRController extends PoseEnabledController {
  12812. /**
  12813. * Internal, the default controller model for the controller
  12814. */
  12815. protected _defaultModel: AbstractMesh;
  12816. /**
  12817. * Fired when the trigger state has changed
  12818. */
  12819. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12820. /**
  12821. * Fired when the main button state has changed
  12822. */
  12823. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12824. /**
  12825. * Fired when the secondary button state has changed
  12826. */
  12827. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12828. /**
  12829. * Fired when the pad state has changed
  12830. */
  12831. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12832. /**
  12833. * Fired when controllers stick values have changed
  12834. */
  12835. onPadValuesChangedObservable: Observable<StickValues>;
  12836. /**
  12837. * Array of button availible on the controller
  12838. */
  12839. protected _buttons: Array<MutableGamepadButton>;
  12840. private _onButtonStateChange;
  12841. /**
  12842. * Fired when a controller button's state has changed
  12843. * @param callback the callback containing the button that was modified
  12844. */
  12845. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12846. /**
  12847. * X and Y axis corrisponding to the controllers joystick
  12848. */
  12849. pad: StickValues;
  12850. /**
  12851. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12852. */
  12853. hand: string;
  12854. /**
  12855. * The default controller model for the controller
  12856. */
  12857. readonly defaultModel: AbstractMesh;
  12858. /**
  12859. * Creates a new WebVRController from a gamepad
  12860. * @param vrGamepad the gamepad that the WebVRController should be created from
  12861. */
  12862. constructor(vrGamepad: any);
  12863. /**
  12864. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12865. */
  12866. update(): void;
  12867. /**
  12868. * Function to be called when a button is modified
  12869. */
  12870. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12871. /**
  12872. * Loads a mesh and attaches it to the controller
  12873. * @param scene the scene the mesh should be added to
  12874. * @param meshLoaded callback for when the mesh has been loaded
  12875. */
  12876. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12877. private _setButtonValue;
  12878. private _changes;
  12879. private _checkChanges;
  12880. /**
  12881. * Disposes of th webVRCOntroller
  12882. */
  12883. dispose(): void;
  12884. }
  12885. }
  12886. declare module "babylonjs/Lights/hemisphericLight" {
  12887. import { Nullable } from "babylonjs/types";
  12888. import { Scene } from "babylonjs/scene";
  12889. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12890. import { Effect } from "babylonjs/Materials/effect";
  12891. import { Light } from "babylonjs/Lights/light";
  12892. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12893. /**
  12894. * The HemisphericLight simulates the ambient environment light,
  12895. * so the passed direction is the light reflection direction, not the incoming direction.
  12896. */
  12897. export class HemisphericLight extends Light {
  12898. /**
  12899. * The groundColor is the light in the opposite direction to the one specified during creation.
  12900. * 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.
  12901. */
  12902. groundColor: Color3;
  12903. /**
  12904. * The light reflection direction, not the incoming direction.
  12905. */
  12906. direction: Vector3;
  12907. /**
  12908. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12909. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12910. * The HemisphericLight can't cast shadows.
  12911. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12912. * @param name The friendly name of the light
  12913. * @param direction The direction of the light reflection
  12914. * @param scene The scene the light belongs to
  12915. */
  12916. constructor(name: string, direction: Vector3, scene: Scene);
  12917. protected _buildUniformLayout(): void;
  12918. /**
  12919. * Returns the string "HemisphericLight".
  12920. * @return The class name
  12921. */
  12922. getClassName(): string;
  12923. /**
  12924. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12925. * Returns the updated direction.
  12926. * @param target The target the direction should point to
  12927. * @return The computed direction
  12928. */
  12929. setDirectionToTarget(target: Vector3): Vector3;
  12930. /**
  12931. * Returns the shadow generator associated to the light.
  12932. * @returns Always null for hemispheric lights because it does not support shadows.
  12933. */
  12934. getShadowGenerator(): Nullable<IShadowGenerator>;
  12935. /**
  12936. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12937. * @param effect The effect to update
  12938. * @param lightIndex The index of the light in the effect to update
  12939. * @returns The hemispheric light
  12940. */
  12941. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12942. /**
  12943. * Computes the world matrix of the node
  12944. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12945. * @param useWasUpdatedFlag defines a reserved property
  12946. * @returns the world matrix
  12947. */
  12948. computeWorldMatrix(): Matrix;
  12949. /**
  12950. * Returns the integer 3.
  12951. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12952. */
  12953. getTypeID(): number;
  12954. /**
  12955. * Prepares the list of defines specific to the light type.
  12956. * @param defines the list of defines
  12957. * @param lightIndex defines the index of the light for the effect
  12958. */
  12959. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12960. }
  12961. }
  12962. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12963. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12964. import { Nullable } from "babylonjs/types";
  12965. import { Observable } from "babylonjs/Misc/observable";
  12966. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12967. import { Scene } from "babylonjs/scene";
  12968. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12969. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12970. import { Node } from "babylonjs/node";
  12971. import { Ray } from "babylonjs/Culling/ray";
  12972. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12973. /**
  12974. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12975. * IMPORTANT!! The data is right-hand data.
  12976. * @export
  12977. * @interface DevicePose
  12978. */
  12979. export interface DevicePose {
  12980. /**
  12981. * The position of the device, values in array are [x,y,z].
  12982. */
  12983. readonly position: Nullable<Float32Array>;
  12984. /**
  12985. * The linearVelocity of the device, values in array are [x,y,z].
  12986. */
  12987. readonly linearVelocity: Nullable<Float32Array>;
  12988. /**
  12989. * The linearAcceleration of the device, values in array are [x,y,z].
  12990. */
  12991. readonly linearAcceleration: Nullable<Float32Array>;
  12992. /**
  12993. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12994. */
  12995. readonly orientation: Nullable<Float32Array>;
  12996. /**
  12997. * The angularVelocity of the device, values in array are [x,y,z].
  12998. */
  12999. readonly angularVelocity: Nullable<Float32Array>;
  13000. /**
  13001. * The angularAcceleration of the device, values in array are [x,y,z].
  13002. */
  13003. readonly angularAcceleration: Nullable<Float32Array>;
  13004. }
  13005. /**
  13006. * Interface representing a pose controlled object in Babylon.
  13007. * A pose controlled object has both regular pose values as well as pose values
  13008. * from an external device such as a VR head mounted display
  13009. */
  13010. export interface PoseControlled {
  13011. /**
  13012. * The position of the object in babylon space.
  13013. */
  13014. position: Vector3;
  13015. /**
  13016. * The rotation quaternion of the object in babylon space.
  13017. */
  13018. rotationQuaternion: Quaternion;
  13019. /**
  13020. * The position of the device in babylon space.
  13021. */
  13022. devicePosition?: Vector3;
  13023. /**
  13024. * The rotation quaternion of the device in babylon space.
  13025. */
  13026. deviceRotationQuaternion: Quaternion;
  13027. /**
  13028. * The raw pose coming from the device.
  13029. */
  13030. rawPose: Nullable<DevicePose>;
  13031. /**
  13032. * The scale of the device to be used when translating from device space to babylon space.
  13033. */
  13034. deviceScaleFactor: number;
  13035. /**
  13036. * Updates the poseControlled values based on the input device pose.
  13037. * @param poseData the pose data to update the object with
  13038. */
  13039. updateFromDevice(poseData: DevicePose): void;
  13040. }
  13041. /**
  13042. * Set of options to customize the webVRCamera
  13043. */
  13044. export interface WebVROptions {
  13045. /**
  13046. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13047. */
  13048. trackPosition?: boolean;
  13049. /**
  13050. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13051. */
  13052. positionScale?: number;
  13053. /**
  13054. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13055. */
  13056. displayName?: string;
  13057. /**
  13058. * Should the native controller meshes be initialized. (default: true)
  13059. */
  13060. controllerMeshes?: boolean;
  13061. /**
  13062. * Creating a default HemiLight only on controllers. (default: true)
  13063. */
  13064. defaultLightingOnControllers?: boolean;
  13065. /**
  13066. * If you don't want to use the default VR button of the helper. (default: false)
  13067. */
  13068. useCustomVRButton?: boolean;
  13069. /**
  13070. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13071. */
  13072. customVRButton?: HTMLButtonElement;
  13073. /**
  13074. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13075. */
  13076. rayLength?: number;
  13077. /**
  13078. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13079. */
  13080. defaultHeight?: number;
  13081. }
  13082. /**
  13083. * This represents a WebVR camera.
  13084. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13085. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13086. */
  13087. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13088. private webVROptions;
  13089. /**
  13090. * @hidden
  13091. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13092. */
  13093. _vrDevice: any;
  13094. /**
  13095. * The rawPose of the vrDevice.
  13096. */
  13097. rawPose: Nullable<DevicePose>;
  13098. private _onVREnabled;
  13099. private _specsVersion;
  13100. private _attached;
  13101. private _frameData;
  13102. protected _descendants: Array<Node>;
  13103. private _deviceRoomPosition;
  13104. /** @hidden */
  13105. _deviceRoomRotationQuaternion: Quaternion;
  13106. private _standingMatrix;
  13107. /**
  13108. * Represents device position in babylon space.
  13109. */
  13110. devicePosition: Vector3;
  13111. /**
  13112. * Represents device rotation in babylon space.
  13113. */
  13114. deviceRotationQuaternion: Quaternion;
  13115. /**
  13116. * The scale of the device to be used when translating from device space to babylon space.
  13117. */
  13118. deviceScaleFactor: number;
  13119. private _deviceToWorld;
  13120. private _worldToDevice;
  13121. /**
  13122. * References to the webVR controllers for the vrDevice.
  13123. */
  13124. controllers: Array<WebVRController>;
  13125. /**
  13126. * Emits an event when a controller is attached.
  13127. */
  13128. onControllersAttachedObservable: Observable<WebVRController[]>;
  13129. /**
  13130. * Emits an event when a controller's mesh has been loaded;
  13131. */
  13132. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13133. /**
  13134. * Emits an event when the HMD's pose has been updated.
  13135. */
  13136. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13137. private _poseSet;
  13138. /**
  13139. * If the rig cameras be used as parent instead of this camera.
  13140. */
  13141. rigParenting: boolean;
  13142. private _lightOnControllers;
  13143. private _defaultHeight?;
  13144. /**
  13145. * Instantiates a WebVRFreeCamera.
  13146. * @param name The name of the WebVRFreeCamera
  13147. * @param position The starting anchor position for the camera
  13148. * @param scene The scene the camera belongs to
  13149. * @param webVROptions a set of customizable options for the webVRCamera
  13150. */
  13151. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13152. /**
  13153. * Gets the device distance from the ground in meters.
  13154. * @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.
  13155. */
  13156. deviceDistanceToRoomGround(): number;
  13157. /**
  13158. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13159. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13160. */
  13161. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13162. /**
  13163. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13164. * @returns A promise with a boolean set to if the standing matrix is supported.
  13165. */
  13166. useStandingMatrixAsync(): Promise<boolean>;
  13167. /**
  13168. * Disposes the camera
  13169. */
  13170. dispose(): void;
  13171. /**
  13172. * Gets a vrController by name.
  13173. * @param name The name of the controller to retreive
  13174. * @returns the controller matching the name specified or null if not found
  13175. */
  13176. getControllerByName(name: string): Nullable<WebVRController>;
  13177. private _leftController;
  13178. /**
  13179. * The controller corrisponding to the users left hand.
  13180. */
  13181. readonly leftController: Nullable<WebVRController>;
  13182. private _rightController;
  13183. /**
  13184. * The controller corrisponding to the users right hand.
  13185. */
  13186. readonly rightController: Nullable<WebVRController>;
  13187. /**
  13188. * Casts a ray forward from the vrCamera's gaze.
  13189. * @param length Length of the ray (default: 100)
  13190. * @returns the ray corrisponding to the gaze
  13191. */
  13192. getForwardRay(length?: number): Ray;
  13193. /**
  13194. * @hidden
  13195. * Updates the camera based on device's frame data
  13196. */
  13197. _checkInputs(): void;
  13198. /**
  13199. * Updates the poseControlled values based on the input device pose.
  13200. * @param poseData Pose coming from the device
  13201. */
  13202. updateFromDevice(poseData: DevicePose): void;
  13203. private _htmlElementAttached;
  13204. private _detachIfAttached;
  13205. /**
  13206. * WebVR's attach control will start broadcasting frames to the device.
  13207. * Note that in certain browsers (chrome for example) this function must be called
  13208. * within a user-interaction callback. Example:
  13209. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13210. *
  13211. * @param element html element to attach the vrDevice to
  13212. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13213. */
  13214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13215. /**
  13216. * Detaches the camera from the html element and disables VR
  13217. *
  13218. * @param element html element to detach from
  13219. */
  13220. detachControl(element: HTMLElement): void;
  13221. /**
  13222. * @returns the name of this class
  13223. */
  13224. getClassName(): string;
  13225. /**
  13226. * Calls resetPose on the vrDisplay
  13227. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13228. */
  13229. resetToCurrentRotation(): void;
  13230. /**
  13231. * @hidden
  13232. * Updates the rig cameras (left and right eye)
  13233. */
  13234. _updateRigCameras(): void;
  13235. private _workingVector;
  13236. private _oneVector;
  13237. private _workingMatrix;
  13238. private updateCacheCalled;
  13239. private _correctPositionIfNotTrackPosition;
  13240. /**
  13241. * @hidden
  13242. * Updates the cached values of the camera
  13243. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13244. */
  13245. _updateCache(ignoreParentClass?: boolean): void;
  13246. /**
  13247. * @hidden
  13248. * Get current device position in babylon world
  13249. */
  13250. _computeDevicePosition(): void;
  13251. /**
  13252. * Updates the current device position and rotation in the babylon world
  13253. */
  13254. update(): void;
  13255. /**
  13256. * @hidden
  13257. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13258. * @returns an identity matrix
  13259. */
  13260. _getViewMatrix(): Matrix;
  13261. private _tmpMatrix;
  13262. /**
  13263. * This function is called by the two RIG cameras.
  13264. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13265. * @hidden
  13266. */
  13267. _getWebVRViewMatrix(): Matrix;
  13268. /** @hidden */
  13269. _getWebVRProjectionMatrix(): Matrix;
  13270. private _onGamepadConnectedObserver;
  13271. private _onGamepadDisconnectedObserver;
  13272. private _updateCacheWhenTrackingDisabledObserver;
  13273. /**
  13274. * Initializes the controllers and their meshes
  13275. */
  13276. initControllers(): void;
  13277. }
  13278. }
  13279. declare module "babylonjs/PostProcesses/postProcess" {
  13280. import { Nullable } from "babylonjs/types";
  13281. import { SmartArray } from "babylonjs/Misc/smartArray";
  13282. import { Observable } from "babylonjs/Misc/observable";
  13283. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13284. import { Camera } from "babylonjs/Cameras/camera";
  13285. import { Effect } from "babylonjs/Materials/effect";
  13286. import "babylonjs/Shaders/postprocess.vertex";
  13287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13288. import { Engine } from "babylonjs/Engines/engine";
  13289. /**
  13290. * Size options for a post process
  13291. */
  13292. export type PostProcessOptions = {
  13293. width: number;
  13294. height: number;
  13295. };
  13296. /**
  13297. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13298. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13299. */
  13300. export class PostProcess {
  13301. /** Name of the PostProcess. */
  13302. name: string;
  13303. /**
  13304. * Gets or sets the unique id of the post process
  13305. */
  13306. uniqueId: number;
  13307. /**
  13308. * Width of the texture to apply the post process on
  13309. */
  13310. width: number;
  13311. /**
  13312. * Height of the texture to apply the post process on
  13313. */
  13314. height: number;
  13315. /**
  13316. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13317. * @hidden
  13318. */
  13319. _outputTexture: Nullable<InternalTexture>;
  13320. /**
  13321. * Sampling mode used by the shader
  13322. * See https://doc.babylonjs.com/classes/3.1/texture
  13323. */
  13324. renderTargetSamplingMode: number;
  13325. /**
  13326. * Clear color to use when screen clearing
  13327. */
  13328. clearColor: Color4;
  13329. /**
  13330. * If the buffer needs to be cleared before applying the post process. (default: true)
  13331. * Should be set to false if shader will overwrite all previous pixels.
  13332. */
  13333. autoClear: boolean;
  13334. /**
  13335. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13336. */
  13337. alphaMode: number;
  13338. /**
  13339. * Sets the setAlphaBlendConstants of the babylon engine
  13340. */
  13341. alphaConstants: Color4;
  13342. /**
  13343. * Animations to be used for the post processing
  13344. */
  13345. animations: import("babylonjs/Animations/animation").Animation[];
  13346. /**
  13347. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13348. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13349. */
  13350. enablePixelPerfectMode: boolean;
  13351. /**
  13352. * Force the postprocess to be applied without taking in account viewport
  13353. */
  13354. forceFullscreenViewport: boolean;
  13355. /**
  13356. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13357. *
  13358. * | Value | Type | Description |
  13359. * | ----- | ----------------------------------- | ----------- |
  13360. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13361. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13362. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13363. *
  13364. */
  13365. scaleMode: number;
  13366. /**
  13367. * Force textures to be a power of two (default: false)
  13368. */
  13369. alwaysForcePOT: boolean;
  13370. private _samples;
  13371. /**
  13372. * Number of sample textures (default: 1)
  13373. */
  13374. samples: number;
  13375. /**
  13376. * Modify the scale of the post process to be the same as the viewport (default: false)
  13377. */
  13378. adaptScaleToCurrentViewport: boolean;
  13379. private _camera;
  13380. private _scene;
  13381. private _engine;
  13382. private _options;
  13383. private _reusable;
  13384. private _textureType;
  13385. /**
  13386. * Smart array of input and output textures for the post process.
  13387. * @hidden
  13388. */
  13389. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13390. /**
  13391. * The index in _textures that corresponds to the output texture.
  13392. * @hidden
  13393. */
  13394. _currentRenderTextureInd: number;
  13395. private _effect;
  13396. private _samplers;
  13397. private _fragmentUrl;
  13398. private _vertexUrl;
  13399. private _parameters;
  13400. private _scaleRatio;
  13401. protected _indexParameters: any;
  13402. private _shareOutputWithPostProcess;
  13403. private _texelSize;
  13404. private _forcedOutputTexture;
  13405. /**
  13406. * Returns the fragment url or shader name used in the post process.
  13407. * @returns the fragment url or name in the shader store.
  13408. */
  13409. getEffectName(): string;
  13410. /**
  13411. * An event triggered when the postprocess is activated.
  13412. */
  13413. onActivateObservable: Observable<Camera>;
  13414. private _onActivateObserver;
  13415. /**
  13416. * A function that is added to the onActivateObservable
  13417. */
  13418. onActivate: Nullable<(camera: Camera) => void>;
  13419. /**
  13420. * An event triggered when the postprocess changes its size.
  13421. */
  13422. onSizeChangedObservable: Observable<PostProcess>;
  13423. private _onSizeChangedObserver;
  13424. /**
  13425. * A function that is added to the onSizeChangedObservable
  13426. */
  13427. onSizeChanged: (postProcess: PostProcess) => void;
  13428. /**
  13429. * An event triggered when the postprocess applies its effect.
  13430. */
  13431. onApplyObservable: Observable<Effect>;
  13432. private _onApplyObserver;
  13433. /**
  13434. * A function that is added to the onApplyObservable
  13435. */
  13436. onApply: (effect: Effect) => void;
  13437. /**
  13438. * An event triggered before rendering the postprocess
  13439. */
  13440. onBeforeRenderObservable: Observable<Effect>;
  13441. private _onBeforeRenderObserver;
  13442. /**
  13443. * A function that is added to the onBeforeRenderObservable
  13444. */
  13445. onBeforeRender: (effect: Effect) => void;
  13446. /**
  13447. * An event triggered after rendering the postprocess
  13448. */
  13449. onAfterRenderObservable: Observable<Effect>;
  13450. private _onAfterRenderObserver;
  13451. /**
  13452. * A function that is added to the onAfterRenderObservable
  13453. */
  13454. onAfterRender: (efect: Effect) => void;
  13455. /**
  13456. * 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
  13457. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13458. */
  13459. inputTexture: InternalTexture;
  13460. /**
  13461. * Gets the camera which post process is applied to.
  13462. * @returns The camera the post process is applied to.
  13463. */
  13464. getCamera(): Camera;
  13465. /**
  13466. * Gets the texel size of the postprocess.
  13467. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13468. */
  13469. readonly texelSize: Vector2;
  13470. /**
  13471. * Creates a new instance PostProcess
  13472. * @param name The name of the PostProcess.
  13473. * @param fragmentUrl The url of the fragment shader to be used.
  13474. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13475. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13477. * @param camera The camera to apply the render pass to.
  13478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13479. * @param engine The engine which the post process will be applied. (default: current engine)
  13480. * @param reusable If the post process can be reused on the same frame. (default: false)
  13481. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13482. * @param textureType Type of textures used when performing the post process. (default: 0)
  13483. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13484. * @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
  13485. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13486. */
  13487. constructor(
  13488. /** Name of the PostProcess. */
  13489. 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);
  13490. /**
  13491. * Gets a string idenfifying the name of the class
  13492. * @returns "PostProcess" string
  13493. */
  13494. getClassName(): string;
  13495. /**
  13496. * Gets the engine which this post process belongs to.
  13497. * @returns The engine the post process was enabled with.
  13498. */
  13499. getEngine(): Engine;
  13500. /**
  13501. * The effect that is created when initializing the post process.
  13502. * @returns The created effect corrisponding the the postprocess.
  13503. */
  13504. getEffect(): Effect;
  13505. /**
  13506. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13507. * @param postProcess The post process to share the output with.
  13508. * @returns This post process.
  13509. */
  13510. shareOutputWith(postProcess: PostProcess): PostProcess;
  13511. /**
  13512. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13513. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13514. */
  13515. useOwnOutput(): void;
  13516. /**
  13517. * Updates the effect with the current post process compile time values and recompiles the shader.
  13518. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13519. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13520. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13521. * @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
  13522. * @param onCompiled Called when the shader has been compiled.
  13523. * @param onError Called if there is an error when compiling a shader.
  13524. */
  13525. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13526. /**
  13527. * The post process is reusable if it can be used multiple times within one frame.
  13528. * @returns If the post process is reusable
  13529. */
  13530. isReusable(): boolean;
  13531. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13532. markTextureDirty(): void;
  13533. /**
  13534. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13535. * 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.
  13536. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13537. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13538. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13539. * @returns The target texture that was bound to be written to.
  13540. */
  13541. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13542. /**
  13543. * If the post process is supported.
  13544. */
  13545. readonly isSupported: boolean;
  13546. /**
  13547. * The aspect ratio of the output texture.
  13548. */
  13549. readonly aspectRatio: number;
  13550. /**
  13551. * Get a value indicating if the post-process is ready to be used
  13552. * @returns true if the post-process is ready (shader is compiled)
  13553. */
  13554. isReady(): boolean;
  13555. /**
  13556. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13557. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13558. */
  13559. apply(): Nullable<Effect>;
  13560. private _disposeTextures;
  13561. /**
  13562. * Disposes the post process.
  13563. * @param camera The camera to dispose the post process on.
  13564. */
  13565. dispose(camera?: Camera): void;
  13566. }
  13567. }
  13568. declare module "babylonjs/PostProcesses/postProcessManager" {
  13569. import { Nullable } from "babylonjs/types";
  13570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13571. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13572. import { Scene } from "babylonjs/scene";
  13573. /**
  13574. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13575. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13576. */
  13577. export class PostProcessManager {
  13578. private _scene;
  13579. private _indexBuffer;
  13580. private _vertexBuffers;
  13581. /**
  13582. * Creates a new instance PostProcess
  13583. * @param scene The scene that the post process is associated with.
  13584. */
  13585. constructor(scene: Scene);
  13586. private _prepareBuffers;
  13587. private _buildIndexBuffer;
  13588. /**
  13589. * Rebuilds the vertex buffers of the manager.
  13590. * @hidden
  13591. */
  13592. _rebuild(): void;
  13593. /**
  13594. * Prepares a frame to be run through a post process.
  13595. * @param sourceTexture The input texture to the post procesess. (default: null)
  13596. * @param postProcesses An array of post processes to be run. (default: null)
  13597. * @returns True if the post processes were able to be run.
  13598. * @hidden
  13599. */
  13600. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13601. /**
  13602. * Manually render a set of post processes to a texture.
  13603. * @param postProcesses An array of post processes to be run.
  13604. * @param targetTexture The target texture to render to.
  13605. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13606. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13607. * @param lodLevel defines which lod of the texture to render to
  13608. */
  13609. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13610. /**
  13611. * Finalize the result of the output of the postprocesses.
  13612. * @param doNotPresent If true the result will not be displayed to the screen.
  13613. * @param targetTexture The target texture to render to.
  13614. * @param faceIndex The index of the face to bind the target texture to.
  13615. * @param postProcesses The array of post processes to render.
  13616. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13617. * @hidden
  13618. */
  13619. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13620. /**
  13621. * Disposes of the post process manager.
  13622. */
  13623. dispose(): void;
  13624. }
  13625. }
  13626. declare module "babylonjs/Layers/layerSceneComponent" {
  13627. import { Scene } from "babylonjs/scene";
  13628. import { ISceneComponent } from "babylonjs/sceneComponent";
  13629. import { Layer } from "babylonjs/Layers/layer";
  13630. module "babylonjs/abstractScene" {
  13631. interface AbstractScene {
  13632. /**
  13633. * The list of layers (background and foreground) of the scene
  13634. */
  13635. layers: Array<Layer>;
  13636. }
  13637. }
  13638. /**
  13639. * Defines the layer scene component responsible to manage any layers
  13640. * in a given scene.
  13641. */
  13642. export class LayerSceneComponent implements ISceneComponent {
  13643. /**
  13644. * The component name helpfull to identify the component in the list of scene components.
  13645. */
  13646. readonly name: string;
  13647. /**
  13648. * The scene the component belongs to.
  13649. */
  13650. scene: Scene;
  13651. private _engine;
  13652. /**
  13653. * Creates a new instance of the component for the given scene
  13654. * @param scene Defines the scene to register the component in
  13655. */
  13656. constructor(scene: Scene);
  13657. /**
  13658. * Registers the component in a given scene
  13659. */
  13660. register(): void;
  13661. /**
  13662. * Rebuilds the elements related to this component in case of
  13663. * context lost for instance.
  13664. */
  13665. rebuild(): void;
  13666. /**
  13667. * Disposes the component and the associated ressources.
  13668. */
  13669. dispose(): void;
  13670. private _draw;
  13671. private _drawCameraPredicate;
  13672. private _drawCameraBackground;
  13673. private _drawCameraForeground;
  13674. private _drawRenderTargetPredicate;
  13675. private _drawRenderTargetBackground;
  13676. private _drawRenderTargetForeground;
  13677. }
  13678. }
  13679. declare module "babylonjs/Shaders/layer.fragment" {
  13680. /** @hidden */
  13681. export var layerPixelShader: {
  13682. name: string;
  13683. shader: string;
  13684. };
  13685. }
  13686. declare module "babylonjs/Shaders/layer.vertex" {
  13687. /** @hidden */
  13688. export var layerVertexShader: {
  13689. name: string;
  13690. shader: string;
  13691. };
  13692. }
  13693. declare module "babylonjs/Layers/layer" {
  13694. import { Observable } from "babylonjs/Misc/observable";
  13695. import { Nullable } from "babylonjs/types";
  13696. import { Scene } from "babylonjs/scene";
  13697. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13698. import { Texture } from "babylonjs/Materials/Textures/texture";
  13699. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13700. import "babylonjs/Shaders/layer.fragment";
  13701. import "babylonjs/Shaders/layer.vertex";
  13702. /**
  13703. * This represents a full screen 2d layer.
  13704. * This can be useful to display a picture in the background of your scene for instance.
  13705. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13706. */
  13707. export class Layer {
  13708. /**
  13709. * Define the name of the layer.
  13710. */
  13711. name: string;
  13712. /**
  13713. * Define the texture the layer should display.
  13714. */
  13715. texture: Nullable<Texture>;
  13716. /**
  13717. * Is the layer in background or foreground.
  13718. */
  13719. isBackground: boolean;
  13720. /**
  13721. * Define the color of the layer (instead of texture).
  13722. */
  13723. color: Color4;
  13724. /**
  13725. * Define the scale of the layer in order to zoom in out of the texture.
  13726. */
  13727. scale: Vector2;
  13728. /**
  13729. * Define an offset for the layer in order to shift the texture.
  13730. */
  13731. offset: Vector2;
  13732. /**
  13733. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13734. */
  13735. alphaBlendingMode: number;
  13736. /**
  13737. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13738. * Alpha test will not mix with the background color in case of transparency.
  13739. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13740. */
  13741. alphaTest: boolean;
  13742. /**
  13743. * Define a mask to restrict the layer to only some of the scene cameras.
  13744. */
  13745. layerMask: number;
  13746. /**
  13747. * Define the list of render target the layer is visible into.
  13748. */
  13749. renderTargetTextures: RenderTargetTexture[];
  13750. /**
  13751. * Define if the layer is only used in renderTarget or if it also
  13752. * renders in the main frame buffer of the canvas.
  13753. */
  13754. renderOnlyInRenderTargetTextures: boolean;
  13755. private _scene;
  13756. private _vertexBuffers;
  13757. private _indexBuffer;
  13758. private _effect;
  13759. private _alphaTestEffect;
  13760. /**
  13761. * An event triggered when the layer is disposed.
  13762. */
  13763. onDisposeObservable: Observable<Layer>;
  13764. private _onDisposeObserver;
  13765. /**
  13766. * Back compatibility with callback before the onDisposeObservable existed.
  13767. * The set callback will be triggered when the layer has been disposed.
  13768. */
  13769. onDispose: () => void;
  13770. /**
  13771. * An event triggered before rendering the scene
  13772. */
  13773. onBeforeRenderObservable: Observable<Layer>;
  13774. private _onBeforeRenderObserver;
  13775. /**
  13776. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13777. * The set callback will be triggered just before rendering the layer.
  13778. */
  13779. onBeforeRender: () => void;
  13780. /**
  13781. * An event triggered after rendering the scene
  13782. */
  13783. onAfterRenderObservable: Observable<Layer>;
  13784. private _onAfterRenderObserver;
  13785. /**
  13786. * Back compatibility with callback before the onAfterRenderObservable existed.
  13787. * The set callback will be triggered just after rendering the layer.
  13788. */
  13789. onAfterRender: () => void;
  13790. /**
  13791. * Instantiates a new layer.
  13792. * This represents a full screen 2d layer.
  13793. * This can be useful to display a picture in the background of your scene for instance.
  13794. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13795. * @param name Define the name of the layer in the scene
  13796. * @param imgUrl Define the url of the texture to display in the layer
  13797. * @param scene Define the scene the layer belongs to
  13798. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13799. * @param color Defines a color for the layer
  13800. */
  13801. constructor(
  13802. /**
  13803. * Define the name of the layer.
  13804. */
  13805. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13806. private _createIndexBuffer;
  13807. /** @hidden */
  13808. _rebuild(): void;
  13809. /**
  13810. * Renders the layer in the scene.
  13811. */
  13812. render(): void;
  13813. /**
  13814. * Disposes and releases the associated ressources.
  13815. */
  13816. dispose(): void;
  13817. }
  13818. }
  13819. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13820. import { Scene } from "babylonjs/scene";
  13821. import { ISceneComponent } from "babylonjs/sceneComponent";
  13822. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13823. module "babylonjs/abstractScene" {
  13824. interface AbstractScene {
  13825. /**
  13826. * The list of procedural textures added to the scene
  13827. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13828. */
  13829. proceduralTextures: Array<ProceduralTexture>;
  13830. }
  13831. }
  13832. /**
  13833. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13834. * in a given scene.
  13835. */
  13836. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13837. /**
  13838. * The component name helpfull to identify the component in the list of scene components.
  13839. */
  13840. readonly name: string;
  13841. /**
  13842. * The scene the component belongs to.
  13843. */
  13844. scene: Scene;
  13845. /**
  13846. * Creates a new instance of the component for the given scene
  13847. * @param scene Defines the scene to register the component in
  13848. */
  13849. constructor(scene: Scene);
  13850. /**
  13851. * Registers the component in a given scene
  13852. */
  13853. register(): void;
  13854. /**
  13855. * Rebuilds the elements related to this component in case of
  13856. * context lost for instance.
  13857. */
  13858. rebuild(): void;
  13859. /**
  13860. * Disposes the component and the associated ressources.
  13861. */
  13862. dispose(): void;
  13863. private _beforeClear;
  13864. }
  13865. }
  13866. declare module "babylonjs/Shaders/procedural.vertex" {
  13867. /** @hidden */
  13868. export var proceduralVertexShader: {
  13869. name: string;
  13870. shader: string;
  13871. };
  13872. }
  13873. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13874. import { Observable } from "babylonjs/Misc/observable";
  13875. import { Nullable } from "babylonjs/types";
  13876. import { Scene } from "babylonjs/scene";
  13877. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13878. import { Effect } from "babylonjs/Materials/effect";
  13879. import { Texture } from "babylonjs/Materials/Textures/texture";
  13880. import "babylonjs/Shaders/procedural.vertex";
  13881. /**
  13882. * 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.
  13883. * This is the base class of any Procedural texture and contains most of the shareable code.
  13884. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13885. */
  13886. export class ProceduralTexture extends Texture {
  13887. isCube: boolean;
  13888. /**
  13889. * Define if the texture is enabled or not (disabled texture will not render)
  13890. */
  13891. isEnabled: boolean;
  13892. /**
  13893. * Define if the texture must be cleared before rendering (default is true)
  13894. */
  13895. autoClear: boolean;
  13896. /**
  13897. * Callback called when the texture is generated
  13898. */
  13899. onGenerated: () => void;
  13900. /**
  13901. * Event raised when the texture is generated
  13902. */
  13903. onGeneratedObservable: Observable<ProceduralTexture>;
  13904. /** @hidden */
  13905. _generateMipMaps: boolean;
  13906. /** @hidden **/
  13907. _effect: Effect;
  13908. /** @hidden */
  13909. _textures: {
  13910. [key: string]: Texture;
  13911. };
  13912. private _size;
  13913. private _currentRefreshId;
  13914. private _refreshRate;
  13915. private _vertexBuffers;
  13916. private _indexBuffer;
  13917. private _uniforms;
  13918. private _samplers;
  13919. private _fragment;
  13920. private _floats;
  13921. private _ints;
  13922. private _floatsArrays;
  13923. private _colors3;
  13924. private _colors4;
  13925. private _vectors2;
  13926. private _vectors3;
  13927. private _matrices;
  13928. private _fallbackTexture;
  13929. private _fallbackTextureUsed;
  13930. private _engine;
  13931. private _cachedDefines;
  13932. private _contentUpdateId;
  13933. private _contentData;
  13934. /**
  13935. * Instantiates a new procedural texture.
  13936. * 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.
  13937. * This is the base class of any Procedural texture and contains most of the shareable code.
  13938. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13939. * @param name Define the name of the texture
  13940. * @param size Define the size of the texture to create
  13941. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13942. * @param scene Define the scene the texture belongs to
  13943. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13944. * @param generateMipMaps Define if the texture should creates mip maps or not
  13945. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13946. */
  13947. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13948. /**
  13949. * The effect that is created when initializing the post process.
  13950. * @returns The created effect corrisponding the the postprocess.
  13951. */
  13952. getEffect(): Effect;
  13953. /**
  13954. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13955. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13956. */
  13957. getContent(): Nullable<ArrayBufferView>;
  13958. private _createIndexBuffer;
  13959. /** @hidden */
  13960. _rebuild(): void;
  13961. /**
  13962. * Resets the texture in order to recreate its associated resources.
  13963. * This can be called in case of context loss
  13964. */
  13965. reset(): void;
  13966. protected _getDefines(): string;
  13967. /**
  13968. * Is the texture ready to be used ? (rendered at least once)
  13969. * @returns true if ready, otherwise, false.
  13970. */
  13971. isReady(): boolean;
  13972. /**
  13973. * Resets the refresh counter of the texture and start bak from scratch.
  13974. * Could be useful to regenerate the texture if it is setup to render only once.
  13975. */
  13976. resetRefreshCounter(): void;
  13977. /**
  13978. * Set the fragment shader to use in order to render the texture.
  13979. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13980. */
  13981. setFragment(fragment: any): void;
  13982. /**
  13983. * Define the refresh rate of the texture or the rendering frequency.
  13984. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13985. */
  13986. refreshRate: number;
  13987. /** @hidden */
  13988. _shouldRender(): boolean;
  13989. /**
  13990. * Get the size the texture is rendering at.
  13991. * @returns the size (texture is always squared)
  13992. */
  13993. getRenderSize(): number;
  13994. /**
  13995. * Resize the texture to new value.
  13996. * @param size Define the new size the texture should have
  13997. * @param generateMipMaps Define whether the new texture should create mip maps
  13998. */
  13999. resize(size: number, generateMipMaps: boolean): void;
  14000. private _checkUniform;
  14001. /**
  14002. * Set a texture in the shader program used to render.
  14003. * @param name Define the name of the uniform samplers as defined in the shader
  14004. * @param texture Define the texture to bind to this sampler
  14005. * @return the texture itself allowing "fluent" like uniform updates
  14006. */
  14007. setTexture(name: string, texture: Texture): ProceduralTexture;
  14008. /**
  14009. * Set a float in the shader.
  14010. * @param name Define the name of the uniform as defined in the shader
  14011. * @param value Define the value to give to the uniform
  14012. * @return the texture itself allowing "fluent" like uniform updates
  14013. */
  14014. setFloat(name: string, value: number): ProceduralTexture;
  14015. /**
  14016. * Set a int in the shader.
  14017. * @param name Define the name of the uniform as defined in the shader
  14018. * @param value Define the value to give to the uniform
  14019. * @return the texture itself allowing "fluent" like uniform updates
  14020. */
  14021. setInt(name: string, value: number): ProceduralTexture;
  14022. /**
  14023. * Set an array of floats in the shader.
  14024. * @param name Define the name of the uniform as defined in the shader
  14025. * @param value Define the value to give to the uniform
  14026. * @return the texture itself allowing "fluent" like uniform updates
  14027. */
  14028. setFloats(name: string, value: number[]): ProceduralTexture;
  14029. /**
  14030. * Set a vec3 in the shader from a Color3.
  14031. * @param name Define the name of the uniform as defined in the shader
  14032. * @param value Define the value to give to the uniform
  14033. * @return the texture itself allowing "fluent" like uniform updates
  14034. */
  14035. setColor3(name: string, value: Color3): ProceduralTexture;
  14036. /**
  14037. * Set a vec4 in the shader from a Color4.
  14038. * @param name Define the name of the uniform as defined in the shader
  14039. * @param value Define the value to give to the uniform
  14040. * @return the texture itself allowing "fluent" like uniform updates
  14041. */
  14042. setColor4(name: string, value: Color4): ProceduralTexture;
  14043. /**
  14044. * Set a vec2 in the shader from a Vector2.
  14045. * @param name Define the name of the uniform as defined in the shader
  14046. * @param value Define the value to give to the uniform
  14047. * @return the texture itself allowing "fluent" like uniform updates
  14048. */
  14049. setVector2(name: string, value: Vector2): ProceduralTexture;
  14050. /**
  14051. * Set a vec3 in the shader from a Vector3.
  14052. * @param name Define the name of the uniform as defined in the shader
  14053. * @param value Define the value to give to the uniform
  14054. * @return the texture itself allowing "fluent" like uniform updates
  14055. */
  14056. setVector3(name: string, value: Vector3): ProceduralTexture;
  14057. /**
  14058. * Set a mat4 in the shader from a MAtrix.
  14059. * @param name Define the name of the uniform as defined in the shader
  14060. * @param value Define the value to give to the uniform
  14061. * @return the texture itself allowing "fluent" like uniform updates
  14062. */
  14063. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14064. /**
  14065. * Render the texture to its associated render target.
  14066. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14067. */
  14068. render(useCameraPostProcess?: boolean): void;
  14069. /**
  14070. * Clone the texture.
  14071. * @returns the cloned texture
  14072. */
  14073. clone(): ProceduralTexture;
  14074. /**
  14075. * Dispose the texture and release its asoociated resources.
  14076. */
  14077. dispose(): void;
  14078. }
  14079. }
  14080. declare module "babylonjs/Particles/baseParticleSystem" {
  14081. import { Nullable } from "babylonjs/types";
  14082. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14084. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14085. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14087. import { Scene } from "babylonjs/scene";
  14088. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14089. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14090. import { Texture } from "babylonjs/Materials/Textures/texture";
  14091. import { Animation } from "babylonjs/Animations/animation";
  14092. /**
  14093. * This represents the base class for particle system in Babylon.
  14094. * 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.
  14095. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14096. * @example https://doc.babylonjs.com/babylon101/particles
  14097. */
  14098. export class BaseParticleSystem {
  14099. /**
  14100. * Source color is added to the destination color without alpha affecting the result
  14101. */
  14102. static BLENDMODE_ONEONE: number;
  14103. /**
  14104. * Blend current color and particle color using particle’s alpha
  14105. */
  14106. static BLENDMODE_STANDARD: number;
  14107. /**
  14108. * Add current color and particle color multiplied by particle’s alpha
  14109. */
  14110. static BLENDMODE_ADD: number;
  14111. /**
  14112. * Multiply current color with particle color
  14113. */
  14114. static BLENDMODE_MULTIPLY: number;
  14115. /**
  14116. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14117. */
  14118. static BLENDMODE_MULTIPLYADD: number;
  14119. /**
  14120. * List of animations used by the particle system.
  14121. */
  14122. animations: Animation[];
  14123. /**
  14124. * The id of the Particle system.
  14125. */
  14126. id: string;
  14127. /**
  14128. * The friendly name of the Particle system.
  14129. */
  14130. name: string;
  14131. /**
  14132. * The rendering group used by the Particle system to chose when to render.
  14133. */
  14134. renderingGroupId: number;
  14135. /**
  14136. * The emitter represents the Mesh or position we are attaching the particle system to.
  14137. */
  14138. emitter: Nullable<AbstractMesh | Vector3>;
  14139. /**
  14140. * The maximum number of particles to emit per frame
  14141. */
  14142. emitRate: number;
  14143. /**
  14144. * If you want to launch only a few particles at once, that can be done, as well.
  14145. */
  14146. manualEmitCount: number;
  14147. /**
  14148. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14149. */
  14150. updateSpeed: number;
  14151. /**
  14152. * The amount of time the particle system is running (depends of the overall update speed).
  14153. */
  14154. targetStopDuration: number;
  14155. /**
  14156. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14157. */
  14158. disposeOnStop: boolean;
  14159. /**
  14160. * Minimum power of emitting particles.
  14161. */
  14162. minEmitPower: number;
  14163. /**
  14164. * Maximum power of emitting particles.
  14165. */
  14166. maxEmitPower: number;
  14167. /**
  14168. * Minimum life time of emitting particles.
  14169. */
  14170. minLifeTime: number;
  14171. /**
  14172. * Maximum life time of emitting particles.
  14173. */
  14174. maxLifeTime: number;
  14175. /**
  14176. * Minimum Size of emitting particles.
  14177. */
  14178. minSize: number;
  14179. /**
  14180. * Maximum Size of emitting particles.
  14181. */
  14182. maxSize: number;
  14183. /**
  14184. * Minimum scale of emitting particles on X axis.
  14185. */
  14186. minScaleX: number;
  14187. /**
  14188. * Maximum scale of emitting particles on X axis.
  14189. */
  14190. maxScaleX: number;
  14191. /**
  14192. * Minimum scale of emitting particles on Y axis.
  14193. */
  14194. minScaleY: number;
  14195. /**
  14196. * Maximum scale of emitting particles on Y axis.
  14197. */
  14198. maxScaleY: number;
  14199. /**
  14200. * Gets or sets the minimal initial rotation in radians.
  14201. */
  14202. minInitialRotation: number;
  14203. /**
  14204. * Gets or sets the maximal initial rotation in radians.
  14205. */
  14206. maxInitialRotation: number;
  14207. /**
  14208. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14209. */
  14210. minAngularSpeed: number;
  14211. /**
  14212. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14213. */
  14214. maxAngularSpeed: number;
  14215. /**
  14216. * The texture used to render each particle. (this can be a spritesheet)
  14217. */
  14218. particleTexture: Nullable<Texture>;
  14219. /**
  14220. * The layer mask we are rendering the particles through.
  14221. */
  14222. layerMask: number;
  14223. /**
  14224. * This can help using your own shader to render the particle system.
  14225. * The according effect will be created
  14226. */
  14227. customShader: any;
  14228. /**
  14229. * By default particle system starts as soon as they are created. This prevents the
  14230. * automatic start to happen and let you decide when to start emitting particles.
  14231. */
  14232. preventAutoStart: boolean;
  14233. private _noiseTexture;
  14234. /**
  14235. * Gets or sets a texture used to add random noise to particle positions
  14236. */
  14237. noiseTexture: Nullable<ProceduralTexture>;
  14238. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14239. noiseStrength: Vector3;
  14240. /**
  14241. * Callback triggered when the particle animation is ending.
  14242. */
  14243. onAnimationEnd: Nullable<() => void>;
  14244. /**
  14245. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14246. */
  14247. blendMode: number;
  14248. /**
  14249. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14250. * to override the particles.
  14251. */
  14252. forceDepthWrite: boolean;
  14253. /** 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 */
  14254. preWarmCycles: number;
  14255. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14256. preWarmStepOffset: number;
  14257. /**
  14258. * 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)
  14259. */
  14260. spriteCellChangeSpeed: number;
  14261. /**
  14262. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14263. */
  14264. startSpriteCellID: number;
  14265. /**
  14266. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14267. */
  14268. endSpriteCellID: number;
  14269. /**
  14270. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14271. */
  14272. spriteCellWidth: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14275. */
  14276. spriteCellHeight: number;
  14277. /**
  14278. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14279. */
  14280. spriteRandomStartCell: boolean;
  14281. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14282. translationPivot: Vector2;
  14283. /** @hidden */
  14284. protected _isAnimationSheetEnabled: boolean;
  14285. /**
  14286. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14287. */
  14288. beginAnimationOnStart: boolean;
  14289. /**
  14290. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14291. */
  14292. beginAnimationFrom: number;
  14293. /**
  14294. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14295. */
  14296. beginAnimationTo: number;
  14297. /**
  14298. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14299. */
  14300. beginAnimationLoop: boolean;
  14301. /**
  14302. * Gets or sets a world offset applied to all particles
  14303. */
  14304. worldOffset: Vector3;
  14305. /**
  14306. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14307. */
  14308. isAnimationSheetEnabled: boolean;
  14309. /**
  14310. * Get hosting scene
  14311. * @returns the scene
  14312. */
  14313. getScene(): Scene;
  14314. /**
  14315. * You can use gravity if you want to give an orientation to your particles.
  14316. */
  14317. gravity: Vector3;
  14318. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14319. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14320. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14321. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14322. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14323. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14324. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14325. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14326. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14327. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14328. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14329. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14330. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14331. /**
  14332. * Defines the delay in milliseconds before starting the system (0 by default)
  14333. */
  14334. startDelay: number;
  14335. /**
  14336. * Gets the current list of drag gradients.
  14337. * You must use addDragGradient and removeDragGradient to udpate this list
  14338. * @returns the list of drag gradients
  14339. */
  14340. getDragGradients(): Nullable<Array<FactorGradient>>;
  14341. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14342. limitVelocityDamping: number;
  14343. /**
  14344. * Gets the current list of limit velocity gradients.
  14345. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14346. * @returns the list of limit velocity gradients
  14347. */
  14348. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14349. /**
  14350. * Gets the current list of color gradients.
  14351. * You must use addColorGradient and removeColorGradient to udpate this list
  14352. * @returns the list of color gradients
  14353. */
  14354. getColorGradients(): Nullable<Array<ColorGradient>>;
  14355. /**
  14356. * Gets the current list of size gradients.
  14357. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14358. * @returns the list of size gradients
  14359. */
  14360. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14361. /**
  14362. * Gets the current list of color remap gradients.
  14363. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14364. * @returns the list of color remap gradients
  14365. */
  14366. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Gets the current list of alpha remap gradients.
  14369. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14370. * @returns the list of alpha remap gradients
  14371. */
  14372. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Gets the current list of life time gradients.
  14375. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14376. * @returns the list of life time gradients
  14377. */
  14378. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14379. /**
  14380. * Gets the current list of angular speed gradients.
  14381. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14382. * @returns the list of angular speed gradients
  14383. */
  14384. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of velocity gradients.
  14387. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14388. * @returns the list of velocity gradients
  14389. */
  14390. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of start size gradients.
  14393. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14394. * @returns the list of start size gradients
  14395. */
  14396. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14397. /**
  14398. * Gets the current list of emit rate gradients.
  14399. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14400. * @returns the list of emit rate gradients
  14401. */
  14402. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14403. /**
  14404. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14405. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14406. */
  14407. direction1: Vector3;
  14408. /**
  14409. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14410. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14411. */
  14412. direction2: Vector3;
  14413. /**
  14414. * 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.
  14415. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14416. */
  14417. minEmitBox: Vector3;
  14418. /**
  14419. * 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.
  14420. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14421. */
  14422. maxEmitBox: Vector3;
  14423. /**
  14424. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14425. */
  14426. color1: Color4;
  14427. /**
  14428. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14429. */
  14430. color2: Color4;
  14431. /**
  14432. * Color the particle will have at the end of its lifetime
  14433. */
  14434. colorDead: Color4;
  14435. /**
  14436. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14437. */
  14438. textureMask: Color4;
  14439. /**
  14440. * The particle emitter type defines the emitter used by the particle system.
  14441. * It can be for example box, sphere, or cone...
  14442. */
  14443. particleEmitterType: IParticleEmitterType;
  14444. /** @hidden */
  14445. _isSubEmitter: boolean;
  14446. /**
  14447. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14448. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14449. */
  14450. billboardMode: number;
  14451. protected _isBillboardBased: boolean;
  14452. /**
  14453. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14454. */
  14455. isBillboardBased: boolean;
  14456. /**
  14457. * The scene the particle system belongs to.
  14458. */
  14459. protected _scene: Scene;
  14460. /**
  14461. * Local cache of defines for image processing.
  14462. */
  14463. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14464. /**
  14465. * Default configuration related to image processing available in the standard Material.
  14466. */
  14467. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14468. /**
  14469. * Gets the image processing configuration used either in this material.
  14470. */
  14471. /**
  14472. * Sets the Default image processing configuration used either in the this material.
  14473. *
  14474. * If sets to null, the scene one is in use.
  14475. */
  14476. imageProcessingConfiguration: ImageProcessingConfiguration;
  14477. /**
  14478. * Attaches a new image processing configuration to the Standard Material.
  14479. * @param configuration
  14480. */
  14481. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14482. /** @hidden */
  14483. protected _reset(): void;
  14484. /** @hidden */
  14485. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14486. /**
  14487. * Instantiates a particle system.
  14488. * 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.
  14489. * @param name The name of the particle system
  14490. */
  14491. constructor(name: string);
  14492. /**
  14493. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14494. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14495. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14496. * @returns the emitter
  14497. */
  14498. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14499. /**
  14500. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14501. * @param radius The radius of the hemisphere to emit from
  14502. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14503. * @returns the emitter
  14504. */
  14505. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14506. /**
  14507. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14508. * @param radius The radius of the sphere to emit from
  14509. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14510. * @returns the emitter
  14511. */
  14512. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14513. /**
  14514. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14515. * @param radius The radius of the sphere to emit from
  14516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14518. * @returns the emitter
  14519. */
  14520. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14521. /**
  14522. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14523. * @param radius The radius of the emission cylinder
  14524. * @param height The height of the emission cylinder
  14525. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14526. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14527. * @returns the emitter
  14528. */
  14529. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14530. /**
  14531. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14532. * @param radius The radius of the cylinder to emit from
  14533. * @param height The height of the emission cylinder
  14534. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14537. * @returns the emitter
  14538. */
  14539. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14540. /**
  14541. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14542. * @param radius The radius of the cone to emit from
  14543. * @param angle The base angle of the cone
  14544. * @returns the emitter
  14545. */
  14546. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14547. /**
  14548. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14551. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14552. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14553. * @returns the emitter
  14554. */
  14555. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14556. }
  14557. }
  14558. declare module "babylonjs/Particles/subEmitter" {
  14559. import { Scene } from "babylonjs/scene";
  14560. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14561. /**
  14562. * Type of sub emitter
  14563. */
  14564. export enum SubEmitterType {
  14565. /**
  14566. * Attached to the particle over it's lifetime
  14567. */
  14568. ATTACHED = 0,
  14569. /**
  14570. * Created when the particle dies
  14571. */
  14572. END = 1
  14573. }
  14574. /**
  14575. * Sub emitter class used to emit particles from an existing particle
  14576. */
  14577. export class SubEmitter {
  14578. /**
  14579. * the particle system to be used by the sub emitter
  14580. */
  14581. particleSystem: ParticleSystem;
  14582. /**
  14583. * Type of the submitter (Default: END)
  14584. */
  14585. type: SubEmitterType;
  14586. /**
  14587. * 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)
  14588. * Note: This only is supported when using an emitter of type Mesh
  14589. */
  14590. inheritDirection: boolean;
  14591. /**
  14592. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14593. */
  14594. inheritedVelocityAmount: number;
  14595. /**
  14596. * Creates a sub emitter
  14597. * @param particleSystem the particle system to be used by the sub emitter
  14598. */
  14599. constructor(
  14600. /**
  14601. * the particle system to be used by the sub emitter
  14602. */
  14603. particleSystem: ParticleSystem);
  14604. /**
  14605. * Clones the sub emitter
  14606. * @returns the cloned sub emitter
  14607. */
  14608. clone(): SubEmitter;
  14609. /**
  14610. * Serialize current object to a JSON object
  14611. * @returns the serialized object
  14612. */
  14613. serialize(): any;
  14614. /** @hidden */
  14615. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14616. /**
  14617. * Creates a new SubEmitter from a serialized JSON version
  14618. * @param serializationObject defines the JSON object to read from
  14619. * @param scene defines the hosting scene
  14620. * @param rootUrl defines the rootUrl for data loading
  14621. * @returns a new SubEmitter
  14622. */
  14623. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14624. /** Release associated resources */
  14625. dispose(): void;
  14626. }
  14627. }
  14628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14629. /** @hidden */
  14630. export var clipPlaneFragmentDeclaration: {
  14631. name: string;
  14632. shader: string;
  14633. };
  14634. }
  14635. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14636. /** @hidden */
  14637. export var imageProcessingDeclaration: {
  14638. name: string;
  14639. shader: string;
  14640. };
  14641. }
  14642. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14643. /** @hidden */
  14644. export var imageProcessingFunctions: {
  14645. name: string;
  14646. shader: string;
  14647. };
  14648. }
  14649. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14650. /** @hidden */
  14651. export var clipPlaneFragment: {
  14652. name: string;
  14653. shader: string;
  14654. };
  14655. }
  14656. declare module "babylonjs/Shaders/particles.fragment" {
  14657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14658. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14659. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14660. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14661. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14662. /** @hidden */
  14663. export var particlesPixelShader: {
  14664. name: string;
  14665. shader: string;
  14666. };
  14667. }
  14668. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14669. /** @hidden */
  14670. export var clipPlaneVertexDeclaration: {
  14671. name: string;
  14672. shader: string;
  14673. };
  14674. }
  14675. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14676. /** @hidden */
  14677. export var clipPlaneVertex: {
  14678. name: string;
  14679. shader: string;
  14680. };
  14681. }
  14682. declare module "babylonjs/Shaders/particles.vertex" {
  14683. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14684. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14685. /** @hidden */
  14686. export var particlesVertexShader: {
  14687. name: string;
  14688. shader: string;
  14689. };
  14690. }
  14691. declare module "babylonjs/Particles/particleSystem" {
  14692. import { Nullable } from "babylonjs/types";
  14693. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14694. import { Observable } from "babylonjs/Misc/observable";
  14695. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14696. import { Effect } from "babylonjs/Materials/effect";
  14697. import { Scene, IDisposable } from "babylonjs/scene";
  14698. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14699. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14700. import { Particle } from "babylonjs/Particles/particle";
  14701. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14702. import "babylonjs/Shaders/particles.fragment";
  14703. import "babylonjs/Shaders/particles.vertex";
  14704. /**
  14705. * This represents a particle system in Babylon.
  14706. * 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.
  14707. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14708. * @example https://doc.babylonjs.com/babylon101/particles
  14709. */
  14710. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14711. /**
  14712. * Billboard mode will only apply to Y axis
  14713. */
  14714. static readonly BILLBOARDMODE_Y: number;
  14715. /**
  14716. * Billboard mode will apply to all axes
  14717. */
  14718. static readonly BILLBOARDMODE_ALL: number;
  14719. /**
  14720. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14721. */
  14722. static readonly BILLBOARDMODE_STRETCHED: number;
  14723. /**
  14724. * This function can be defined to provide custom update for active particles.
  14725. * This function will be called instead of regular update (age, position, color, etc.).
  14726. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14727. */
  14728. updateFunction: (particles: Particle[]) => void;
  14729. private _emitterWorldMatrix;
  14730. /**
  14731. * This function can be defined to specify initial direction for every new particle.
  14732. * It by default use the emitterType defined function
  14733. */
  14734. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14735. /**
  14736. * This function can be defined to specify initial position for every new particle.
  14737. * It by default use the emitterType defined function
  14738. */
  14739. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14740. /**
  14741. * @hidden
  14742. */
  14743. _inheritedVelocityOffset: Vector3;
  14744. /**
  14745. * An event triggered when the system is disposed
  14746. */
  14747. onDisposeObservable: Observable<ParticleSystem>;
  14748. private _onDisposeObserver;
  14749. /**
  14750. * Sets a callback that will be triggered when the system is disposed
  14751. */
  14752. onDispose: () => void;
  14753. private _particles;
  14754. private _epsilon;
  14755. private _capacity;
  14756. private _stockParticles;
  14757. private _newPartsExcess;
  14758. private _vertexData;
  14759. private _vertexBuffer;
  14760. private _vertexBuffers;
  14761. private _spriteBuffer;
  14762. private _indexBuffer;
  14763. private _effect;
  14764. private _customEffect;
  14765. private _cachedDefines;
  14766. private _scaledColorStep;
  14767. private _colorDiff;
  14768. private _scaledDirection;
  14769. private _scaledGravity;
  14770. private _currentRenderId;
  14771. private _alive;
  14772. private _useInstancing;
  14773. private _started;
  14774. private _stopped;
  14775. private _actualFrame;
  14776. private _scaledUpdateSpeed;
  14777. private _vertexBufferSize;
  14778. /** @hidden */
  14779. _currentEmitRateGradient: Nullable<FactorGradient>;
  14780. /** @hidden */
  14781. _currentEmitRate1: number;
  14782. /** @hidden */
  14783. _currentEmitRate2: number;
  14784. /** @hidden */
  14785. _currentStartSizeGradient: Nullable<FactorGradient>;
  14786. /** @hidden */
  14787. _currentStartSize1: number;
  14788. /** @hidden */
  14789. _currentStartSize2: number;
  14790. private readonly _rawTextureWidth;
  14791. private _rampGradientsTexture;
  14792. private _useRampGradients;
  14793. /** Gets or sets a boolean indicating that ramp gradients must be used
  14794. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14795. */
  14796. useRampGradients: boolean;
  14797. /**
  14798. * 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.
  14799. * 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: [])
  14800. */
  14801. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14802. private _subEmitters;
  14803. /**
  14804. * @hidden
  14805. * If the particle systems emitter should be disposed when the particle system is disposed
  14806. */
  14807. _disposeEmitterOnDispose: boolean;
  14808. /**
  14809. * The current active Sub-systems, this property is used by the root particle system only.
  14810. */
  14811. activeSubSystems: Array<ParticleSystem>;
  14812. private _rootParticleSystem;
  14813. /**
  14814. * Gets the current list of active particles
  14815. */
  14816. readonly particles: Particle[];
  14817. /**
  14818. * Returns the string "ParticleSystem"
  14819. * @returns a string containing the class name
  14820. */
  14821. getClassName(): string;
  14822. /**
  14823. * Instantiates a particle system.
  14824. * 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.
  14825. * @param name The name of the particle system
  14826. * @param capacity The max number of particles alive at the same time
  14827. * @param scene The scene the particle system belongs to
  14828. * @param customEffect a custom effect used to change the way particles are rendered by default
  14829. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14830. * @param epsilon Offset used to render the particles
  14831. */
  14832. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14833. private _addFactorGradient;
  14834. private _removeFactorGradient;
  14835. /**
  14836. * Adds a new life time gradient
  14837. * @param gradient defines the gradient to use (between 0 and 1)
  14838. * @param factor defines the life time factor to affect to the specified gradient
  14839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14840. * @returns the current particle system
  14841. */
  14842. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14843. /**
  14844. * Remove a specific life time gradient
  14845. * @param gradient defines the gradient to remove
  14846. * @returns the current particle system
  14847. */
  14848. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14849. /**
  14850. * Adds a new size gradient
  14851. * @param gradient defines the gradient to use (between 0 and 1)
  14852. * @param factor defines the size factor to affect to the specified gradient
  14853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14854. * @returns the current particle system
  14855. */
  14856. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14857. /**
  14858. * Remove a specific size gradient
  14859. * @param gradient defines the gradient to remove
  14860. * @returns the current particle system
  14861. */
  14862. removeSizeGradient(gradient: number): IParticleSystem;
  14863. /**
  14864. * Adds a new color remap gradient
  14865. * @param gradient defines the gradient to use (between 0 and 1)
  14866. * @param min defines the color remap minimal range
  14867. * @param max defines the color remap maximal range
  14868. * @returns the current particle system
  14869. */
  14870. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14871. /**
  14872. * Remove a specific color remap gradient
  14873. * @param gradient defines the gradient to remove
  14874. * @returns the current particle system
  14875. */
  14876. removeColorRemapGradient(gradient: number): IParticleSystem;
  14877. /**
  14878. * Adds a new alpha remap gradient
  14879. * @param gradient defines the gradient to use (between 0 and 1)
  14880. * @param min defines the alpha remap minimal range
  14881. * @param max defines the alpha remap maximal range
  14882. * @returns the current particle system
  14883. */
  14884. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14885. /**
  14886. * Remove a specific alpha remap gradient
  14887. * @param gradient defines the gradient to remove
  14888. * @returns the current particle system
  14889. */
  14890. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14891. /**
  14892. * Adds a new angular speed gradient
  14893. * @param gradient defines the gradient to use (between 0 and 1)
  14894. * @param factor defines the angular speed to affect to the specified gradient
  14895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14896. * @returns the current particle system
  14897. */
  14898. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14899. /**
  14900. * Remove a specific angular speed gradient
  14901. * @param gradient defines the gradient to remove
  14902. * @returns the current particle system
  14903. */
  14904. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14905. /**
  14906. * Adds a new velocity gradient
  14907. * @param gradient defines the gradient to use (between 0 and 1)
  14908. * @param factor defines the velocity to affect to the specified gradient
  14909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14910. * @returns the current particle system
  14911. */
  14912. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14913. /**
  14914. * Remove a specific velocity gradient
  14915. * @param gradient defines the gradient to remove
  14916. * @returns the current particle system
  14917. */
  14918. removeVelocityGradient(gradient: number): IParticleSystem;
  14919. /**
  14920. * Adds a new limit velocity gradient
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the limit velocity value to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific limit velocity gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Adds a new drag gradient
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param factor defines the drag value to affect to the specified gradient
  14937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14938. * @returns the current particle system
  14939. */
  14940. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14941. /**
  14942. * Remove a specific drag gradient
  14943. * @param gradient defines the gradient to remove
  14944. * @returns the current particle system
  14945. */
  14946. removeDragGradient(gradient: number): IParticleSystem;
  14947. /**
  14948. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14949. * @param gradient defines the gradient to use (between 0 and 1)
  14950. * @param factor defines the emit rate value to affect to the specified gradient
  14951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14952. * @returns the current particle system
  14953. */
  14954. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14955. /**
  14956. * Remove a specific emit rate gradient
  14957. * @param gradient defines the gradient to remove
  14958. * @returns the current particle system
  14959. */
  14960. removeEmitRateGradient(gradient: number): IParticleSystem;
  14961. /**
  14962. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14963. * @param gradient defines the gradient to use (between 0 and 1)
  14964. * @param factor defines the start size value to affect to the specified gradient
  14965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14966. * @returns the current particle system
  14967. */
  14968. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14969. /**
  14970. * Remove a specific start size gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeStartSizeGradient(gradient: number): IParticleSystem;
  14975. private _createRampGradientTexture;
  14976. /**
  14977. * Gets the current list of ramp gradients.
  14978. * You must use addRampGradient and removeRampGradient to udpate this list
  14979. * @returns the list of ramp gradients
  14980. */
  14981. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14982. /**
  14983. * Adds a new ramp gradient used to remap particle colors
  14984. * @param gradient defines the gradient to use (between 0 and 1)
  14985. * @param color defines the color to affect to the specified gradient
  14986. * @returns the current particle system
  14987. */
  14988. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14989. /**
  14990. * Remove a specific ramp gradient
  14991. * @param gradient defines the gradient to remove
  14992. * @returns the current particle system
  14993. */
  14994. removeRampGradient(gradient: number): ParticleSystem;
  14995. /**
  14996. * Adds a new color gradient
  14997. * @param gradient defines the gradient to use (between 0 and 1)
  14998. * @param color1 defines the color to affect to the specified gradient
  14999. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15000. * @returns this particle system
  15001. */
  15002. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15003. /**
  15004. * Remove a specific color gradient
  15005. * @param gradient defines the gradient to remove
  15006. * @returns this particle system
  15007. */
  15008. removeColorGradient(gradient: number): IParticleSystem;
  15009. private _fetchR;
  15010. protected _reset(): void;
  15011. private _resetEffect;
  15012. private _createVertexBuffers;
  15013. private _createIndexBuffer;
  15014. /**
  15015. * Gets the maximum number of particles active at the same time.
  15016. * @returns The max number of active particles.
  15017. */
  15018. getCapacity(): number;
  15019. /**
  15020. * Gets whether there are still active particles in the system.
  15021. * @returns True if it is alive, otherwise false.
  15022. */
  15023. isAlive(): boolean;
  15024. /**
  15025. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15026. * @returns True if it has been started, otherwise false.
  15027. */
  15028. isStarted(): boolean;
  15029. private _prepareSubEmitterInternalArray;
  15030. /**
  15031. * Starts the particle system and begins to emit
  15032. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15033. */
  15034. start(delay?: number): void;
  15035. /**
  15036. * Stops the particle system.
  15037. * @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.
  15038. */
  15039. stop(stopSubEmitters?: boolean): void;
  15040. /**
  15041. * Remove all active particles
  15042. */
  15043. reset(): void;
  15044. /**
  15045. * @hidden (for internal use only)
  15046. */
  15047. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15048. /**
  15049. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15050. * Its lifetime will start back at 0.
  15051. */
  15052. recycleParticle: (particle: Particle) => void;
  15053. private _stopSubEmitters;
  15054. private _createParticle;
  15055. private _removeFromRoot;
  15056. private _emitFromParticle;
  15057. private _update;
  15058. /** @hidden */
  15059. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15060. /** @hidden */
  15061. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15062. /** @hidden */
  15063. private _getEffect;
  15064. /**
  15065. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15066. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15067. */
  15068. animate(preWarmOnly?: boolean): void;
  15069. private _appendParticleVertices;
  15070. /**
  15071. * Rebuilds the particle system.
  15072. */
  15073. rebuild(): void;
  15074. /**
  15075. * Is this system ready to be used/rendered
  15076. * @return true if the system is ready
  15077. */
  15078. isReady(): boolean;
  15079. private _render;
  15080. /**
  15081. * Renders the particle system in its current state.
  15082. * @returns the current number of particles
  15083. */
  15084. render(): number;
  15085. /**
  15086. * Disposes the particle system and free the associated resources
  15087. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15088. */
  15089. dispose(disposeTexture?: boolean): void;
  15090. /**
  15091. * Clones the particle system.
  15092. * @param name The name of the cloned object
  15093. * @param newEmitter The new emitter to use
  15094. * @returns the cloned particle system
  15095. */
  15096. clone(name: string, newEmitter: any): ParticleSystem;
  15097. /**
  15098. * Serializes the particle system to a JSON object.
  15099. * @returns the JSON object
  15100. */
  15101. serialize(): any;
  15102. /** @hidden */
  15103. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15104. /** @hidden */
  15105. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15106. /**
  15107. * Parses a JSON object to create a particle system.
  15108. * @param parsedParticleSystem The JSON object to parse
  15109. * @param scene The scene to create the particle system in
  15110. * @param rootUrl The root url to use to load external dependencies like texture
  15111. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15112. * @returns the Parsed particle system
  15113. */
  15114. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15115. }
  15116. }
  15117. declare module "babylonjs/Particles/particle" {
  15118. import { Nullable } from "babylonjs/types";
  15119. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15120. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15121. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15122. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15123. /**
  15124. * A particle represents one of the element emitted by a particle system.
  15125. * This is mainly define by its coordinates, direction, velocity and age.
  15126. */
  15127. export class Particle {
  15128. /**
  15129. * The particle system the particle belongs to.
  15130. */
  15131. particleSystem: ParticleSystem;
  15132. private static _Count;
  15133. /**
  15134. * Unique ID of the particle
  15135. */
  15136. id: number;
  15137. /**
  15138. * The world position of the particle in the scene.
  15139. */
  15140. position: Vector3;
  15141. /**
  15142. * The world direction of the particle in the scene.
  15143. */
  15144. direction: Vector3;
  15145. /**
  15146. * The color of the particle.
  15147. */
  15148. color: Color4;
  15149. /**
  15150. * The color change of the particle per step.
  15151. */
  15152. colorStep: Color4;
  15153. /**
  15154. * Defines how long will the life of the particle be.
  15155. */
  15156. lifeTime: number;
  15157. /**
  15158. * The current age of the particle.
  15159. */
  15160. age: number;
  15161. /**
  15162. * The current size of the particle.
  15163. */
  15164. size: number;
  15165. /**
  15166. * The current scale of the particle.
  15167. */
  15168. scale: Vector2;
  15169. /**
  15170. * The current angle of the particle.
  15171. */
  15172. angle: number;
  15173. /**
  15174. * Defines how fast is the angle changing.
  15175. */
  15176. angularSpeed: number;
  15177. /**
  15178. * Defines the cell index used by the particle to be rendered from a sprite.
  15179. */
  15180. cellIndex: number;
  15181. /**
  15182. * The information required to support color remapping
  15183. */
  15184. remapData: Vector4;
  15185. /** @hidden */
  15186. _randomCellOffset?: number;
  15187. /** @hidden */
  15188. _initialDirection: Nullable<Vector3>;
  15189. /** @hidden */
  15190. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15191. /** @hidden */
  15192. _initialStartSpriteCellID: number;
  15193. /** @hidden */
  15194. _initialEndSpriteCellID: number;
  15195. /** @hidden */
  15196. _currentColorGradient: Nullable<ColorGradient>;
  15197. /** @hidden */
  15198. _currentColor1: Color4;
  15199. /** @hidden */
  15200. _currentColor2: Color4;
  15201. /** @hidden */
  15202. _currentSizeGradient: Nullable<FactorGradient>;
  15203. /** @hidden */
  15204. _currentSize1: number;
  15205. /** @hidden */
  15206. _currentSize2: number;
  15207. /** @hidden */
  15208. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15209. /** @hidden */
  15210. _currentAngularSpeed1: number;
  15211. /** @hidden */
  15212. _currentAngularSpeed2: number;
  15213. /** @hidden */
  15214. _currentVelocityGradient: Nullable<FactorGradient>;
  15215. /** @hidden */
  15216. _currentVelocity1: number;
  15217. /** @hidden */
  15218. _currentVelocity2: number;
  15219. /** @hidden */
  15220. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15221. /** @hidden */
  15222. _currentLimitVelocity1: number;
  15223. /** @hidden */
  15224. _currentLimitVelocity2: number;
  15225. /** @hidden */
  15226. _currentDragGradient: Nullable<FactorGradient>;
  15227. /** @hidden */
  15228. _currentDrag1: number;
  15229. /** @hidden */
  15230. _currentDrag2: number;
  15231. /** @hidden */
  15232. _randomNoiseCoordinates1: Vector3;
  15233. /** @hidden */
  15234. _randomNoiseCoordinates2: Vector3;
  15235. /**
  15236. * Creates a new instance Particle
  15237. * @param particleSystem the particle system the particle belongs to
  15238. */
  15239. constructor(
  15240. /**
  15241. * The particle system the particle belongs to.
  15242. */
  15243. particleSystem: ParticleSystem);
  15244. private updateCellInfoFromSystem;
  15245. /**
  15246. * Defines how the sprite cell index is updated for the particle
  15247. */
  15248. updateCellIndex(): void;
  15249. /** @hidden */
  15250. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15251. /** @hidden */
  15252. _inheritParticleInfoToSubEmitters(): void;
  15253. /** @hidden */
  15254. _reset(): void;
  15255. /**
  15256. * Copy the properties of particle to another one.
  15257. * @param other the particle to copy the information to.
  15258. */
  15259. copyTo(other: Particle): void;
  15260. }
  15261. }
  15262. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15263. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15264. import { Effect } from "babylonjs/Materials/effect";
  15265. import { Particle } from "babylonjs/Particles/particle";
  15266. /**
  15267. * Particle emitter represents a volume emitting particles.
  15268. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15269. */
  15270. export interface IParticleEmitterType {
  15271. /**
  15272. * Called by the particle System when the direction is computed for the created particle.
  15273. * @param worldMatrix is the world matrix of the particle system
  15274. * @param directionToUpdate is the direction vector to update with the result
  15275. * @param particle is the particle we are computed the direction for
  15276. */
  15277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15278. /**
  15279. * Called by the particle System when the position is computed for the created particle.
  15280. * @param worldMatrix is the world matrix of the particle system
  15281. * @param positionToUpdate is the position vector to update with the result
  15282. * @param particle is the particle we are computed the position for
  15283. */
  15284. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15285. /**
  15286. * Clones the current emitter and returns a copy of it
  15287. * @returns the new emitter
  15288. */
  15289. clone(): IParticleEmitterType;
  15290. /**
  15291. * Called by the GPUParticleSystem to setup the update shader
  15292. * @param effect defines the update shader
  15293. */
  15294. applyToShader(effect: Effect): void;
  15295. /**
  15296. * Returns a string to use to update the GPU particles update shader
  15297. * @returns the effect defines string
  15298. */
  15299. getEffectDefines(): string;
  15300. /**
  15301. * Returns a string representing the class name
  15302. * @returns a string containing the class name
  15303. */
  15304. getClassName(): string;
  15305. /**
  15306. * Serializes the particle system to a JSON object.
  15307. * @returns the JSON object
  15308. */
  15309. serialize(): any;
  15310. /**
  15311. * Parse properties from a JSON object
  15312. * @param serializationObject defines the JSON object
  15313. */
  15314. parse(serializationObject: any): void;
  15315. }
  15316. }
  15317. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15318. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15319. import { Effect } from "babylonjs/Materials/effect";
  15320. import { Particle } from "babylonjs/Particles/particle";
  15321. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15322. /**
  15323. * Particle emitter emitting particles from the inside of a box.
  15324. * It emits the particles randomly between 2 given directions.
  15325. */
  15326. export class BoxParticleEmitter implements IParticleEmitterType {
  15327. /**
  15328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15329. */
  15330. direction1: Vector3;
  15331. /**
  15332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15333. */
  15334. direction2: Vector3;
  15335. /**
  15336. * 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.
  15337. */
  15338. minEmitBox: Vector3;
  15339. /**
  15340. * 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.
  15341. */
  15342. maxEmitBox: Vector3;
  15343. /**
  15344. * Creates a new instance BoxParticleEmitter
  15345. */
  15346. constructor();
  15347. /**
  15348. * Called by the particle System when the direction is computed for the created particle.
  15349. * @param worldMatrix is the world matrix of the particle system
  15350. * @param directionToUpdate is the direction vector to update with the result
  15351. * @param particle is the particle we are computed the direction for
  15352. */
  15353. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15354. /**
  15355. * Called by the particle System when the position is computed for the created particle.
  15356. * @param worldMatrix is the world matrix of the particle system
  15357. * @param positionToUpdate is the position vector to update with the result
  15358. * @param particle is the particle we are computed the position for
  15359. */
  15360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15361. /**
  15362. * Clones the current emitter and returns a copy of it
  15363. * @returns the new emitter
  15364. */
  15365. clone(): BoxParticleEmitter;
  15366. /**
  15367. * Called by the GPUParticleSystem to setup the update shader
  15368. * @param effect defines the update shader
  15369. */
  15370. applyToShader(effect: Effect): void;
  15371. /**
  15372. * Returns a string to use to update the GPU particles update shader
  15373. * @returns a string containng the defines string
  15374. */
  15375. getEffectDefines(): string;
  15376. /**
  15377. * Returns the string "BoxParticleEmitter"
  15378. * @returns a string containing the class name
  15379. */
  15380. getClassName(): string;
  15381. /**
  15382. * Serializes the particle system to a JSON object.
  15383. * @returns the JSON object
  15384. */
  15385. serialize(): any;
  15386. /**
  15387. * Parse properties from a JSON object
  15388. * @param serializationObject defines the JSON object
  15389. */
  15390. parse(serializationObject: any): void;
  15391. }
  15392. }
  15393. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15394. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15395. import { Effect } from "babylonjs/Materials/effect";
  15396. import { Particle } from "babylonjs/Particles/particle";
  15397. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15398. /**
  15399. * Particle emitter emitting particles from the inside of a cone.
  15400. * It emits the particles alongside the cone volume from the base to the particle.
  15401. * The emission direction might be randomized.
  15402. */
  15403. export class ConeParticleEmitter implements IParticleEmitterType {
  15404. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15405. directionRandomizer: number;
  15406. private _radius;
  15407. private _angle;
  15408. private _height;
  15409. /**
  15410. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15411. */
  15412. radiusRange: number;
  15413. /**
  15414. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15415. */
  15416. heightRange: number;
  15417. /**
  15418. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15419. */
  15420. emitFromSpawnPointOnly: boolean;
  15421. /**
  15422. * Gets or sets the radius of the emission cone
  15423. */
  15424. radius: number;
  15425. /**
  15426. * Gets or sets the angle of the emission cone
  15427. */
  15428. angle: number;
  15429. private _buildHeight;
  15430. /**
  15431. * Creates a new instance ConeParticleEmitter
  15432. * @param radius the radius of the emission cone (1 by default)
  15433. * @param angle the cone base angle (PI by default)
  15434. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15435. */
  15436. constructor(radius?: number, angle?: number,
  15437. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15438. directionRandomizer?: number);
  15439. /**
  15440. * Called by the particle System when the direction is computed for the created particle.
  15441. * @param worldMatrix is the world matrix of the particle system
  15442. * @param directionToUpdate is the direction vector to update with the result
  15443. * @param particle is the particle we are computed the direction for
  15444. */
  15445. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15446. /**
  15447. * Called by the particle System when the position is computed for the created particle.
  15448. * @param worldMatrix is the world matrix of the particle system
  15449. * @param positionToUpdate is the position vector to update with the result
  15450. * @param particle is the particle we are computed the position for
  15451. */
  15452. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15453. /**
  15454. * Clones the current emitter and returns a copy of it
  15455. * @returns the new emitter
  15456. */
  15457. clone(): ConeParticleEmitter;
  15458. /**
  15459. * Called by the GPUParticleSystem to setup the update shader
  15460. * @param effect defines the update shader
  15461. */
  15462. applyToShader(effect: Effect): void;
  15463. /**
  15464. * Returns a string to use to update the GPU particles update shader
  15465. * @returns a string containng the defines string
  15466. */
  15467. getEffectDefines(): string;
  15468. /**
  15469. * Returns the string "ConeParticleEmitter"
  15470. * @returns a string containing the class name
  15471. */
  15472. getClassName(): string;
  15473. /**
  15474. * Serializes the particle system to a JSON object.
  15475. * @returns the JSON object
  15476. */
  15477. serialize(): any;
  15478. /**
  15479. * Parse properties from a JSON object
  15480. * @param serializationObject defines the JSON object
  15481. */
  15482. parse(serializationObject: any): void;
  15483. }
  15484. }
  15485. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15486. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15487. import { Effect } from "babylonjs/Materials/effect";
  15488. import { Particle } from "babylonjs/Particles/particle";
  15489. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15490. /**
  15491. * Particle emitter emitting particles from the inside of a cylinder.
  15492. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15493. */
  15494. export class CylinderParticleEmitter implements IParticleEmitterType {
  15495. /**
  15496. * The radius of the emission cylinder.
  15497. */
  15498. radius: number;
  15499. /**
  15500. * The height of the emission cylinder.
  15501. */
  15502. height: number;
  15503. /**
  15504. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15505. */
  15506. radiusRange: number;
  15507. /**
  15508. * How much to randomize the particle direction [0-1].
  15509. */
  15510. directionRandomizer: number;
  15511. /**
  15512. * Creates a new instance CylinderParticleEmitter
  15513. * @param radius the radius of the emission cylinder (1 by default)
  15514. * @param height the height of the emission cylinder (1 by default)
  15515. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15516. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15517. */
  15518. constructor(
  15519. /**
  15520. * The radius of the emission cylinder.
  15521. */
  15522. radius?: number,
  15523. /**
  15524. * The height of the emission cylinder.
  15525. */
  15526. height?: number,
  15527. /**
  15528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15529. */
  15530. radiusRange?: number,
  15531. /**
  15532. * How much to randomize the particle direction [0-1].
  15533. */
  15534. directionRandomizer?: number);
  15535. /**
  15536. * Called by the particle System when the direction is computed for the created particle.
  15537. * @param worldMatrix is the world matrix of the particle system
  15538. * @param directionToUpdate is the direction vector to update with the result
  15539. * @param particle is the particle we are computed the direction for
  15540. */
  15541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15542. /**
  15543. * Called by the particle System when the position is computed for the created particle.
  15544. * @param worldMatrix is the world matrix of the particle system
  15545. * @param positionToUpdate is the position vector to update with the result
  15546. * @param particle is the particle we are computed the position for
  15547. */
  15548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15549. /**
  15550. * Clones the current emitter and returns a copy of it
  15551. * @returns the new emitter
  15552. */
  15553. clone(): CylinderParticleEmitter;
  15554. /**
  15555. * Called by the GPUParticleSystem to setup the update shader
  15556. * @param effect defines the update shader
  15557. */
  15558. applyToShader(effect: Effect): void;
  15559. /**
  15560. * Returns a string to use to update the GPU particles update shader
  15561. * @returns a string containng the defines string
  15562. */
  15563. getEffectDefines(): string;
  15564. /**
  15565. * Returns the string "CylinderParticleEmitter"
  15566. * @returns a string containing the class name
  15567. */
  15568. getClassName(): string;
  15569. /**
  15570. * Serializes the particle system to a JSON object.
  15571. * @returns the JSON object
  15572. */
  15573. serialize(): any;
  15574. /**
  15575. * Parse properties from a JSON object
  15576. * @param serializationObject defines the JSON object
  15577. */
  15578. parse(serializationObject: any): void;
  15579. }
  15580. /**
  15581. * Particle emitter emitting particles from the inside of a cylinder.
  15582. * It emits the particles randomly between two vectors.
  15583. */
  15584. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15585. /**
  15586. * The min limit of the emission direction.
  15587. */
  15588. direction1: Vector3;
  15589. /**
  15590. * The max limit of the emission direction.
  15591. */
  15592. direction2: Vector3;
  15593. /**
  15594. * Creates a new instance CylinderDirectedParticleEmitter
  15595. * @param radius the radius of the emission cylinder (1 by default)
  15596. * @param height the height of the emission cylinder (1 by default)
  15597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15598. * @param direction1 the min limit of the emission direction (up vector by default)
  15599. * @param direction2 the max limit of the emission direction (up vector by default)
  15600. */
  15601. constructor(radius?: number, height?: number, radiusRange?: number,
  15602. /**
  15603. * The min limit of the emission direction.
  15604. */
  15605. direction1?: Vector3,
  15606. /**
  15607. * The max limit of the emission direction.
  15608. */
  15609. direction2?: Vector3);
  15610. /**
  15611. * Called by the particle System when the direction is computed for the created particle.
  15612. * @param worldMatrix is the world matrix of the particle system
  15613. * @param directionToUpdate is the direction vector to update with the result
  15614. * @param particle is the particle we are computed the direction for
  15615. */
  15616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15617. /**
  15618. * Clones the current emitter and returns a copy of it
  15619. * @returns the new emitter
  15620. */
  15621. clone(): CylinderDirectedParticleEmitter;
  15622. /**
  15623. * Called by the GPUParticleSystem to setup the update shader
  15624. * @param effect defines the update shader
  15625. */
  15626. applyToShader(effect: Effect): void;
  15627. /**
  15628. * Returns a string to use to update the GPU particles update shader
  15629. * @returns a string containng the defines string
  15630. */
  15631. getEffectDefines(): string;
  15632. /**
  15633. * Returns the string "CylinderDirectedParticleEmitter"
  15634. * @returns a string containing the class name
  15635. */
  15636. getClassName(): string;
  15637. /**
  15638. * Serializes the particle system to a JSON object.
  15639. * @returns the JSON object
  15640. */
  15641. serialize(): any;
  15642. /**
  15643. * Parse properties from a JSON object
  15644. * @param serializationObject defines the JSON object
  15645. */
  15646. parse(serializationObject: any): void;
  15647. }
  15648. }
  15649. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15650. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15651. import { Effect } from "babylonjs/Materials/effect";
  15652. import { Particle } from "babylonjs/Particles/particle";
  15653. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15654. /**
  15655. * Particle emitter emitting particles from the inside of a hemisphere.
  15656. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15657. */
  15658. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15659. /**
  15660. * The radius of the emission hemisphere.
  15661. */
  15662. radius: number;
  15663. /**
  15664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15665. */
  15666. radiusRange: number;
  15667. /**
  15668. * How much to randomize the particle direction [0-1].
  15669. */
  15670. directionRandomizer: number;
  15671. /**
  15672. * Creates a new instance HemisphericParticleEmitter
  15673. * @param radius the radius of the emission hemisphere (1 by default)
  15674. * @param radiusRange the range of the emission hemisphere [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 hemisphere.
  15680. */
  15681. radius?: number,
  15682. /**
  15683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15684. */
  15685. radiusRange?: number,
  15686. /**
  15687. * How much to randomize the particle direction [0-1].
  15688. */
  15689. directionRandomizer?: number);
  15690. /**
  15691. * Called by the particle System when the direction is computed for the created particle.
  15692. * @param worldMatrix is the world matrix of the particle system
  15693. * @param directionToUpdate is the direction vector to update with the result
  15694. * @param particle is the particle we are computed the direction for
  15695. */
  15696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15697. /**
  15698. * Called by the particle System when the position is computed for the created particle.
  15699. * @param worldMatrix is the world matrix of the particle system
  15700. * @param positionToUpdate is the position vector to update with the result
  15701. * @param particle is the particle we are computed the position for
  15702. */
  15703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15704. /**
  15705. * Clones the current emitter and returns a copy of it
  15706. * @returns the new emitter
  15707. */
  15708. clone(): HemisphericParticleEmitter;
  15709. /**
  15710. * Called by the GPUParticleSystem to setup the update shader
  15711. * @param effect defines the update shader
  15712. */
  15713. applyToShader(effect: Effect): void;
  15714. /**
  15715. * Returns a string to use to update the GPU particles update shader
  15716. * @returns a string containng the defines string
  15717. */
  15718. getEffectDefines(): string;
  15719. /**
  15720. * Returns the string "HemisphericParticleEmitter"
  15721. * @returns a string containing the class name
  15722. */
  15723. getClassName(): string;
  15724. /**
  15725. * Serializes the particle system to a JSON object.
  15726. * @returns the JSON object
  15727. */
  15728. serialize(): any;
  15729. /**
  15730. * Parse properties from a JSON object
  15731. * @param serializationObject defines the JSON object
  15732. */
  15733. parse(serializationObject: any): void;
  15734. }
  15735. }
  15736. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15737. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15738. import { Effect } from "babylonjs/Materials/effect";
  15739. import { Particle } from "babylonjs/Particles/particle";
  15740. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15741. /**
  15742. * Particle emitter emitting particles from a point.
  15743. * It emits the particles randomly between 2 given directions.
  15744. */
  15745. export class PointParticleEmitter implements IParticleEmitterType {
  15746. /**
  15747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15748. */
  15749. direction1: Vector3;
  15750. /**
  15751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15752. */
  15753. direction2: Vector3;
  15754. /**
  15755. * Creates a new instance PointParticleEmitter
  15756. */
  15757. constructor();
  15758. /**
  15759. * Called by the particle System when the direction is computed for the created particle.
  15760. * @param worldMatrix is the world matrix of the particle system
  15761. * @param directionToUpdate is the direction vector to update with the result
  15762. * @param particle is the particle we are computed the direction for
  15763. */
  15764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15765. /**
  15766. * Called by the particle System when the position is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param positionToUpdate is the position vector to update with the result
  15769. * @param particle is the particle we are computed the position for
  15770. */
  15771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Clones the current emitter and returns a copy of it
  15774. * @returns the new emitter
  15775. */
  15776. clone(): PointParticleEmitter;
  15777. /**
  15778. * Called by the GPUParticleSystem to setup the update shader
  15779. * @param effect defines the update shader
  15780. */
  15781. applyToShader(effect: Effect): void;
  15782. /**
  15783. * Returns a string to use to update the GPU particles update shader
  15784. * @returns a string containng the defines string
  15785. */
  15786. getEffectDefines(): string;
  15787. /**
  15788. * Returns the string "PointParticleEmitter"
  15789. * @returns a string containing the class name
  15790. */
  15791. getClassName(): string;
  15792. /**
  15793. * Serializes the particle system to a JSON object.
  15794. * @returns the JSON object
  15795. */
  15796. serialize(): any;
  15797. /**
  15798. * Parse properties from a JSON object
  15799. * @param serializationObject defines the JSON object
  15800. */
  15801. parse(serializationObject: any): void;
  15802. }
  15803. }
  15804. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15805. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15806. import { Effect } from "babylonjs/Materials/effect";
  15807. import { Particle } from "babylonjs/Particles/particle";
  15808. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15809. /**
  15810. * Particle emitter emitting particles from the inside of a sphere.
  15811. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15812. */
  15813. export class SphereParticleEmitter implements IParticleEmitterType {
  15814. /**
  15815. * The radius of the emission sphere.
  15816. */
  15817. radius: number;
  15818. /**
  15819. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15820. */
  15821. radiusRange: number;
  15822. /**
  15823. * How much to randomize the particle direction [0-1].
  15824. */
  15825. directionRandomizer: number;
  15826. /**
  15827. * Creates a new instance SphereParticleEmitter
  15828. * @param radius the radius of the emission sphere (1 by default)
  15829. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15830. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15831. */
  15832. constructor(
  15833. /**
  15834. * The radius of the emission sphere.
  15835. */
  15836. radius?: number,
  15837. /**
  15838. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15839. */
  15840. radiusRange?: number,
  15841. /**
  15842. * How much to randomize the particle direction [0-1].
  15843. */
  15844. directionRandomizer?: number);
  15845. /**
  15846. * Called by the particle System when the direction is computed for the created particle.
  15847. * @param worldMatrix is the world matrix of the particle system
  15848. * @param directionToUpdate is the direction vector to update with the result
  15849. * @param particle is the particle we are computed the direction for
  15850. */
  15851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15852. /**
  15853. * Called by the particle System when the position is computed for the created particle.
  15854. * @param worldMatrix is the world matrix of the particle system
  15855. * @param positionToUpdate is the position vector to update with the result
  15856. * @param particle is the particle we are computed the position for
  15857. */
  15858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15859. /**
  15860. * Clones the current emitter and returns a copy of it
  15861. * @returns the new emitter
  15862. */
  15863. clone(): SphereParticleEmitter;
  15864. /**
  15865. * Called by the GPUParticleSystem to setup the update shader
  15866. * @param effect defines the update shader
  15867. */
  15868. applyToShader(effect: Effect): void;
  15869. /**
  15870. * Returns a string to use to update the GPU particles update shader
  15871. * @returns a string containng the defines string
  15872. */
  15873. getEffectDefines(): string;
  15874. /**
  15875. * Returns the string "SphereParticleEmitter"
  15876. * @returns a string containing the class name
  15877. */
  15878. getClassName(): string;
  15879. /**
  15880. * Serializes the particle system to a JSON object.
  15881. * @returns the JSON object
  15882. */
  15883. serialize(): any;
  15884. /**
  15885. * Parse properties from a JSON object
  15886. * @param serializationObject defines the JSON object
  15887. */
  15888. parse(serializationObject: any): void;
  15889. }
  15890. /**
  15891. * Particle emitter emitting particles from the inside of a sphere.
  15892. * It emits the particles randomly between two vectors.
  15893. */
  15894. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15895. /**
  15896. * The min limit of the emission direction.
  15897. */
  15898. direction1: Vector3;
  15899. /**
  15900. * The max limit of the emission direction.
  15901. */
  15902. direction2: Vector3;
  15903. /**
  15904. * Creates a new instance SphereDirectedParticleEmitter
  15905. * @param radius the radius of the emission sphere (1 by default)
  15906. * @param direction1 the min limit of the emission direction (up vector by default)
  15907. * @param direction2 the max limit of the emission direction (up vector by default)
  15908. */
  15909. constructor(radius?: number,
  15910. /**
  15911. * The min limit of the emission direction.
  15912. */
  15913. direction1?: Vector3,
  15914. /**
  15915. * The max limit of the emission direction.
  15916. */
  15917. direction2?: Vector3);
  15918. /**
  15919. * Called by the particle System when the direction is computed for the created particle.
  15920. * @param worldMatrix is the world matrix of the particle system
  15921. * @param directionToUpdate is the direction vector to update with the result
  15922. * @param particle is the particle we are computed the direction for
  15923. */
  15924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15925. /**
  15926. * Clones the current emitter and returns a copy of it
  15927. * @returns the new emitter
  15928. */
  15929. clone(): SphereDirectedParticleEmitter;
  15930. /**
  15931. * Called by the GPUParticleSystem to setup the update shader
  15932. * @param effect defines the update shader
  15933. */
  15934. applyToShader(effect: Effect): void;
  15935. /**
  15936. * Returns a string to use to update the GPU particles update shader
  15937. * @returns a string containng the defines string
  15938. */
  15939. getEffectDefines(): string;
  15940. /**
  15941. * Returns the string "SphereDirectedParticleEmitter"
  15942. * @returns a string containing the class name
  15943. */
  15944. getClassName(): string;
  15945. /**
  15946. * Serializes the particle system to a JSON object.
  15947. * @returns the JSON object
  15948. */
  15949. serialize(): any;
  15950. /**
  15951. * Parse properties from a JSON object
  15952. * @param serializationObject defines the JSON object
  15953. */
  15954. parse(serializationObject: any): void;
  15955. }
  15956. }
  15957. declare module "babylonjs/Particles/EmitterTypes/index" {
  15958. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15959. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15960. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15961. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15962. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15963. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15964. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15965. }
  15966. declare module "babylonjs/Particles/IParticleSystem" {
  15967. import { Nullable } from "babylonjs/types";
  15968. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15971. import { Texture } from "babylonjs/Materials/Textures/texture";
  15972. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15973. import { Scene } from "babylonjs/scene";
  15974. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15975. import { Animation } from "babylonjs/Animations/animation";
  15976. /**
  15977. * Interface representing a particle system in Babylon.js.
  15978. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15979. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15980. */
  15981. export interface IParticleSystem {
  15982. /**
  15983. * List of animations used by the particle system.
  15984. */
  15985. animations: Animation[];
  15986. /**
  15987. * The id of the Particle system.
  15988. */
  15989. id: string;
  15990. /**
  15991. * The name of the Particle system.
  15992. */
  15993. name: string;
  15994. /**
  15995. * The emitter represents the Mesh or position we are attaching the particle system to.
  15996. */
  15997. emitter: Nullable<AbstractMesh | Vector3>;
  15998. /**
  15999. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16000. */
  16001. isBillboardBased: boolean;
  16002. /**
  16003. * The rendering group used by the Particle system to chose when to render.
  16004. */
  16005. renderingGroupId: number;
  16006. /**
  16007. * The layer mask we are rendering the particles through.
  16008. */
  16009. layerMask: number;
  16010. /**
  16011. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16012. */
  16013. updateSpeed: number;
  16014. /**
  16015. * The amount of time the particle system is running (depends of the overall update speed).
  16016. */
  16017. targetStopDuration: number;
  16018. /**
  16019. * The texture used to render each particle. (this can be a spritesheet)
  16020. */
  16021. particleTexture: Nullable<Texture>;
  16022. /**
  16023. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16024. */
  16025. blendMode: number;
  16026. /**
  16027. * Minimum life time of emitting particles.
  16028. */
  16029. minLifeTime: number;
  16030. /**
  16031. * Maximum life time of emitting particles.
  16032. */
  16033. maxLifeTime: number;
  16034. /**
  16035. * Minimum Size of emitting particles.
  16036. */
  16037. minSize: number;
  16038. /**
  16039. * Maximum Size of emitting particles.
  16040. */
  16041. maxSize: number;
  16042. /**
  16043. * Minimum scale of emitting particles on X axis.
  16044. */
  16045. minScaleX: number;
  16046. /**
  16047. * Maximum scale of emitting particles on X axis.
  16048. */
  16049. maxScaleX: number;
  16050. /**
  16051. * Minimum scale of emitting particles on Y axis.
  16052. */
  16053. minScaleY: number;
  16054. /**
  16055. * Maximum scale of emitting particles on Y axis.
  16056. */
  16057. maxScaleY: number;
  16058. /**
  16059. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16060. */
  16061. color1: Color4;
  16062. /**
  16063. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16064. */
  16065. color2: Color4;
  16066. /**
  16067. * Color the particle will have at the end of its lifetime.
  16068. */
  16069. colorDead: Color4;
  16070. /**
  16071. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16072. */
  16073. emitRate: number;
  16074. /**
  16075. * You can use gravity if you want to give an orientation to your particles.
  16076. */
  16077. gravity: Vector3;
  16078. /**
  16079. * Minimum power of emitting particles.
  16080. */
  16081. minEmitPower: number;
  16082. /**
  16083. * Maximum power of emitting particles.
  16084. */
  16085. maxEmitPower: number;
  16086. /**
  16087. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16088. */
  16089. minAngularSpeed: number;
  16090. /**
  16091. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16092. */
  16093. maxAngularSpeed: number;
  16094. /**
  16095. * Gets or sets the minimal initial rotation in radians.
  16096. */
  16097. minInitialRotation: number;
  16098. /**
  16099. * Gets or sets the maximal initial rotation in radians.
  16100. */
  16101. maxInitialRotation: number;
  16102. /**
  16103. * The particle emitter type defines the emitter used by the particle system.
  16104. * It can be for example box, sphere, or cone...
  16105. */
  16106. particleEmitterType: Nullable<IParticleEmitterType>;
  16107. /**
  16108. * Defines the delay in milliseconds before starting the system (0 by default)
  16109. */
  16110. startDelay: number;
  16111. /**
  16112. * 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
  16113. */
  16114. preWarmCycles: number;
  16115. /**
  16116. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16117. */
  16118. preWarmStepOffset: number;
  16119. /**
  16120. * 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)
  16121. */
  16122. spriteCellChangeSpeed: number;
  16123. /**
  16124. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16125. */
  16126. startSpriteCellID: number;
  16127. /**
  16128. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16129. */
  16130. endSpriteCellID: number;
  16131. /**
  16132. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16133. */
  16134. spriteCellWidth: number;
  16135. /**
  16136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16137. */
  16138. spriteCellHeight: number;
  16139. /**
  16140. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16141. */
  16142. spriteRandomStartCell: boolean;
  16143. /**
  16144. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16145. */
  16146. isAnimationSheetEnabled: boolean;
  16147. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16148. translationPivot: Vector2;
  16149. /**
  16150. * Gets or sets a texture used to add random noise to particle positions
  16151. */
  16152. noiseTexture: Nullable<BaseTexture>;
  16153. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16154. noiseStrength: Vector3;
  16155. /**
  16156. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16157. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16158. */
  16159. billboardMode: number;
  16160. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16161. limitVelocityDamping: number;
  16162. /**
  16163. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16164. */
  16165. beginAnimationOnStart: boolean;
  16166. /**
  16167. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16168. */
  16169. beginAnimationFrom: number;
  16170. /**
  16171. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16172. */
  16173. beginAnimationTo: number;
  16174. /**
  16175. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16176. */
  16177. beginAnimationLoop: boolean;
  16178. /**
  16179. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16180. */
  16181. disposeOnStop: boolean;
  16182. /**
  16183. * Gets the maximum number of particles active at the same time.
  16184. * @returns The max number of active particles.
  16185. */
  16186. getCapacity(): number;
  16187. /**
  16188. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16189. * @returns True if it has been started, otherwise false.
  16190. */
  16191. isStarted(): boolean;
  16192. /**
  16193. * Animates the particle system for this frame.
  16194. */
  16195. animate(): void;
  16196. /**
  16197. * Renders the particle system in its current state.
  16198. * @returns the current number of particles
  16199. */
  16200. render(): number;
  16201. /**
  16202. * Dispose the particle system and frees its associated resources.
  16203. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16204. */
  16205. dispose(disposeTexture?: boolean): void;
  16206. /**
  16207. * Clones the particle system.
  16208. * @param name The name of the cloned object
  16209. * @param newEmitter The new emitter to use
  16210. * @returns the cloned particle system
  16211. */
  16212. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16213. /**
  16214. * Serializes the particle system to a JSON object.
  16215. * @returns the JSON object
  16216. */
  16217. serialize(): any;
  16218. /**
  16219. * Rebuild the particle system
  16220. */
  16221. rebuild(): void;
  16222. /**
  16223. * Starts the particle system and begins to emit
  16224. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16225. */
  16226. start(delay?: number): void;
  16227. /**
  16228. * Stops the particle system.
  16229. */
  16230. stop(): void;
  16231. /**
  16232. * Remove all active particles
  16233. */
  16234. reset(): void;
  16235. /**
  16236. * Is this system ready to be used/rendered
  16237. * @return true if the system is ready
  16238. */
  16239. isReady(): boolean;
  16240. /**
  16241. * Adds a new color gradient
  16242. * @param gradient defines the gradient to use (between 0 and 1)
  16243. * @param color1 defines the color to affect to the specified gradient
  16244. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16245. * @returns the current particle system
  16246. */
  16247. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16248. /**
  16249. * Remove a specific color gradient
  16250. * @param gradient defines the gradient to remove
  16251. * @returns the current particle system
  16252. */
  16253. removeColorGradient(gradient: number): IParticleSystem;
  16254. /**
  16255. * Adds a new size gradient
  16256. * @param gradient defines the gradient to use (between 0 and 1)
  16257. * @param factor defines the size factor to affect to the specified gradient
  16258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16259. * @returns the current particle system
  16260. */
  16261. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16262. /**
  16263. * Remove a specific size gradient
  16264. * @param gradient defines the gradient to remove
  16265. * @returns the current particle system
  16266. */
  16267. removeSizeGradient(gradient: number): IParticleSystem;
  16268. /**
  16269. * Gets the current list of color gradients.
  16270. * You must use addColorGradient and removeColorGradient to udpate this list
  16271. * @returns the list of color gradients
  16272. */
  16273. getColorGradients(): Nullable<Array<ColorGradient>>;
  16274. /**
  16275. * Gets the current list of size gradients.
  16276. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16277. * @returns the list of size gradients
  16278. */
  16279. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16280. /**
  16281. * Gets the current list of angular speed gradients.
  16282. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16283. * @returns the list of angular speed gradients
  16284. */
  16285. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16286. /**
  16287. * Adds a new angular speed gradient
  16288. * @param gradient defines the gradient to use (between 0 and 1)
  16289. * @param factor defines the angular speed to affect to the specified gradient
  16290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16291. * @returns the current particle system
  16292. */
  16293. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16294. /**
  16295. * Remove a specific angular speed gradient
  16296. * @param gradient defines the gradient to remove
  16297. * @returns the current particle system
  16298. */
  16299. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16300. /**
  16301. * Gets the current list of velocity gradients.
  16302. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16303. * @returns the list of velocity gradients
  16304. */
  16305. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16306. /**
  16307. * Adds a new velocity gradient
  16308. * @param gradient defines the gradient to use (between 0 and 1)
  16309. * @param factor defines the velocity to affect to the specified gradient
  16310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16311. * @returns the current particle system
  16312. */
  16313. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16314. /**
  16315. * Remove a specific velocity gradient
  16316. * @param gradient defines the gradient to remove
  16317. * @returns the current particle system
  16318. */
  16319. removeVelocityGradient(gradient: number): IParticleSystem;
  16320. /**
  16321. * Gets the current list of limit velocity gradients.
  16322. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16323. * @returns the list of limit velocity gradients
  16324. */
  16325. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16326. /**
  16327. * Adds a new limit velocity gradient
  16328. * @param gradient defines the gradient to use (between 0 and 1)
  16329. * @param factor defines the limit velocity to affect to the specified gradient
  16330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16331. * @returns the current particle system
  16332. */
  16333. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16334. /**
  16335. * Remove a specific limit velocity gradient
  16336. * @param gradient defines the gradient to remove
  16337. * @returns the current particle system
  16338. */
  16339. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16340. /**
  16341. * Adds a new drag gradient
  16342. * @param gradient defines the gradient to use (between 0 and 1)
  16343. * @param factor defines the drag to affect to the specified gradient
  16344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16345. * @returns the current particle system
  16346. */
  16347. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16348. /**
  16349. * Remove a specific drag gradient
  16350. * @param gradient defines the gradient to remove
  16351. * @returns the current particle system
  16352. */
  16353. removeDragGradient(gradient: number): IParticleSystem;
  16354. /**
  16355. * Gets the current list of drag gradients.
  16356. * You must use addDragGradient and removeDragGradient to udpate this list
  16357. * @returns the list of drag gradients
  16358. */
  16359. getDragGradients(): Nullable<Array<FactorGradient>>;
  16360. /**
  16361. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16362. * @param gradient defines the gradient to use (between 0 and 1)
  16363. * @param factor defines the emit rate to affect to the specified gradient
  16364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16365. * @returns the current particle system
  16366. */
  16367. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16368. /**
  16369. * Remove a specific emit rate gradient
  16370. * @param gradient defines the gradient to remove
  16371. * @returns the current particle system
  16372. */
  16373. removeEmitRateGradient(gradient: number): IParticleSystem;
  16374. /**
  16375. * Gets the current list of emit rate gradients.
  16376. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16377. * @returns the list of emit rate gradients
  16378. */
  16379. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16380. /**
  16381. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16382. * @param gradient defines the gradient to use (between 0 and 1)
  16383. * @param factor defines the start size to affect to the specified gradient
  16384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16385. * @returns the current particle system
  16386. */
  16387. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16388. /**
  16389. * Remove a specific start size gradient
  16390. * @param gradient defines the gradient to remove
  16391. * @returns the current particle system
  16392. */
  16393. removeStartSizeGradient(gradient: number): IParticleSystem;
  16394. /**
  16395. * Gets the current list of start size gradients.
  16396. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16397. * @returns the list of start size gradients
  16398. */
  16399. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16400. /**
  16401. * Adds a new life time gradient
  16402. * @param gradient defines the gradient to use (between 0 and 1)
  16403. * @param factor defines the life time factor to affect to the specified gradient
  16404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16405. * @returns the current particle system
  16406. */
  16407. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16408. /**
  16409. * Remove a specific life time gradient
  16410. * @param gradient defines the gradient to remove
  16411. * @returns the current particle system
  16412. */
  16413. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16414. /**
  16415. * Gets the current list of life time gradients.
  16416. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16417. * @returns the list of life time gradients
  16418. */
  16419. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16420. /**
  16421. * Gets the current list of color gradients.
  16422. * You must use addColorGradient and removeColorGradient to udpate this list
  16423. * @returns the list of color gradients
  16424. */
  16425. getColorGradients(): Nullable<Array<ColorGradient>>;
  16426. /**
  16427. * Adds a new ramp gradient used to remap particle colors
  16428. * @param gradient defines the gradient to use (between 0 and 1)
  16429. * @param color defines the color to affect to the specified gradient
  16430. * @returns the current particle system
  16431. */
  16432. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16433. /**
  16434. * Gets the current list of ramp gradients.
  16435. * You must use addRampGradient and removeRampGradient to udpate this list
  16436. * @returns the list of ramp gradients
  16437. */
  16438. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16439. /** Gets or sets a boolean indicating that ramp gradients must be used
  16440. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16441. */
  16442. useRampGradients: boolean;
  16443. /**
  16444. * Adds a new color remap gradient
  16445. * @param gradient defines the gradient to use (between 0 and 1)
  16446. * @param min defines the color remap minimal range
  16447. * @param max defines the color remap maximal range
  16448. * @returns the current particle system
  16449. */
  16450. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16451. /**
  16452. * Gets the current list of color remap gradients.
  16453. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16454. * @returns the list of color remap gradients
  16455. */
  16456. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16457. /**
  16458. * Adds a new alpha remap gradient
  16459. * @param gradient defines the gradient to use (between 0 and 1)
  16460. * @param min defines the alpha remap minimal range
  16461. * @param max defines the alpha remap maximal range
  16462. * @returns the current particle system
  16463. */
  16464. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16465. /**
  16466. * Gets the current list of alpha remap gradients.
  16467. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16468. * @returns the list of alpha remap gradients
  16469. */
  16470. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16471. /**
  16472. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16475. * @returns the emitter
  16476. */
  16477. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16478. /**
  16479. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16480. * @param radius The radius of the hemisphere to emit from
  16481. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16482. * @returns the emitter
  16483. */
  16484. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16485. /**
  16486. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16487. * @param radius The radius of the sphere to emit from
  16488. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16489. * @returns the emitter
  16490. */
  16491. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16492. /**
  16493. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16494. * @param radius The radius of the sphere to emit from
  16495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16497. * @returns the emitter
  16498. */
  16499. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16500. /**
  16501. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16502. * @param radius The radius of the emission cylinder
  16503. * @param height The height of the emission cylinder
  16504. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16505. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16506. * @returns the emitter
  16507. */
  16508. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16509. /**
  16510. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16511. * @param radius The radius of the cylinder to emit from
  16512. * @param height The height of the emission cylinder
  16513. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16516. * @returns the emitter
  16517. */
  16518. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16519. /**
  16520. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16521. * @param radius The radius of the cone to emit from
  16522. * @param angle The base angle of the cone
  16523. * @returns the emitter
  16524. */
  16525. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16526. /**
  16527. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16530. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16531. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16532. * @returns the emitter
  16533. */
  16534. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16535. /**
  16536. * Get hosting scene
  16537. * @returns the scene
  16538. */
  16539. getScene(): Scene;
  16540. }
  16541. }
  16542. declare module "babylonjs/Meshes/instancedMesh" {
  16543. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16544. import { Vector3 } from "babylonjs/Maths/math";
  16545. import { Camera } from "babylonjs/Cameras/camera";
  16546. import { Node } from "babylonjs/node";
  16547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16548. import { Mesh } from "babylonjs/Meshes/mesh";
  16549. import { Material } from "babylonjs/Materials/material";
  16550. import { Skeleton } from "babylonjs/Bones/skeleton";
  16551. /**
  16552. * Creates an instance based on a source mesh.
  16553. */
  16554. export class InstancedMesh extends AbstractMesh {
  16555. private _sourceMesh;
  16556. private _currentLOD;
  16557. /** @hidden */
  16558. _indexInSourceMeshInstanceArray: number;
  16559. constructor(name: string, source: Mesh);
  16560. /**
  16561. * Returns the string "InstancedMesh".
  16562. */
  16563. getClassName(): string;
  16564. /**
  16565. * If the source mesh receives shadows
  16566. */
  16567. readonly receiveShadows: boolean;
  16568. /**
  16569. * The material of the source mesh
  16570. */
  16571. readonly material: Nullable<Material>;
  16572. /**
  16573. * Visibility of the source mesh
  16574. */
  16575. readonly visibility: number;
  16576. /**
  16577. * Skeleton of the source mesh
  16578. */
  16579. readonly skeleton: Nullable<Skeleton>;
  16580. /**
  16581. * Rendering ground id of the source mesh
  16582. */
  16583. renderingGroupId: number;
  16584. /**
  16585. * Returns the total number of vertices (integer).
  16586. */
  16587. getTotalVertices(): number;
  16588. /**
  16589. * Returns a positive integer : the total number of indices in this mesh geometry.
  16590. * @returns the numner of indices or zero if the mesh has no geometry.
  16591. */
  16592. getTotalIndices(): number;
  16593. /**
  16594. * The source mesh of the instance
  16595. */
  16596. readonly sourceMesh: Mesh;
  16597. /**
  16598. * Is this node ready to be used/rendered
  16599. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16600. * @return {boolean} is it ready
  16601. */
  16602. isReady(completeCheck?: boolean): boolean;
  16603. /**
  16604. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16605. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16606. * @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.
  16607. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16608. */
  16609. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16610. /**
  16611. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16612. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16613. * The `data` are either a numeric array either a Float32Array.
  16614. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16615. * 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).
  16616. * Note that a new underlying VertexBuffer object is created each call.
  16617. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16618. *
  16619. * Possible `kind` values :
  16620. * - VertexBuffer.PositionKind
  16621. * - VertexBuffer.UVKind
  16622. * - VertexBuffer.UV2Kind
  16623. * - VertexBuffer.UV3Kind
  16624. * - VertexBuffer.UV4Kind
  16625. * - VertexBuffer.UV5Kind
  16626. * - VertexBuffer.UV6Kind
  16627. * - VertexBuffer.ColorKind
  16628. * - VertexBuffer.MatricesIndicesKind
  16629. * - VertexBuffer.MatricesIndicesExtraKind
  16630. * - VertexBuffer.MatricesWeightsKind
  16631. * - VertexBuffer.MatricesWeightsExtraKind
  16632. *
  16633. * Returns the Mesh.
  16634. */
  16635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16636. /**
  16637. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16638. * If the mesh has no geometry, it is simply returned as it is.
  16639. * The `data` are either a numeric array either a Float32Array.
  16640. * No new underlying VertexBuffer object is created.
  16641. * 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.
  16642. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16643. *
  16644. * Possible `kind` values :
  16645. * - VertexBuffer.PositionKind
  16646. * - VertexBuffer.UVKind
  16647. * - VertexBuffer.UV2Kind
  16648. * - VertexBuffer.UV3Kind
  16649. * - VertexBuffer.UV4Kind
  16650. * - VertexBuffer.UV5Kind
  16651. * - VertexBuffer.UV6Kind
  16652. * - VertexBuffer.ColorKind
  16653. * - VertexBuffer.MatricesIndicesKind
  16654. * - VertexBuffer.MatricesIndicesExtraKind
  16655. * - VertexBuffer.MatricesWeightsKind
  16656. * - VertexBuffer.MatricesWeightsExtraKind
  16657. *
  16658. * Returns the Mesh.
  16659. */
  16660. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16661. /**
  16662. * Sets the mesh indices.
  16663. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16664. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16665. * This method creates a new index buffer each call.
  16666. * Returns the Mesh.
  16667. */
  16668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16669. /**
  16670. * Boolean : True if the mesh owns the requested kind of data.
  16671. */
  16672. isVerticesDataPresent(kind: string): boolean;
  16673. /**
  16674. * Returns an array of indices (IndicesArray).
  16675. */
  16676. getIndices(): Nullable<IndicesArray>;
  16677. readonly _positions: Nullable<Vector3[]>;
  16678. /**
  16679. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16680. * This means the mesh underlying bounding box and sphere are recomputed.
  16681. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16682. * @returns the current mesh
  16683. */
  16684. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16685. /** @hidden */
  16686. _preActivate(): InstancedMesh;
  16687. /** @hidden */
  16688. _activate(renderId: number): InstancedMesh;
  16689. /**
  16690. * Returns the current associated LOD AbstractMesh.
  16691. */
  16692. getLOD(camera: Camera): AbstractMesh;
  16693. /** @hidden */
  16694. _syncSubMeshes(): InstancedMesh;
  16695. /** @hidden */
  16696. _generatePointsArray(): boolean;
  16697. /**
  16698. * Creates a new InstancedMesh from the current mesh.
  16699. * - name (string) : the cloned mesh name
  16700. * - newParent (optional Node) : the optional Node to parent the clone to.
  16701. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16702. *
  16703. * Returns the clone.
  16704. */
  16705. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16706. /**
  16707. * Disposes the InstancedMesh.
  16708. * Returns nothing.
  16709. */
  16710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16711. }
  16712. }
  16713. declare module "babylonjs/Materials/shaderMaterial" {
  16714. import { Scene } from "babylonjs/scene";
  16715. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16717. import { Mesh } from "babylonjs/Meshes/mesh";
  16718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16719. import { Texture } from "babylonjs/Materials/Textures/texture";
  16720. import { Material } from "babylonjs/Materials/material";
  16721. /**
  16722. * Defines the options associated with the creation of a shader material.
  16723. */
  16724. export interface IShaderMaterialOptions {
  16725. /**
  16726. * Does the material work in alpha blend mode
  16727. */
  16728. needAlphaBlending: boolean;
  16729. /**
  16730. * Does the material work in alpha test mode
  16731. */
  16732. needAlphaTesting: boolean;
  16733. /**
  16734. * The list of attribute names used in the shader
  16735. */
  16736. attributes: string[];
  16737. /**
  16738. * The list of unifrom names used in the shader
  16739. */
  16740. uniforms: string[];
  16741. /**
  16742. * The list of UBO names used in the shader
  16743. */
  16744. uniformBuffers: string[];
  16745. /**
  16746. * The list of sampler names used in the shader
  16747. */
  16748. samplers: string[];
  16749. /**
  16750. * The list of defines used in the shader
  16751. */
  16752. defines: string[];
  16753. }
  16754. /**
  16755. * 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.
  16756. *
  16757. * This returned material effects how the mesh will look based on the code in the shaders.
  16758. *
  16759. * @see http://doc.babylonjs.com/how_to/shader_material
  16760. */
  16761. export class ShaderMaterial extends Material {
  16762. private _shaderPath;
  16763. private _options;
  16764. private _textures;
  16765. private _textureArrays;
  16766. private _floats;
  16767. private _ints;
  16768. private _floatsArrays;
  16769. private _colors3;
  16770. private _colors3Arrays;
  16771. private _colors4;
  16772. private _vectors2;
  16773. private _vectors3;
  16774. private _vectors4;
  16775. private _matrices;
  16776. private _matrices3x3;
  16777. private _matrices2x2;
  16778. private _vectors2Arrays;
  16779. private _vectors3Arrays;
  16780. private _cachedWorldViewMatrix;
  16781. private _renderId;
  16782. /**
  16783. * Instantiate a new shader material.
  16784. * 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.
  16785. * This returned material effects how the mesh will look based on the code in the shaders.
  16786. * @see http://doc.babylonjs.com/how_to/shader_material
  16787. * @param name Define the name of the material in the scene
  16788. * @param scene Define the scene the material belongs to
  16789. * @param shaderPath Defines the route to the shader code in one of three ways:
  16790. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16791. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16792. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16793. * @param options Define the options used to create the shader
  16794. */
  16795. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16796. /**
  16797. * Gets the current class name of the material e.g. "ShaderMaterial"
  16798. * Mainly use in serialization.
  16799. * @returns the class name
  16800. */
  16801. getClassName(): string;
  16802. /**
  16803. * Specifies if the material will require alpha blending
  16804. * @returns a boolean specifying if alpha blending is needed
  16805. */
  16806. needAlphaBlending(): boolean;
  16807. /**
  16808. * Specifies if this material should be rendered in alpha test mode
  16809. * @returns a boolean specifying if an alpha test is needed.
  16810. */
  16811. needAlphaTesting(): boolean;
  16812. private _checkUniform;
  16813. /**
  16814. * Set a texture in the shader.
  16815. * @param name Define the name of the uniform samplers as defined in the shader
  16816. * @param texture Define the texture to bind to this sampler
  16817. * @return the material itself allowing "fluent" like uniform updates
  16818. */
  16819. setTexture(name: string, texture: Texture): ShaderMaterial;
  16820. /**
  16821. * Set a texture array in the shader.
  16822. * @param name Define the name of the uniform sampler array as defined in the shader
  16823. * @param textures Define the list of textures to bind to this sampler
  16824. * @return the material itself allowing "fluent" like uniform updates
  16825. */
  16826. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16827. /**
  16828. * Set a float in the shader.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the material itself allowing "fluent" like uniform updates
  16832. */
  16833. setFloat(name: string, value: number): ShaderMaterial;
  16834. /**
  16835. * Set a int in the shader.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the material itself allowing "fluent" like uniform updates
  16839. */
  16840. setInt(name: string, value: number): ShaderMaterial;
  16841. /**
  16842. * Set an array of floats in the shader.
  16843. * @param name Define the name of the uniform as defined in the shader
  16844. * @param value Define the value to give to the uniform
  16845. * @return the material itself allowing "fluent" like uniform updates
  16846. */
  16847. setFloats(name: string, value: number[]): ShaderMaterial;
  16848. /**
  16849. * Set a vec3 in the shader from a Color3.
  16850. * @param name Define the name of the uniform as defined in the shader
  16851. * @param value Define the value to give to the uniform
  16852. * @return the material itself allowing "fluent" like uniform updates
  16853. */
  16854. setColor3(name: string, value: Color3): ShaderMaterial;
  16855. /**
  16856. * Set a vec3 array in the shader from a Color3 array.
  16857. * @param name Define the name of the uniform as defined in the shader
  16858. * @param value Define the value to give to the uniform
  16859. * @return the material itself allowing "fluent" like uniform updates
  16860. */
  16861. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16862. /**
  16863. * Set a vec4 in the shader from a Color4.
  16864. * @param name Define the name of the uniform as defined in the shader
  16865. * @param value Define the value to give to the uniform
  16866. * @return the material itself allowing "fluent" like uniform updates
  16867. */
  16868. setColor4(name: string, value: Color4): ShaderMaterial;
  16869. /**
  16870. * Set a vec2 in the shader from a Vector2.
  16871. * @param name Define the name of the uniform as defined in the shader
  16872. * @param value Define the value to give to the uniform
  16873. * @return the material itself allowing "fluent" like uniform updates
  16874. */
  16875. setVector2(name: string, value: Vector2): ShaderMaterial;
  16876. /**
  16877. * Set a vec3 in the shader from a Vector3.
  16878. * @param name Define the name of the uniform as defined in the shader
  16879. * @param value Define the value to give to the uniform
  16880. * @return the material itself allowing "fluent" like uniform updates
  16881. */
  16882. setVector3(name: string, value: Vector3): ShaderMaterial;
  16883. /**
  16884. * Set a vec4 in the shader from a Vector4.
  16885. * @param name Define the name of the uniform as defined in the shader
  16886. * @param value Define the value to give to the uniform
  16887. * @return the material itself allowing "fluent" like uniform updates
  16888. */
  16889. setVector4(name: string, value: Vector4): ShaderMaterial;
  16890. /**
  16891. * Set a mat4 in the shader from a Matrix.
  16892. * @param name Define the name of the uniform as defined in the shader
  16893. * @param value Define the value to give to the uniform
  16894. * @return the material itself allowing "fluent" like uniform updates
  16895. */
  16896. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16897. /**
  16898. * Set a mat3 in the shader from a Float32Array.
  16899. * @param name Define the name of the uniform as defined in the shader
  16900. * @param value Define the value to give to the uniform
  16901. * @return the material itself allowing "fluent" like uniform updates
  16902. */
  16903. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16904. /**
  16905. * Set a mat2 in the shader from a Float32Array.
  16906. * @param name Define the name of the uniform as defined in the shader
  16907. * @param value Define the value to give to the uniform
  16908. * @return the material itself allowing "fluent" like uniform updates
  16909. */
  16910. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16911. /**
  16912. * Set a vec2 array in the shader from a number array.
  16913. * @param name Define the name of the uniform as defined in the shader
  16914. * @param value Define the value to give to the uniform
  16915. * @return the material itself allowing "fluent" like uniform updates
  16916. */
  16917. setArray2(name: string, value: number[]): ShaderMaterial;
  16918. /**
  16919. * Set a vec3 array in the shader from a number array.
  16920. * @param name Define the name of the uniform as defined in the shader
  16921. * @param value Define the value to give to the uniform
  16922. * @return the material itself allowing "fluent" like uniform updates
  16923. */
  16924. setArray3(name: string, value: number[]): ShaderMaterial;
  16925. private _checkCache;
  16926. /**
  16927. * Checks if the material is ready to render the requested mesh
  16928. * @param mesh Define the mesh to render
  16929. * @param useInstances Define whether or not the material is used with instances
  16930. * @returns true if ready, otherwise false
  16931. */
  16932. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16933. /**
  16934. * Binds the world matrix to the material
  16935. * @param world defines the world transformation matrix
  16936. */
  16937. bindOnlyWorldMatrix(world: Matrix): void;
  16938. /**
  16939. * Binds the material to the mesh
  16940. * @param world defines the world transformation matrix
  16941. * @param mesh defines the mesh to bind the material to
  16942. */
  16943. bind(world: Matrix, mesh?: Mesh): void;
  16944. /**
  16945. * Gets the active textures from the material
  16946. * @returns an array of textures
  16947. */
  16948. getActiveTextures(): BaseTexture[];
  16949. /**
  16950. * Specifies if the material uses a texture
  16951. * @param texture defines the texture to check against the material
  16952. * @returns a boolean specifying if the material uses the texture
  16953. */
  16954. hasTexture(texture: BaseTexture): boolean;
  16955. /**
  16956. * Makes a duplicate of the material, and gives it a new name
  16957. * @param name defines the new name for the duplicated material
  16958. * @returns the cloned material
  16959. */
  16960. clone(name: string): ShaderMaterial;
  16961. /**
  16962. * Disposes the material
  16963. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16964. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16965. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16966. */
  16967. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16968. /**
  16969. * Serializes this material in a JSON representation
  16970. * @returns the serialized material object
  16971. */
  16972. serialize(): any;
  16973. /**
  16974. * Creates a shader material from parsed shader material data
  16975. * @param source defines the JSON represnetation of the material
  16976. * @param scene defines the hosting scene
  16977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16978. * @returns a new material
  16979. */
  16980. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16981. }
  16982. }
  16983. declare module "babylonjs/Shaders/color.fragment" {
  16984. /** @hidden */
  16985. export var colorPixelShader: {
  16986. name: string;
  16987. shader: string;
  16988. };
  16989. }
  16990. declare module "babylonjs/Shaders/color.vertex" {
  16991. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16992. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16993. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16994. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16995. /** @hidden */
  16996. export var colorVertexShader: {
  16997. name: string;
  16998. shader: string;
  16999. };
  17000. }
  17001. declare module "babylonjs/Meshes/linesMesh" {
  17002. import { Nullable } from "babylonjs/types";
  17003. import { Scene } from "babylonjs/scene";
  17004. import { Color3 } from "babylonjs/Maths/math";
  17005. import { Node } from "babylonjs/node";
  17006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17007. import { Mesh } from "babylonjs/Meshes/mesh";
  17008. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17009. import { Effect } from "babylonjs/Materials/effect";
  17010. import { Material } from "babylonjs/Materials/material";
  17011. import "babylonjs/Shaders/color.fragment";
  17012. import "babylonjs/Shaders/color.vertex";
  17013. /**
  17014. * Line mesh
  17015. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17016. */
  17017. export class LinesMesh extends Mesh {
  17018. /**
  17019. * If vertex color should be applied to the mesh
  17020. */
  17021. useVertexColor?: boolean | undefined;
  17022. /**
  17023. * If vertex alpha should be applied to the mesh
  17024. */
  17025. useVertexAlpha?: boolean | undefined;
  17026. /**
  17027. * Color of the line (Default: White)
  17028. */
  17029. color: Color3;
  17030. /**
  17031. * Alpha of the line (Default: 1)
  17032. */
  17033. alpha: number;
  17034. /**
  17035. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17036. * This margin is expressed in world space coordinates, so its value may vary.
  17037. * Default value is 0.1
  17038. */
  17039. intersectionThreshold: number;
  17040. private _colorShader;
  17041. /**
  17042. * Creates a new LinesMesh
  17043. * @param name defines the name
  17044. * @param scene defines the hosting scene
  17045. * @param parent defines the parent mesh if any
  17046. * @param source defines the optional source LinesMesh used to clone data from
  17047. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17048. * When false, achieved by calling a clone(), also passing False.
  17049. * This will make creation of children, recursive.
  17050. * @param useVertexColor defines if this LinesMesh supports vertex color
  17051. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17052. */
  17053. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17054. /**
  17055. * If vertex color should be applied to the mesh
  17056. */
  17057. useVertexColor?: boolean | undefined,
  17058. /**
  17059. * If vertex alpha should be applied to the mesh
  17060. */
  17061. useVertexAlpha?: boolean | undefined);
  17062. /**
  17063. * Returns the string "LineMesh"
  17064. */
  17065. getClassName(): string;
  17066. /**
  17067. * @hidden
  17068. */
  17069. /**
  17070. * @hidden
  17071. */
  17072. material: Material;
  17073. /**
  17074. * @hidden
  17075. */
  17076. readonly checkCollisions: boolean;
  17077. /** @hidden */
  17078. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17079. /** @hidden */
  17080. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17081. /**
  17082. * Disposes of the line mesh
  17083. * @param doNotRecurse If children should be disposed
  17084. */
  17085. dispose(doNotRecurse?: boolean): void;
  17086. /**
  17087. * Returns a new LineMesh object cloned from the current one.
  17088. */
  17089. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17090. /**
  17091. * Creates a new InstancedLinesMesh object from the mesh model.
  17092. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17093. * @param name defines the name of the new instance
  17094. * @returns a new InstancedLinesMesh
  17095. */
  17096. createInstance(name: string): InstancedLinesMesh;
  17097. }
  17098. /**
  17099. * Creates an instance based on a source LinesMesh
  17100. */
  17101. export class InstancedLinesMesh extends InstancedMesh {
  17102. /**
  17103. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17104. * This margin is expressed in world space coordinates, so its value may vary.
  17105. * Initilized with the intersectionThreshold value of the source LinesMesh
  17106. */
  17107. intersectionThreshold: number;
  17108. constructor(name: string, source: LinesMesh);
  17109. /**
  17110. * Returns the string "InstancedLinesMesh".
  17111. */
  17112. getClassName(): string;
  17113. }
  17114. }
  17115. declare module "babylonjs/Shaders/line.fragment" {
  17116. /** @hidden */
  17117. export var linePixelShader: {
  17118. name: string;
  17119. shader: string;
  17120. };
  17121. }
  17122. declare module "babylonjs/Shaders/line.vertex" {
  17123. /** @hidden */
  17124. export var lineVertexShader: {
  17125. name: string;
  17126. shader: string;
  17127. };
  17128. }
  17129. declare module "babylonjs/Rendering/edgesRenderer" {
  17130. import { Nullable } from "babylonjs/types";
  17131. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17133. import { Vector3 } from "babylonjs/Maths/math";
  17134. import { IDisposable } from "babylonjs/scene";
  17135. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17136. import "babylonjs/Shaders/line.fragment";
  17137. import "babylonjs/Shaders/line.vertex";
  17138. module "babylonjs/Meshes/abstractMesh" {
  17139. interface AbstractMesh {
  17140. /**
  17141. * Disables the mesh edge rendering mode
  17142. * @returns the currentAbstractMesh
  17143. */
  17144. disableEdgesRendering(): AbstractMesh;
  17145. /**
  17146. * Enables the edge rendering mode on the mesh.
  17147. * This mode makes the mesh edges visible
  17148. * @param epsilon defines the maximal distance between two angles to detect a face
  17149. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17150. * @returns the currentAbstractMesh
  17151. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17152. */
  17153. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17154. /**
  17155. * Gets the edgesRenderer associated with the mesh
  17156. */
  17157. edgesRenderer: Nullable<EdgesRenderer>;
  17158. }
  17159. }
  17160. module "babylonjs/Meshes/linesMesh" {
  17161. interface LinesMesh {
  17162. /**
  17163. * Enables the edge rendering mode on the mesh.
  17164. * This mode makes the mesh edges visible
  17165. * @param epsilon defines the maximal distance between two angles to detect a face
  17166. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17167. * @returns the currentAbstractMesh
  17168. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17169. */
  17170. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17171. }
  17172. }
  17173. module "babylonjs/Meshes/linesMesh" {
  17174. interface InstancedLinesMesh {
  17175. /**
  17176. * Enables the edge rendering mode on the mesh.
  17177. * This mode makes the mesh edges visible
  17178. * @param epsilon defines the maximal distance between two angles to detect a face
  17179. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17180. * @returns the current InstancedLinesMesh
  17181. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17182. */
  17183. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17184. }
  17185. }
  17186. /**
  17187. * Defines the minimum contract an Edges renderer should follow.
  17188. */
  17189. export interface IEdgesRenderer extends IDisposable {
  17190. /**
  17191. * Gets or sets a boolean indicating if the edgesRenderer is active
  17192. */
  17193. isEnabled: boolean;
  17194. /**
  17195. * Renders the edges of the attached mesh,
  17196. */
  17197. render(): void;
  17198. /**
  17199. * Checks wether or not the edges renderer is ready to render.
  17200. * @return true if ready, otherwise false.
  17201. */
  17202. isReady(): boolean;
  17203. }
  17204. /**
  17205. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17206. */
  17207. export class EdgesRenderer implements IEdgesRenderer {
  17208. /**
  17209. * Define the size of the edges with an orthographic camera
  17210. */
  17211. edgesWidthScalerForOrthographic: number;
  17212. /**
  17213. * Define the size of the edges with a perspective camera
  17214. */
  17215. edgesWidthScalerForPerspective: number;
  17216. protected _source: AbstractMesh;
  17217. protected _linesPositions: number[];
  17218. protected _linesNormals: number[];
  17219. protected _linesIndices: number[];
  17220. protected _epsilon: number;
  17221. protected _indicesCount: number;
  17222. protected _lineShader: ShaderMaterial;
  17223. protected _ib: WebGLBuffer;
  17224. protected _buffers: {
  17225. [key: string]: Nullable<VertexBuffer>;
  17226. };
  17227. protected _checkVerticesInsteadOfIndices: boolean;
  17228. private _meshRebuildObserver;
  17229. private _meshDisposeObserver;
  17230. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17231. isEnabled: boolean;
  17232. /**
  17233. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17234. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17235. * @param source Mesh used to create edges
  17236. * @param epsilon sum of angles in adjacency to check for edge
  17237. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17238. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17239. */
  17240. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17241. protected _prepareRessources(): void;
  17242. /** @hidden */
  17243. _rebuild(): void;
  17244. /**
  17245. * Releases the required resources for the edges renderer
  17246. */
  17247. dispose(): void;
  17248. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17249. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17250. /**
  17251. * Checks if the pair of p0 and p1 is en edge
  17252. * @param faceIndex
  17253. * @param edge
  17254. * @param faceNormals
  17255. * @param p0
  17256. * @param p1
  17257. * @private
  17258. */
  17259. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17260. /**
  17261. * push line into the position, normal and index buffer
  17262. * @protected
  17263. */
  17264. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17265. /**
  17266. * Generates lines edges from adjacencjes
  17267. * @private
  17268. */
  17269. _generateEdgesLines(): void;
  17270. /**
  17271. * Checks wether or not the edges renderer is ready to render.
  17272. * @return true if ready, otherwise false.
  17273. */
  17274. isReady(): boolean;
  17275. /**
  17276. * Renders the edges of the attached mesh,
  17277. */
  17278. render(): void;
  17279. }
  17280. /**
  17281. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17282. */
  17283. export class LineEdgesRenderer extends EdgesRenderer {
  17284. /**
  17285. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17286. * @param source LineMesh used to generate edges
  17287. * @param epsilon not important (specified angle for edge detection)
  17288. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17289. */
  17290. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17291. /**
  17292. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17293. */
  17294. _generateEdgesLines(): void;
  17295. }
  17296. }
  17297. declare module "babylonjs/Rendering/renderingGroup" {
  17298. import { SmartArray } from "babylonjs/Misc/smartArray";
  17299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17301. import { Nullable } from "babylonjs/types";
  17302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17303. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17304. import { Material } from "babylonjs/Materials/material";
  17305. import { Scene } from "babylonjs/scene";
  17306. /**
  17307. * This represents the object necessary to create a rendering group.
  17308. * This is exclusively used and created by the rendering manager.
  17309. * To modify the behavior, you use the available helpers in your scene or meshes.
  17310. * @hidden
  17311. */
  17312. export class RenderingGroup {
  17313. index: number;
  17314. private _scene;
  17315. private _opaqueSubMeshes;
  17316. private _transparentSubMeshes;
  17317. private _alphaTestSubMeshes;
  17318. private _depthOnlySubMeshes;
  17319. private _particleSystems;
  17320. private _spriteManagers;
  17321. private _opaqueSortCompareFn;
  17322. private _alphaTestSortCompareFn;
  17323. private _transparentSortCompareFn;
  17324. private _renderOpaque;
  17325. private _renderAlphaTest;
  17326. private _renderTransparent;
  17327. private _edgesRenderers;
  17328. onBeforeTransparentRendering: () => void;
  17329. /**
  17330. * Set the opaque sort comparison function.
  17331. * If null the sub meshes will be render in the order they were created
  17332. */
  17333. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17334. /**
  17335. * Set the alpha test sort comparison function.
  17336. * If null the sub meshes will be render in the order they were created
  17337. */
  17338. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17339. /**
  17340. * Set the transparent sort comparison function.
  17341. * If null the sub meshes will be render in the order they were created
  17342. */
  17343. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17344. /**
  17345. * Creates a new rendering group.
  17346. * @param index The rendering group index
  17347. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17348. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17349. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17350. */
  17351. 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>);
  17352. /**
  17353. * Render all the sub meshes contained in the group.
  17354. * @param customRenderFunction Used to override the default render behaviour of the group.
  17355. * @returns true if rendered some submeshes.
  17356. */
  17357. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17358. /**
  17359. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17360. * @param subMeshes The submeshes to render
  17361. */
  17362. private renderOpaqueSorted;
  17363. /**
  17364. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17365. * @param subMeshes The submeshes to render
  17366. */
  17367. private renderAlphaTestSorted;
  17368. /**
  17369. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17370. * @param subMeshes The submeshes to render
  17371. */
  17372. private renderTransparentSorted;
  17373. /**
  17374. * Renders the submeshes in a specified order.
  17375. * @param subMeshes The submeshes to sort before render
  17376. * @param sortCompareFn The comparison function use to sort
  17377. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17378. * @param transparent Specifies to activate blending if true
  17379. */
  17380. private static renderSorted;
  17381. /**
  17382. * Renders the submeshes in the order they were dispatched (no sort applied).
  17383. * @param subMeshes The submeshes to render
  17384. */
  17385. private static renderUnsorted;
  17386. /**
  17387. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17388. * are rendered back to front if in the same alpha index.
  17389. *
  17390. * @param a The first submesh
  17391. * @param b The second submesh
  17392. * @returns The result of the comparison
  17393. */
  17394. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17395. /**
  17396. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17397. * are rendered back to front.
  17398. *
  17399. * @param a The first submesh
  17400. * @param b The second submesh
  17401. * @returns The result of the comparison
  17402. */
  17403. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17404. /**
  17405. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17406. * are rendered front to back (prevent overdraw).
  17407. *
  17408. * @param a The first submesh
  17409. * @param b The second submesh
  17410. * @returns The result of the comparison
  17411. */
  17412. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17413. /**
  17414. * Resets the different lists of submeshes to prepare a new frame.
  17415. */
  17416. prepare(): void;
  17417. dispose(): void;
  17418. /**
  17419. * Inserts the submesh in its correct queue depending on its material.
  17420. * @param subMesh The submesh to dispatch
  17421. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17422. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17423. */
  17424. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17425. dispatchSprites(spriteManager: ISpriteManager): void;
  17426. dispatchParticles(particleSystem: IParticleSystem): void;
  17427. private _renderParticles;
  17428. private _renderSprites;
  17429. }
  17430. }
  17431. declare module "babylonjs/Rendering/renderingManager" {
  17432. import { Nullable } from "babylonjs/types";
  17433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17435. import { SmartArray } from "babylonjs/Misc/smartArray";
  17436. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17437. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17438. import { Material } from "babylonjs/Materials/material";
  17439. import { Scene } from "babylonjs/scene";
  17440. import { Camera } from "babylonjs/Cameras/camera";
  17441. /**
  17442. * Interface describing the different options available in the rendering manager
  17443. * regarding Auto Clear between groups.
  17444. */
  17445. export interface IRenderingManagerAutoClearSetup {
  17446. /**
  17447. * Defines whether or not autoclear is enable.
  17448. */
  17449. autoClear: boolean;
  17450. /**
  17451. * Defines whether or not to autoclear the depth buffer.
  17452. */
  17453. depth: boolean;
  17454. /**
  17455. * Defines whether or not to autoclear the stencil buffer.
  17456. */
  17457. stencil: boolean;
  17458. }
  17459. /**
  17460. * This class is used by the onRenderingGroupObservable
  17461. */
  17462. export class RenderingGroupInfo {
  17463. /**
  17464. * The Scene that being rendered
  17465. */
  17466. scene: Scene;
  17467. /**
  17468. * The camera currently used for the rendering pass
  17469. */
  17470. camera: Nullable<Camera>;
  17471. /**
  17472. * The ID of the renderingGroup being processed
  17473. */
  17474. renderingGroupId: number;
  17475. }
  17476. /**
  17477. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17478. * It is enable to manage the different groups as well as the different necessary sort functions.
  17479. * This should not be used directly aside of the few static configurations
  17480. */
  17481. export class RenderingManager {
  17482. /**
  17483. * The max id used for rendering groups (not included)
  17484. */
  17485. static MAX_RENDERINGGROUPS: number;
  17486. /**
  17487. * The min id used for rendering groups (included)
  17488. */
  17489. static MIN_RENDERINGGROUPS: number;
  17490. /**
  17491. * Used to globally prevent autoclearing scenes.
  17492. */
  17493. static AUTOCLEAR: boolean;
  17494. /**
  17495. * @hidden
  17496. */
  17497. _useSceneAutoClearSetup: boolean;
  17498. private _scene;
  17499. private _renderingGroups;
  17500. private _depthStencilBufferAlreadyCleaned;
  17501. private _autoClearDepthStencil;
  17502. private _customOpaqueSortCompareFn;
  17503. private _customAlphaTestSortCompareFn;
  17504. private _customTransparentSortCompareFn;
  17505. private _renderingGroupInfo;
  17506. /**
  17507. * Instantiates a new rendering group for a particular scene
  17508. * @param scene Defines the scene the groups belongs to
  17509. */
  17510. constructor(scene: Scene);
  17511. private _clearDepthStencilBuffer;
  17512. /**
  17513. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17514. * @hidden
  17515. */
  17516. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17517. /**
  17518. * Resets the different information of the group to prepare a new frame
  17519. * @hidden
  17520. */
  17521. reset(): void;
  17522. /**
  17523. * Dispose and release the group and its associated resources.
  17524. * @hidden
  17525. */
  17526. dispose(): void;
  17527. /**
  17528. * Clear the info related to rendering groups preventing retention points during dispose.
  17529. */
  17530. freeRenderingGroups(): void;
  17531. private _prepareRenderingGroup;
  17532. /**
  17533. * Add a sprite manager to the rendering manager in order to render it this frame.
  17534. * @param spriteManager Define the sprite manager to render
  17535. */
  17536. dispatchSprites(spriteManager: ISpriteManager): void;
  17537. /**
  17538. * Add a particle system to the rendering manager in order to render it this frame.
  17539. * @param particleSystem Define the particle system to render
  17540. */
  17541. dispatchParticles(particleSystem: IParticleSystem): void;
  17542. /**
  17543. * Add a submesh to the manager in order to render it this frame
  17544. * @param subMesh The submesh to dispatch
  17545. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17546. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17547. */
  17548. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17549. /**
  17550. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17551. * This allowed control for front to back rendering or reversly depending of the special needs.
  17552. *
  17553. * @param renderingGroupId The rendering group id corresponding to its index
  17554. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17555. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17556. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17557. */
  17558. 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;
  17559. /**
  17560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17561. *
  17562. * @param renderingGroupId The rendering group id corresponding to its index
  17563. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17564. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17565. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17566. */
  17567. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17568. /**
  17569. * Gets the current auto clear configuration for one rendering group of the rendering
  17570. * manager.
  17571. * @param index the rendering group index to get the information for
  17572. * @returns The auto clear setup for the requested rendering group
  17573. */
  17574. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17575. }
  17576. }
  17577. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17578. import { Observable } from "babylonjs/Misc/observable";
  17579. import { SmartArray } from "babylonjs/Misc/smartArray";
  17580. import { Nullable } from "babylonjs/types";
  17581. import { Camera } from "babylonjs/Cameras/camera";
  17582. import { Scene } from "babylonjs/scene";
  17583. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17584. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17588. import { Texture } from "babylonjs/Materials/Textures/texture";
  17589. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17590. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17591. import { Engine } from "babylonjs/Engines/engine";
  17592. /**
  17593. * This Helps creating a texture that will be created from a camera in your scene.
  17594. * It is basically a dynamic texture that could be used to create special effects for instance.
  17595. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17596. */
  17597. export class RenderTargetTexture extends Texture {
  17598. isCube: boolean;
  17599. /**
  17600. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17601. */
  17602. static readonly REFRESHRATE_RENDER_ONCE: number;
  17603. /**
  17604. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17605. */
  17606. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17607. /**
  17608. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17609. * the central point of your effect and can save a lot of performances.
  17610. */
  17611. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17612. /**
  17613. * Use this predicate to dynamically define the list of mesh you want to render.
  17614. * If set, the renderList property will be overwritten.
  17615. */
  17616. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17617. private _renderList;
  17618. /**
  17619. * Use this list to define the list of mesh you want to render.
  17620. */
  17621. renderList: Nullable<Array<AbstractMesh>>;
  17622. private _hookArray;
  17623. /**
  17624. * Define if particles should be rendered in your texture.
  17625. */
  17626. renderParticles: boolean;
  17627. /**
  17628. * Define if sprites should be rendered in your texture.
  17629. */
  17630. renderSprites: boolean;
  17631. /**
  17632. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17633. */
  17634. coordinatesMode: number;
  17635. /**
  17636. * Define the camera used to render the texture.
  17637. */
  17638. activeCamera: Nullable<Camera>;
  17639. /**
  17640. * Override the render function of the texture with your own one.
  17641. */
  17642. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17643. /**
  17644. * Define if camera post processes should be use while rendering the texture.
  17645. */
  17646. useCameraPostProcesses: boolean;
  17647. /**
  17648. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17649. */
  17650. ignoreCameraViewport: boolean;
  17651. private _postProcessManager;
  17652. private _postProcesses;
  17653. private _resizeObserver;
  17654. /**
  17655. * An event triggered when the texture is unbind.
  17656. */
  17657. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17658. /**
  17659. * An event triggered when the texture is unbind.
  17660. */
  17661. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17662. private _onAfterUnbindObserver;
  17663. /**
  17664. * Set a after unbind callback in the texture.
  17665. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17666. */
  17667. onAfterUnbind: () => void;
  17668. /**
  17669. * An event triggered before rendering the texture
  17670. */
  17671. onBeforeRenderObservable: Observable<number>;
  17672. private _onBeforeRenderObserver;
  17673. /**
  17674. * Set a before render callback in the texture.
  17675. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17676. */
  17677. onBeforeRender: (faceIndex: number) => void;
  17678. /**
  17679. * An event triggered after rendering the texture
  17680. */
  17681. onAfterRenderObservable: Observable<number>;
  17682. private _onAfterRenderObserver;
  17683. /**
  17684. * Set a after render callback in the texture.
  17685. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17686. */
  17687. onAfterRender: (faceIndex: number) => void;
  17688. /**
  17689. * An event triggered after the texture clear
  17690. */
  17691. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17692. private _onClearObserver;
  17693. /**
  17694. * Set a clear callback in the texture.
  17695. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17696. */
  17697. onClear: (Engine: Engine) => void;
  17698. /**
  17699. * Define the clear color of the Render Target if it should be different from the scene.
  17700. */
  17701. clearColor: Color4;
  17702. protected _size: number | {
  17703. width: number;
  17704. height: number;
  17705. };
  17706. protected _initialSizeParameter: number | {
  17707. width: number;
  17708. height: number;
  17709. } | {
  17710. ratio: number;
  17711. };
  17712. protected _sizeRatio: Nullable<number>;
  17713. /** @hidden */
  17714. _generateMipMaps: boolean;
  17715. protected _renderingManager: RenderingManager;
  17716. /** @hidden */
  17717. _waitingRenderList: string[];
  17718. protected _doNotChangeAspectRatio: boolean;
  17719. protected _currentRefreshId: number;
  17720. protected _refreshRate: number;
  17721. protected _textureMatrix: Matrix;
  17722. protected _samples: number;
  17723. protected _renderTargetOptions: RenderTargetCreationOptions;
  17724. /**
  17725. * Gets render target creation options that were used.
  17726. */
  17727. readonly renderTargetOptions: RenderTargetCreationOptions;
  17728. protected _engine: Engine;
  17729. protected _onRatioRescale(): void;
  17730. /**
  17731. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17732. * It must define where the camera used to render the texture is set
  17733. */
  17734. boundingBoxPosition: Vector3;
  17735. private _boundingBoxSize;
  17736. /**
  17737. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17738. * When defined, the cubemap will switch to local mode
  17739. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17740. * @example https://www.babylonjs-playground.com/#RNASML
  17741. */
  17742. boundingBoxSize: Vector3;
  17743. /**
  17744. * In case the RTT has been created with a depth texture, get the associated
  17745. * depth texture.
  17746. * Otherwise, return null.
  17747. */
  17748. depthStencilTexture: Nullable<InternalTexture>;
  17749. /**
  17750. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17751. * or used a shadow, depth texture...
  17752. * @param name The friendly name of the texture
  17753. * @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)
  17754. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17755. * @param generateMipMaps True if mip maps need to be generated after render.
  17756. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17757. * @param type The type of the buffer in the RTT (int, half float, float...)
  17758. * @param isCube True if a cube texture needs to be created
  17759. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17760. * @param generateDepthBuffer True to generate a depth buffer
  17761. * @param generateStencilBuffer True to generate a stencil buffer
  17762. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17763. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17764. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17765. */
  17766. constructor(name: string, size: number | {
  17767. width: number;
  17768. height: number;
  17769. } | {
  17770. ratio: number;
  17771. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17772. /**
  17773. * Creates a depth stencil texture.
  17774. * This is only available in WebGL 2 or with the depth texture extension available.
  17775. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17776. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17777. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17778. */
  17779. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17780. private _processSizeParameter;
  17781. /**
  17782. * Define the number of samples to use in case of MSAA.
  17783. * It defaults to one meaning no MSAA has been enabled.
  17784. */
  17785. samples: number;
  17786. /**
  17787. * Resets the refresh counter of the texture and start bak from scratch.
  17788. * Could be useful to regenerate the texture if it is setup to render only once.
  17789. */
  17790. resetRefreshCounter(): void;
  17791. /**
  17792. * Define the refresh rate of the texture or the rendering frequency.
  17793. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17794. */
  17795. refreshRate: number;
  17796. /**
  17797. * Adds a post process to the render target rendering passes.
  17798. * @param postProcess define the post process to add
  17799. */
  17800. addPostProcess(postProcess: PostProcess): void;
  17801. /**
  17802. * Clear all the post processes attached to the render target
  17803. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17804. */
  17805. clearPostProcesses(dispose?: boolean): void;
  17806. /**
  17807. * Remove one of the post process from the list of attached post processes to the texture
  17808. * @param postProcess define the post process to remove from the list
  17809. */
  17810. removePostProcess(postProcess: PostProcess): void;
  17811. /** @hidden */
  17812. _shouldRender(): boolean;
  17813. /**
  17814. * Gets the actual render size of the texture.
  17815. * @returns the width of the render size
  17816. */
  17817. getRenderSize(): number;
  17818. /**
  17819. * Gets the actual render width of the texture.
  17820. * @returns the width of the render size
  17821. */
  17822. getRenderWidth(): number;
  17823. /**
  17824. * Gets the actual render height of the texture.
  17825. * @returns the height of the render size
  17826. */
  17827. getRenderHeight(): number;
  17828. /**
  17829. * Get if the texture can be rescaled or not.
  17830. */
  17831. readonly canRescale: boolean;
  17832. /**
  17833. * Resize the texture using a ratio.
  17834. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17835. */
  17836. scale(ratio: number): void;
  17837. /**
  17838. * Get the texture reflection matrix used to rotate/transform the reflection.
  17839. * @returns the reflection matrix
  17840. */
  17841. getReflectionTextureMatrix(): Matrix;
  17842. /**
  17843. * Resize the texture to a new desired size.
  17844. * Be carrefull as it will recreate all the data in the new texture.
  17845. * @param size Define the new size. It can be:
  17846. * - a number for squared texture,
  17847. * - an object containing { width: number, height: number }
  17848. * - or an object containing a ratio { ratio: number }
  17849. */
  17850. resize(size: number | {
  17851. width: number;
  17852. height: number;
  17853. } | {
  17854. ratio: number;
  17855. }): void;
  17856. /**
  17857. * Renders all the objects from the render list into the texture.
  17858. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17859. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17860. */
  17861. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17862. private _bestReflectionRenderTargetDimension;
  17863. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17864. private renderToTarget;
  17865. /**
  17866. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17867. * This allowed control for front to back rendering or reversly depending of the special needs.
  17868. *
  17869. * @param renderingGroupId The rendering group id corresponding to its index
  17870. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17871. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17872. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17873. */
  17874. 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;
  17875. /**
  17876. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17877. *
  17878. * @param renderingGroupId The rendering group id corresponding to its index
  17879. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17880. */
  17881. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17882. /**
  17883. * Clones the texture.
  17884. * @returns the cloned texture
  17885. */
  17886. clone(): RenderTargetTexture;
  17887. /**
  17888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17889. * @returns The JSON representation of the texture
  17890. */
  17891. serialize(): any;
  17892. /**
  17893. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17894. */
  17895. disposeFramebufferObjects(): void;
  17896. /**
  17897. * Dispose the texture and release its associated resources.
  17898. */
  17899. dispose(): void;
  17900. /** @hidden */
  17901. _rebuild(): void;
  17902. /**
  17903. * Clear the info related to rendering groups preventing retention point in material dispose.
  17904. */
  17905. freeRenderingGroups(): void;
  17906. }
  17907. }
  17908. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17909. import { Scene } from "babylonjs/scene";
  17910. import { Plane } from "babylonjs/Maths/math";
  17911. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17912. /**
  17913. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17914. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17915. * You can then easily use it as a reflectionTexture on a flat surface.
  17916. * In case the surface is not a plane, please consider relying on reflection probes.
  17917. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17918. */
  17919. export class MirrorTexture extends RenderTargetTexture {
  17920. private scene;
  17921. /**
  17922. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17923. * 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.
  17924. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17925. */
  17926. mirrorPlane: Plane;
  17927. /**
  17928. * Define the blur ratio used to blur the reflection if needed.
  17929. */
  17930. blurRatio: number;
  17931. /**
  17932. * Define the adaptive blur kernel used to blur the reflection if needed.
  17933. * This will autocompute the closest best match for the `blurKernel`
  17934. */
  17935. adaptiveBlurKernel: number;
  17936. /**
  17937. * Define the blur kernel used to blur the reflection if needed.
  17938. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17939. */
  17940. blurKernel: number;
  17941. /**
  17942. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17943. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17944. */
  17945. blurKernelX: number;
  17946. /**
  17947. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17948. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17949. */
  17950. blurKernelY: number;
  17951. private _autoComputeBlurKernel;
  17952. protected _onRatioRescale(): void;
  17953. private _updateGammaSpace;
  17954. private _imageProcessingConfigChangeObserver;
  17955. private _transformMatrix;
  17956. private _mirrorMatrix;
  17957. private _savedViewMatrix;
  17958. private _blurX;
  17959. private _blurY;
  17960. private _adaptiveBlurKernel;
  17961. private _blurKernelX;
  17962. private _blurKernelY;
  17963. private _blurRatio;
  17964. /**
  17965. * Instantiates a Mirror Texture.
  17966. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17967. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17968. * You can then easily use it as a reflectionTexture on a flat surface.
  17969. * In case the surface is not a plane, please consider relying on reflection probes.
  17970. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17971. * @param name
  17972. * @param size
  17973. * @param scene
  17974. * @param generateMipMaps
  17975. * @param type
  17976. * @param samplingMode
  17977. * @param generateDepthBuffer
  17978. */
  17979. constructor(name: string, size: number | {
  17980. width: number;
  17981. height: number;
  17982. } | {
  17983. ratio: number;
  17984. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17985. private _preparePostProcesses;
  17986. /**
  17987. * Clone the mirror texture.
  17988. * @returns the cloned texture
  17989. */
  17990. clone(): MirrorTexture;
  17991. /**
  17992. * Serialize the texture to a JSON representation you could use in Parse later on
  17993. * @returns the serialized JSON representation
  17994. */
  17995. serialize(): any;
  17996. /**
  17997. * Dispose the texture and release its associated resources.
  17998. */
  17999. dispose(): void;
  18000. }
  18001. }
  18002. declare module "babylonjs/Materials/Textures/texture" {
  18003. import { Observable } from "babylonjs/Misc/observable";
  18004. import { Nullable } from "babylonjs/types";
  18005. import { Scene } from "babylonjs/scene";
  18006. import { Matrix } from "babylonjs/Maths/math";
  18007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18008. /**
  18009. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18010. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18011. */
  18012. export class Texture extends BaseTexture {
  18013. /** @hidden */
  18014. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18015. /** @hidden */
  18016. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18017. /** @hidden */
  18018. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18019. /** nearest is mag = nearest and min = nearest and mip = linear */
  18020. static readonly NEAREST_SAMPLINGMODE: number;
  18021. /** nearest is mag = nearest and min = nearest and mip = linear */
  18022. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18024. static readonly BILINEAR_SAMPLINGMODE: number;
  18025. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18026. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18027. /** Trilinear is mag = linear and min = linear and mip = linear */
  18028. static readonly TRILINEAR_SAMPLINGMODE: number;
  18029. /** Trilinear is mag = linear and min = linear and mip = linear */
  18030. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18031. /** mag = nearest and min = nearest and mip = nearest */
  18032. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18033. /** mag = nearest and min = linear and mip = nearest */
  18034. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18035. /** mag = nearest and min = linear and mip = linear */
  18036. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18037. /** mag = nearest and min = linear and mip = none */
  18038. static readonly NEAREST_LINEAR: number;
  18039. /** mag = nearest and min = nearest and mip = none */
  18040. static readonly NEAREST_NEAREST: number;
  18041. /** mag = linear and min = nearest and mip = nearest */
  18042. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18043. /** mag = linear and min = nearest and mip = linear */
  18044. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18045. /** mag = linear and min = linear and mip = none */
  18046. static readonly LINEAR_LINEAR: number;
  18047. /** mag = linear and min = nearest and mip = none */
  18048. static readonly LINEAR_NEAREST: number;
  18049. /** Explicit coordinates mode */
  18050. static readonly EXPLICIT_MODE: number;
  18051. /** Spherical coordinates mode */
  18052. static readonly SPHERICAL_MODE: number;
  18053. /** Planar coordinates mode */
  18054. static readonly PLANAR_MODE: number;
  18055. /** Cubic coordinates mode */
  18056. static readonly CUBIC_MODE: number;
  18057. /** Projection coordinates mode */
  18058. static readonly PROJECTION_MODE: number;
  18059. /** Inverse Cubic coordinates mode */
  18060. static readonly SKYBOX_MODE: number;
  18061. /** Inverse Cubic coordinates mode */
  18062. static readonly INVCUBIC_MODE: number;
  18063. /** Equirectangular coordinates mode */
  18064. static readonly EQUIRECTANGULAR_MODE: number;
  18065. /** Equirectangular Fixed coordinates mode */
  18066. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18067. /** Equirectangular Fixed Mirrored coordinates mode */
  18068. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18069. /** Texture is not repeating outside of 0..1 UVs */
  18070. static readonly CLAMP_ADDRESSMODE: number;
  18071. /** Texture is repeating outside of 0..1 UVs */
  18072. static readonly WRAP_ADDRESSMODE: number;
  18073. /** Texture is repeating and mirrored */
  18074. static readonly MIRROR_ADDRESSMODE: number;
  18075. /**
  18076. * 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
  18077. */
  18078. static UseSerializedUrlIfAny: boolean;
  18079. /**
  18080. * Define the url of the texture.
  18081. */
  18082. url: Nullable<string>;
  18083. /**
  18084. * Define an offset on the texture to offset the u coordinates of the UVs
  18085. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18086. */
  18087. uOffset: number;
  18088. /**
  18089. * Define an offset on the texture to offset the v coordinates of the UVs
  18090. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18091. */
  18092. vOffset: number;
  18093. /**
  18094. * Define an offset on the texture to scale the u coordinates of the UVs
  18095. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18096. */
  18097. uScale: number;
  18098. /**
  18099. * Define an offset on the texture to scale the v coordinates of the UVs
  18100. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18101. */
  18102. vScale: number;
  18103. /**
  18104. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18105. * @see http://doc.babylonjs.com/how_to/more_materials
  18106. */
  18107. uAng: number;
  18108. /**
  18109. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18110. * @see http://doc.babylonjs.com/how_to/more_materials
  18111. */
  18112. vAng: number;
  18113. /**
  18114. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18115. * @see http://doc.babylonjs.com/how_to/more_materials
  18116. */
  18117. wAng: number;
  18118. /**
  18119. * Defines the center of rotation (U)
  18120. */
  18121. uRotationCenter: number;
  18122. /**
  18123. * Defines the center of rotation (V)
  18124. */
  18125. vRotationCenter: number;
  18126. /**
  18127. * Defines the center of rotation (W)
  18128. */
  18129. wRotationCenter: number;
  18130. /**
  18131. * Are mip maps generated for this texture or not.
  18132. */
  18133. readonly noMipmap: boolean;
  18134. private _noMipmap;
  18135. /** @hidden */
  18136. _invertY: boolean;
  18137. private _rowGenerationMatrix;
  18138. private _cachedTextureMatrix;
  18139. private _projectionModeMatrix;
  18140. private _t0;
  18141. private _t1;
  18142. private _t2;
  18143. private _cachedUOffset;
  18144. private _cachedVOffset;
  18145. private _cachedUScale;
  18146. private _cachedVScale;
  18147. private _cachedUAng;
  18148. private _cachedVAng;
  18149. private _cachedWAng;
  18150. private _cachedProjectionMatrixId;
  18151. private _cachedCoordinatesMode;
  18152. /** @hidden */
  18153. protected _initialSamplingMode: number;
  18154. /** @hidden */
  18155. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18156. private _deleteBuffer;
  18157. protected _format: Nullable<number>;
  18158. private _delayedOnLoad;
  18159. private _delayedOnError;
  18160. /**
  18161. * Observable triggered once the texture has been loaded.
  18162. */
  18163. onLoadObservable: Observable<Texture>;
  18164. protected _isBlocking: boolean;
  18165. /**
  18166. * Is the texture preventing material to render while loading.
  18167. * If false, a default texture will be used instead of the loading one during the preparation step.
  18168. */
  18169. isBlocking: boolean;
  18170. /**
  18171. * Get the current sampling mode associated with the texture.
  18172. */
  18173. readonly samplingMode: number;
  18174. /**
  18175. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18176. */
  18177. readonly invertY: boolean;
  18178. /**
  18179. * Instantiates a new texture.
  18180. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18181. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18182. * @param url define the url of the picture to load as a texture
  18183. * @param scene define the scene the texture will belong to
  18184. * @param noMipmap define if the texture will require mip maps or not
  18185. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18186. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18187. * @param onLoad define a callback triggered when the texture has been loaded
  18188. * @param onError define a callback triggered when an error occurred during the loading session
  18189. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18190. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18191. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18192. */
  18193. 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);
  18194. /**
  18195. * Update the url (and optional buffer) of this texture if url was null during construction.
  18196. * @param url the url of the texture
  18197. * @param buffer the buffer of the texture (defaults to null)
  18198. * @param onLoad callback called when the texture is loaded (defaults to null)
  18199. */
  18200. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18201. /**
  18202. * Finish the loading sequence of a texture flagged as delayed load.
  18203. * @hidden
  18204. */
  18205. delayLoad(): void;
  18206. private _prepareRowForTextureGeneration;
  18207. /**
  18208. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18209. * @returns the transform matrix of the texture.
  18210. */
  18211. getTextureMatrix(): Matrix;
  18212. /**
  18213. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18214. * @returns The reflection texture transform
  18215. */
  18216. getReflectionTextureMatrix(): Matrix;
  18217. /**
  18218. * Clones the texture.
  18219. * @returns the cloned texture
  18220. */
  18221. clone(): Texture;
  18222. /**
  18223. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18224. * @returns The JSON representation of the texture
  18225. */
  18226. serialize(): any;
  18227. /**
  18228. * Get the current class name of the texture useful for serialization or dynamic coding.
  18229. * @returns "Texture"
  18230. */
  18231. getClassName(): string;
  18232. /**
  18233. * Dispose the texture and release its associated resources.
  18234. */
  18235. dispose(): void;
  18236. /**
  18237. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18238. * @param parsedTexture Define the JSON representation of the texture
  18239. * @param scene Define the scene the parsed texture should be instantiated in
  18240. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18241. * @returns The parsed texture if successful
  18242. */
  18243. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18244. /**
  18245. * Creates a texture from its base 64 representation.
  18246. * @param data Define the base64 payload without the data: prefix
  18247. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18248. * @param scene Define the scene the texture should belong to
  18249. * @param noMipmap Forces the texture to not create mip map information if true
  18250. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18251. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18252. * @param onLoad define a callback triggered when the texture has been loaded
  18253. * @param onError define a callback triggered when an error occurred during the loading session
  18254. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18255. * @returns the created texture
  18256. */
  18257. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18258. /**
  18259. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18260. * @param data Define the base64 payload without the data: prefix
  18261. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18262. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18263. * @param scene Define the scene the texture should belong to
  18264. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18265. * @param noMipmap Forces the texture to not create mip map information if true
  18266. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18267. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18268. * @param onLoad define a callback triggered when the texture has been loaded
  18269. * @param onError define a callback triggered when an error occurred during the loading session
  18270. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18271. * @returns the created texture
  18272. */
  18273. 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;
  18274. }
  18275. }
  18276. declare module "babylonjs/Materials/Textures/rawTexture" {
  18277. import { Scene } from "babylonjs/scene";
  18278. import { Texture } from "babylonjs/Materials/Textures/texture";
  18279. /**
  18280. * Raw texture can help creating a texture directly from an array of data.
  18281. * This can be super useful if you either get the data from an uncompressed source or
  18282. * if you wish to create your texture pixel by pixel.
  18283. */
  18284. export class RawTexture extends Texture {
  18285. /**
  18286. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18287. */
  18288. format: number;
  18289. private _engine;
  18290. /**
  18291. * Instantiates a new RawTexture.
  18292. * Raw texture can help creating a texture directly from an array of data.
  18293. * This can be super useful if you either get the data from an uncompressed source or
  18294. * if you wish to create your texture pixel by pixel.
  18295. * @param data define the array of data to use to create the texture
  18296. * @param width define the width of the texture
  18297. * @param height define the height of the texture
  18298. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18299. * @param scene define the scene the texture belongs to
  18300. * @param generateMipMaps define whether mip maps should be generated or not
  18301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18303. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18304. */
  18305. constructor(data: ArrayBufferView, width: number, height: number,
  18306. /**
  18307. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18308. */
  18309. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18310. /**
  18311. * Updates the texture underlying data.
  18312. * @param data Define the new data of the texture
  18313. */
  18314. update(data: ArrayBufferView): void;
  18315. /**
  18316. * Creates a luminance texture from some data.
  18317. * @param data Define the texture data
  18318. * @param width Define the width of the texture
  18319. * @param height Define the height of the texture
  18320. * @param scene Define the scene the texture belongs to
  18321. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18322. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18323. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18324. * @returns the luminance texture
  18325. */
  18326. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18327. /**
  18328. * Creates a luminance alpha texture from some data.
  18329. * @param data Define the texture data
  18330. * @param width Define the width of the texture
  18331. * @param height Define the height of the texture
  18332. * @param scene Define the scene the texture belongs to
  18333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18336. * @returns the luminance alpha texture
  18337. */
  18338. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18339. /**
  18340. * Creates an alpha texture from some data.
  18341. * @param data Define the texture data
  18342. * @param width Define the width of the texture
  18343. * @param height Define the height of the texture
  18344. * @param scene Define the scene the texture belongs to
  18345. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18348. * @returns the alpha texture
  18349. */
  18350. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18351. /**
  18352. * Creates a RGB texture from some data.
  18353. * @param data Define the texture data
  18354. * @param width Define the width of the texture
  18355. * @param height Define the height of the texture
  18356. * @param scene Define the scene the texture belongs to
  18357. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18360. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18361. * @returns the RGB alpha texture
  18362. */
  18363. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18364. /**
  18365. * Creates a RGBA texture from some data.
  18366. * @param data Define the texture data
  18367. * @param width Define the width of the texture
  18368. * @param height Define the height of the texture
  18369. * @param scene Define the scene the texture belongs to
  18370. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18371. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18372. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18373. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18374. * @returns the RGBA texture
  18375. */
  18376. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18377. /**
  18378. * Creates a R texture from some data.
  18379. * @param data Define the texture data
  18380. * @param width Define the width of the texture
  18381. * @param height Define the height of the texture
  18382. * @param scene Define the scene the texture belongs to
  18383. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18384. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18385. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18386. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18387. * @returns the R texture
  18388. */
  18389. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18390. }
  18391. }
  18392. declare module "babylonjs/Animations/runtimeAnimation" {
  18393. import { Animation } from "babylonjs/Animations/animation";
  18394. import { Animatable } from "babylonjs/Animations/animatable";
  18395. import { Scene } from "babylonjs/scene";
  18396. /**
  18397. * Defines a runtime animation
  18398. */
  18399. export class RuntimeAnimation {
  18400. private _events;
  18401. /**
  18402. * The current frame of the runtime animation
  18403. */
  18404. private _currentFrame;
  18405. /**
  18406. * The animation used by the runtime animation
  18407. */
  18408. private _animation;
  18409. /**
  18410. * The target of the runtime animation
  18411. */
  18412. private _target;
  18413. /**
  18414. * The initiating animatable
  18415. */
  18416. private _host;
  18417. /**
  18418. * The original value of the runtime animation
  18419. */
  18420. private _originalValue;
  18421. /**
  18422. * The original blend value of the runtime animation
  18423. */
  18424. private _originalBlendValue;
  18425. /**
  18426. * The offsets cache of the runtime animation
  18427. */
  18428. private _offsetsCache;
  18429. /**
  18430. * The high limits cache of the runtime animation
  18431. */
  18432. private _highLimitsCache;
  18433. /**
  18434. * Specifies if the runtime animation has been stopped
  18435. */
  18436. private _stopped;
  18437. /**
  18438. * The blending factor of the runtime animation
  18439. */
  18440. private _blendingFactor;
  18441. /**
  18442. * The BabylonJS scene
  18443. */
  18444. private _scene;
  18445. /**
  18446. * The current value of the runtime animation
  18447. */
  18448. private _currentValue;
  18449. /** @hidden */
  18450. _workValue: any;
  18451. /**
  18452. * The active target of the runtime animation
  18453. */
  18454. private _activeTarget;
  18455. /**
  18456. * The target path of the runtime animation
  18457. */
  18458. private _targetPath;
  18459. /**
  18460. * The weight of the runtime animation
  18461. */
  18462. private _weight;
  18463. /**
  18464. * The ratio offset of the runtime animation
  18465. */
  18466. private _ratioOffset;
  18467. /**
  18468. * The previous delay of the runtime animation
  18469. */
  18470. private _previousDelay;
  18471. /**
  18472. * The previous ratio of the runtime animation
  18473. */
  18474. private _previousRatio;
  18475. /**
  18476. * Gets the current frame of the runtime animation
  18477. */
  18478. readonly currentFrame: number;
  18479. /**
  18480. * Gets the weight of the runtime animation
  18481. */
  18482. readonly weight: number;
  18483. /**
  18484. * Gets the current value of the runtime animation
  18485. */
  18486. readonly currentValue: any;
  18487. /**
  18488. * Gets the target path of the runtime animation
  18489. */
  18490. readonly targetPath: string;
  18491. /**
  18492. * Gets the actual target of the runtime animation
  18493. */
  18494. readonly target: any;
  18495. /**
  18496. * Create a new RuntimeAnimation object
  18497. * @param target defines the target of the animation
  18498. * @param animation defines the source animation object
  18499. * @param scene defines the hosting scene
  18500. * @param host defines the initiating Animatable
  18501. */
  18502. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18503. /**
  18504. * Gets the animation from the runtime animation
  18505. */
  18506. readonly animation: Animation;
  18507. /**
  18508. * Resets the runtime animation to the beginning
  18509. * @param restoreOriginal defines whether to restore the target property to the original value
  18510. */
  18511. reset(restoreOriginal?: boolean): void;
  18512. /**
  18513. * Specifies if the runtime animation is stopped
  18514. * @returns Boolean specifying if the runtime animation is stopped
  18515. */
  18516. isStopped(): boolean;
  18517. /**
  18518. * Disposes of the runtime animation
  18519. */
  18520. dispose(): void;
  18521. /**
  18522. * Interpolates the animation from the current frame
  18523. * @param currentFrame The frame to interpolate the animation to
  18524. * @param repeatCount The number of times that the animation should loop
  18525. * @param loopMode The type of looping mode to use
  18526. * @param offsetValue Animation offset value
  18527. * @param highLimitValue The high limit value
  18528. * @returns The interpolated value
  18529. */
  18530. private _interpolate;
  18531. /**
  18532. * Apply the interpolated value to the target
  18533. * @param currentValue defines the value computed by the animation
  18534. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18535. */
  18536. setValue(currentValue: any, weight?: number): void;
  18537. private _setValue;
  18538. /**
  18539. * Gets the loop pmode of the runtime animation
  18540. * @returns Loop Mode
  18541. */
  18542. private _getCorrectLoopMode;
  18543. /**
  18544. * Move the current animation to a given frame
  18545. * @param frame defines the frame to move to
  18546. */
  18547. goToFrame(frame: number): void;
  18548. /**
  18549. * @hidden Internal use only
  18550. */
  18551. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18552. /**
  18553. * Execute the current animation
  18554. * @param delay defines the delay to add to the current frame
  18555. * @param from defines the lower bound of the animation range
  18556. * @param to defines the upper bound of the animation range
  18557. * @param loop defines if the current animation must loop
  18558. * @param speedRatio defines the current speed ratio
  18559. * @param weight defines the weight of the animation (default is -1 so no weight)
  18560. * @param onLoop optional callback called when animation loops
  18561. * @returns a boolean indicating if the animation is running
  18562. */
  18563. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18564. }
  18565. }
  18566. declare module "babylonjs/Animations/animatable" {
  18567. import { Animation } from "babylonjs/Animations/animation";
  18568. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18569. import { Nullable } from "babylonjs/types";
  18570. import { Observable } from "babylonjs/Misc/observable";
  18571. import { Scene } from "babylonjs/scene";
  18572. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18573. import { Node } from "babylonjs/node";
  18574. /**
  18575. * Class used to store an actual running animation
  18576. */
  18577. export class Animatable {
  18578. /** defines the target object */
  18579. target: any;
  18580. /** defines the starting frame number (default is 0) */
  18581. fromFrame: number;
  18582. /** defines the ending frame number (default is 100) */
  18583. toFrame: number;
  18584. /** defines if the animation must loop (default is false) */
  18585. loopAnimation: boolean;
  18586. /** defines a callback to call when animation ends if it is not looping */
  18587. onAnimationEnd?: (() => void) | null | undefined;
  18588. /** defines a callback to call when animation loops */
  18589. onAnimationLoop?: (() => void) | null | undefined;
  18590. private _localDelayOffset;
  18591. private _pausedDelay;
  18592. private _runtimeAnimations;
  18593. private _paused;
  18594. private _scene;
  18595. private _speedRatio;
  18596. private _weight;
  18597. private _syncRoot;
  18598. /**
  18599. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18600. * This will only apply for non looping animation (default is true)
  18601. */
  18602. disposeOnEnd: boolean;
  18603. /**
  18604. * Gets a boolean indicating if the animation has started
  18605. */
  18606. animationStarted: boolean;
  18607. /**
  18608. * Observer raised when the animation ends
  18609. */
  18610. onAnimationEndObservable: Observable<Animatable>;
  18611. /**
  18612. * Observer raised when the animation loops
  18613. */
  18614. onAnimationLoopObservable: Observable<Animatable>;
  18615. /**
  18616. * Gets the root Animatable used to synchronize and normalize animations
  18617. */
  18618. readonly syncRoot: Animatable;
  18619. /**
  18620. * Gets the current frame of the first RuntimeAnimation
  18621. * Used to synchronize Animatables
  18622. */
  18623. readonly masterFrame: number;
  18624. /**
  18625. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18626. */
  18627. weight: number;
  18628. /**
  18629. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18630. */
  18631. speedRatio: number;
  18632. /**
  18633. * Creates a new Animatable
  18634. * @param scene defines the hosting scene
  18635. * @param target defines the target object
  18636. * @param fromFrame defines the starting frame number (default is 0)
  18637. * @param toFrame defines the ending frame number (default is 100)
  18638. * @param loopAnimation defines if the animation must loop (default is false)
  18639. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18640. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18641. * @param animations defines a group of animation to add to the new Animatable
  18642. * @param onAnimationLoop defines a callback to call when animation loops
  18643. */
  18644. constructor(scene: Scene,
  18645. /** defines the target object */
  18646. target: any,
  18647. /** defines the starting frame number (default is 0) */
  18648. fromFrame?: number,
  18649. /** defines the ending frame number (default is 100) */
  18650. toFrame?: number,
  18651. /** defines if the animation must loop (default is false) */
  18652. loopAnimation?: boolean, speedRatio?: number,
  18653. /** defines a callback to call when animation ends if it is not looping */
  18654. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18655. /** defines a callback to call when animation loops */
  18656. onAnimationLoop?: (() => void) | null | undefined);
  18657. /**
  18658. * Synchronize and normalize current Animatable with a source Animatable
  18659. * This is useful when using animation weights and when animations are not of the same length
  18660. * @param root defines the root Animatable to synchronize with
  18661. * @returns the current Animatable
  18662. */
  18663. syncWith(root: Animatable): Animatable;
  18664. /**
  18665. * Gets the list of runtime animations
  18666. * @returns an array of RuntimeAnimation
  18667. */
  18668. getAnimations(): RuntimeAnimation[];
  18669. /**
  18670. * Adds more animations to the current animatable
  18671. * @param target defines the target of the animations
  18672. * @param animations defines the new animations to add
  18673. */
  18674. appendAnimations(target: any, animations: Animation[]): void;
  18675. /**
  18676. * Gets the source animation for a specific property
  18677. * @param property defines the propertyu to look for
  18678. * @returns null or the source animation for the given property
  18679. */
  18680. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18681. /**
  18682. * Gets the runtime animation for a specific property
  18683. * @param property defines the propertyu to look for
  18684. * @returns null or the runtime animation for the given property
  18685. */
  18686. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18687. /**
  18688. * Resets the animatable to its original state
  18689. */
  18690. reset(): void;
  18691. /**
  18692. * Allows the animatable to blend with current running animations
  18693. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18694. * @param blendingSpeed defines the blending speed to use
  18695. */
  18696. enableBlending(blendingSpeed: number): void;
  18697. /**
  18698. * Disable animation blending
  18699. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18700. */
  18701. disableBlending(): void;
  18702. /**
  18703. * Jump directly to a given frame
  18704. * @param frame defines the frame to jump to
  18705. */
  18706. goToFrame(frame: number): void;
  18707. /**
  18708. * Pause the animation
  18709. */
  18710. pause(): void;
  18711. /**
  18712. * Restart the animation
  18713. */
  18714. restart(): void;
  18715. private _raiseOnAnimationEnd;
  18716. /**
  18717. * Stop and delete the current animation
  18718. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18719. * @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)
  18720. */
  18721. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18722. /**
  18723. * Wait asynchronously for the animation to end
  18724. * @returns a promise which will be fullfilled when the animation ends
  18725. */
  18726. waitAsync(): Promise<Animatable>;
  18727. /** @hidden */
  18728. _animate(delay: number): boolean;
  18729. }
  18730. module "babylonjs/scene" {
  18731. interface Scene {
  18732. /** @hidden */
  18733. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18734. /** @hidden */
  18735. _processLateAnimationBindingsForMatrices(holder: {
  18736. totalWeight: number;
  18737. animations: RuntimeAnimation[];
  18738. originalValue: Matrix;
  18739. }): any;
  18740. /** @hidden */
  18741. _processLateAnimationBindingsForQuaternions(holder: {
  18742. totalWeight: number;
  18743. animations: RuntimeAnimation[];
  18744. originalValue: Quaternion;
  18745. }, refQuaternion: Quaternion): Quaternion;
  18746. /** @hidden */
  18747. _processLateAnimationBindings(): void;
  18748. /**
  18749. * Will start the animation sequence of a given target
  18750. * @param target defines the target
  18751. * @param from defines from which frame should animation start
  18752. * @param to defines until which frame should animation run.
  18753. * @param weight defines the weight to apply to the animation (1.0 by default)
  18754. * @param loop defines if the animation loops
  18755. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18756. * @param onAnimationEnd defines the function to be executed when the animation ends
  18757. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18758. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18759. * @param onAnimationLoop defines the callback to call when an animation loops
  18760. * @returns the animatable object created for this animation
  18761. */
  18762. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18763. /**
  18764. * Will start the animation sequence of a given target
  18765. * @param target defines the target
  18766. * @param from defines from which frame should animation start
  18767. * @param to defines until which frame should animation run.
  18768. * @param loop defines if the animation loops
  18769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18770. * @param onAnimationEnd defines the function to be executed when the animation ends
  18771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18772. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18773. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18774. * @param onAnimationLoop defines the callback to call when an animation loops
  18775. * @returns the animatable object created for this animation
  18776. */
  18777. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18778. /**
  18779. * Will start the animation sequence of a given target and its hierarchy
  18780. * @param target defines the target
  18781. * @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.
  18782. * @param from defines from which frame should animation start
  18783. * @param to defines until which frame should animation run.
  18784. * @param loop defines if the animation loops
  18785. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18786. * @param onAnimationEnd defines the function to be executed when the animation ends
  18787. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18788. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18789. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18790. * @param onAnimationLoop defines the callback to call when an animation loops
  18791. * @returns the list of created animatables
  18792. */
  18793. 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[];
  18794. /**
  18795. * Begin a new animation on a given node
  18796. * @param target defines the target where the animation will take place
  18797. * @param animations defines the list of animations to start
  18798. * @param from defines the initial value
  18799. * @param to defines the final value
  18800. * @param loop defines if you want animation to loop (off by default)
  18801. * @param speedRatio defines the speed ratio to apply to all animations
  18802. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18803. * @param onAnimationLoop defines the callback to call when an animation loops
  18804. * @returns the list of created animatables
  18805. */
  18806. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18807. /**
  18808. * Begin a new animation on a given node and its hierarchy
  18809. * @param target defines the root node where the animation will take place
  18810. * @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.
  18811. * @param animations defines the list of animations to start
  18812. * @param from defines the initial value
  18813. * @param to defines the final value
  18814. * @param loop defines if you want animation to loop (off by default)
  18815. * @param speedRatio defines the speed ratio to apply to all animations
  18816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18817. * @param onAnimationLoop defines the callback to call when an animation loops
  18818. * @returns the list of animatables created for all nodes
  18819. */
  18820. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18821. /**
  18822. * Gets the animatable associated with a specific target
  18823. * @param target defines the target of the animatable
  18824. * @returns the required animatable if found
  18825. */
  18826. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18827. /**
  18828. * Gets all animatables associated with a given target
  18829. * @param target defines the target to look animatables for
  18830. * @returns an array of Animatables
  18831. */
  18832. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18833. /**
  18834. * Will stop the animation of the given target
  18835. * @param target - the target
  18836. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18837. * @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)
  18838. */
  18839. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18840. /**
  18841. * Stops and removes all animations that have been applied to the scene
  18842. */
  18843. stopAllAnimations(): void;
  18844. }
  18845. }
  18846. module "babylonjs/Bones/bone" {
  18847. interface Bone {
  18848. /**
  18849. * Copy an animation range from another bone
  18850. * @param source defines the source bone
  18851. * @param rangeName defines the range name to copy
  18852. * @param frameOffset defines the frame offset
  18853. * @param rescaleAsRequired defines if rescaling must be applied if required
  18854. * @param skelDimensionsRatio defines the scaling ratio
  18855. * @returns true if operation was successful
  18856. */
  18857. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18858. }
  18859. }
  18860. }
  18861. declare module "babylonjs/Bones/skeleton" {
  18862. import { Bone } from "babylonjs/Bones/bone";
  18863. import { IAnimatable } from "babylonjs/Misc/tools";
  18864. import { Observable } from "babylonjs/Misc/observable";
  18865. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18866. import { Scene } from "babylonjs/scene";
  18867. import { Nullable } from "babylonjs/types";
  18868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18869. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18870. import { Animatable } from "babylonjs/Animations/animatable";
  18871. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18872. import { Animation } from "babylonjs/Animations/animation";
  18873. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18874. /**
  18875. * Class used to handle skinning animations
  18876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18877. */
  18878. export class Skeleton implements IAnimatable {
  18879. /** defines the skeleton name */
  18880. name: string;
  18881. /** defines the skeleton Id */
  18882. id: string;
  18883. /**
  18884. * Defines the list of child bones
  18885. */
  18886. bones: Bone[];
  18887. /**
  18888. * Defines an estimate of the dimension of the skeleton at rest
  18889. */
  18890. dimensionsAtRest: Vector3;
  18891. /**
  18892. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18893. */
  18894. needInitialSkinMatrix: boolean;
  18895. /**
  18896. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18897. */
  18898. overrideMesh: Nullable<AbstractMesh>;
  18899. /**
  18900. * Gets the list of animations attached to this skeleton
  18901. */
  18902. animations: Array<Animation>;
  18903. private _scene;
  18904. private _isDirty;
  18905. private _transformMatrices;
  18906. private _transformMatrixTexture;
  18907. private _meshesWithPoseMatrix;
  18908. private _animatables;
  18909. private _identity;
  18910. private _synchronizedWithMesh;
  18911. private _ranges;
  18912. private _lastAbsoluteTransformsUpdateId;
  18913. private _canUseTextureForBones;
  18914. /** @hidden */
  18915. _numBonesWithLinkedTransformNode: number;
  18916. /**
  18917. * Specifies if the skeleton should be serialized
  18918. */
  18919. doNotSerialize: boolean;
  18920. /**
  18921. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18922. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18923. */
  18924. useTextureToStoreBoneMatrices: boolean;
  18925. private _animationPropertiesOverride;
  18926. /**
  18927. * Gets or sets the animation properties override
  18928. */
  18929. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18930. /**
  18931. * An observable triggered before computing the skeleton's matrices
  18932. */
  18933. onBeforeComputeObservable: Observable<Skeleton>;
  18934. /**
  18935. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18936. */
  18937. readonly isUsingTextureForMatrices: boolean;
  18938. /**
  18939. * Creates a new skeleton
  18940. * @param name defines the skeleton name
  18941. * @param id defines the skeleton Id
  18942. * @param scene defines the hosting scene
  18943. */
  18944. constructor(
  18945. /** defines the skeleton name */
  18946. name: string,
  18947. /** defines the skeleton Id */
  18948. id: string, scene: Scene);
  18949. /**
  18950. * Gets the current object class name.
  18951. * @return the class name
  18952. */
  18953. getClassName(): string;
  18954. /**
  18955. * Returns an array containing the root bones
  18956. * @returns an array containing the root bones
  18957. */
  18958. getChildren(): Array<Bone>;
  18959. /**
  18960. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18961. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18962. * @returns a Float32Array containing matrices data
  18963. */
  18964. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18965. /**
  18966. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18967. * @returns a raw texture containing the data
  18968. */
  18969. getTransformMatrixTexture(): Nullable<RawTexture>;
  18970. /**
  18971. * Gets the current hosting scene
  18972. * @returns a scene object
  18973. */
  18974. getScene(): Scene;
  18975. /**
  18976. * Gets a string representing the current skeleton data
  18977. * @param fullDetails defines a boolean indicating if we want a verbose version
  18978. * @returns a string representing the current skeleton data
  18979. */
  18980. toString(fullDetails?: boolean): string;
  18981. /**
  18982. * Get bone's index searching by name
  18983. * @param name defines bone's name to search for
  18984. * @return the indice of the bone. Returns -1 if not found
  18985. */
  18986. getBoneIndexByName(name: string): number;
  18987. /**
  18988. * Creater a new animation range
  18989. * @param name defines the name of the range
  18990. * @param from defines the start key
  18991. * @param to defines the end key
  18992. */
  18993. createAnimationRange(name: string, from: number, to: number): void;
  18994. /**
  18995. * Delete a specific animation range
  18996. * @param name defines the name of the range
  18997. * @param deleteFrames defines if frames must be removed as well
  18998. */
  18999. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19000. /**
  19001. * Gets a specific animation range
  19002. * @param name defines the name of the range to look for
  19003. * @returns the requested animation range or null if not found
  19004. */
  19005. getAnimationRange(name: string): Nullable<AnimationRange>;
  19006. /**
  19007. * Gets the list of all animation ranges defined on this skeleton
  19008. * @returns an array
  19009. */
  19010. getAnimationRanges(): Nullable<AnimationRange>[];
  19011. /**
  19012. * Copy animation range from a source skeleton.
  19013. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19014. * @param source defines the source skeleton
  19015. * @param name defines the name of the range to copy
  19016. * @param rescaleAsRequired defines if rescaling must be applied if required
  19017. * @returns true if operation was successful
  19018. */
  19019. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19020. /**
  19021. * Forces the skeleton to go to rest pose
  19022. */
  19023. returnToRest(): void;
  19024. private _getHighestAnimationFrame;
  19025. /**
  19026. * Begin a specific animation range
  19027. * @param name defines the name of the range to start
  19028. * @param loop defines if looping must be turned on (false by default)
  19029. * @param speedRatio defines the speed ratio to apply (1 by default)
  19030. * @param onAnimationEnd defines a callback which will be called when animation will end
  19031. * @returns a new animatable
  19032. */
  19033. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19034. /** @hidden */
  19035. _markAsDirty(): void;
  19036. /** @hidden */
  19037. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19038. /** @hidden */
  19039. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19040. private _computeTransformMatrices;
  19041. /**
  19042. * Build all resources required to render a skeleton
  19043. */
  19044. prepare(): void;
  19045. /**
  19046. * Gets the list of animatables currently running for this skeleton
  19047. * @returns an array of animatables
  19048. */
  19049. getAnimatables(): IAnimatable[];
  19050. /**
  19051. * Clone the current skeleton
  19052. * @param name defines the name of the new skeleton
  19053. * @param id defines the id of the enw skeleton
  19054. * @returns the new skeleton
  19055. */
  19056. clone(name: string, id: string): Skeleton;
  19057. /**
  19058. * Enable animation blending for this skeleton
  19059. * @param blendingSpeed defines the blending speed to apply
  19060. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19061. */
  19062. enableBlending(blendingSpeed?: number): void;
  19063. /**
  19064. * Releases all resources associated with the current skeleton
  19065. */
  19066. dispose(): void;
  19067. /**
  19068. * Serialize the skeleton in a JSON object
  19069. * @returns a JSON object
  19070. */
  19071. serialize(): any;
  19072. /**
  19073. * Creates a new skeleton from serialized data
  19074. * @param parsedSkeleton defines the serialized data
  19075. * @param scene defines the hosting scene
  19076. * @returns a new skeleton
  19077. */
  19078. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19079. /**
  19080. * Compute all node absolute transforms
  19081. * @param forceUpdate defines if computation must be done even if cache is up to date
  19082. */
  19083. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19084. /**
  19085. * Gets the root pose matrix
  19086. * @returns a matrix
  19087. */
  19088. getPoseMatrix(): Nullable<Matrix>;
  19089. /**
  19090. * Sorts bones per internal index
  19091. */
  19092. sortBones(): void;
  19093. private _sortBones;
  19094. }
  19095. }
  19096. declare module "babylonjs/Morph/morphTarget" {
  19097. import { IAnimatable } from "babylonjs/Misc/tools";
  19098. import { Observable } from "babylonjs/Misc/observable";
  19099. import { Nullable, FloatArray } from "babylonjs/types";
  19100. import { Scene } from "babylonjs/scene";
  19101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19102. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19103. /**
  19104. * Defines a target to use with MorphTargetManager
  19105. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19106. */
  19107. export class MorphTarget implements IAnimatable {
  19108. /** defines the name of the target */
  19109. name: string;
  19110. /**
  19111. * Gets or sets the list of animations
  19112. */
  19113. animations: import("babylonjs/Animations/animation").Animation[];
  19114. private _scene;
  19115. private _positions;
  19116. private _normals;
  19117. private _tangents;
  19118. private _influence;
  19119. /**
  19120. * Observable raised when the influence changes
  19121. */
  19122. onInfluenceChanged: Observable<boolean>;
  19123. /** @hidden */
  19124. _onDataLayoutChanged: Observable<void>;
  19125. /**
  19126. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19127. */
  19128. influence: number;
  19129. /**
  19130. * Gets or sets the id of the morph Target
  19131. */
  19132. id: string;
  19133. private _animationPropertiesOverride;
  19134. /**
  19135. * Gets or sets the animation properties override
  19136. */
  19137. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19138. /**
  19139. * Creates a new MorphTarget
  19140. * @param name defines the name of the target
  19141. * @param influence defines the influence to use
  19142. * @param scene defines the scene the morphtarget belongs to
  19143. */
  19144. constructor(
  19145. /** defines the name of the target */
  19146. name: string, influence?: number, scene?: Nullable<Scene>);
  19147. /**
  19148. * Gets a boolean defining if the target contains position data
  19149. */
  19150. readonly hasPositions: boolean;
  19151. /**
  19152. * Gets a boolean defining if the target contains normal data
  19153. */
  19154. readonly hasNormals: boolean;
  19155. /**
  19156. * Gets a boolean defining if the target contains tangent data
  19157. */
  19158. readonly hasTangents: boolean;
  19159. /**
  19160. * Affects position data to this target
  19161. * @param data defines the position data to use
  19162. */
  19163. setPositions(data: Nullable<FloatArray>): void;
  19164. /**
  19165. * Gets the position data stored in this target
  19166. * @returns a FloatArray containing the position data (or null if not present)
  19167. */
  19168. getPositions(): Nullable<FloatArray>;
  19169. /**
  19170. * Affects normal data to this target
  19171. * @param data defines the normal data to use
  19172. */
  19173. setNormals(data: Nullable<FloatArray>): void;
  19174. /**
  19175. * Gets the normal data stored in this target
  19176. * @returns a FloatArray containing the normal data (or null if not present)
  19177. */
  19178. getNormals(): Nullable<FloatArray>;
  19179. /**
  19180. * Affects tangent data to this target
  19181. * @param data defines the tangent data to use
  19182. */
  19183. setTangents(data: Nullable<FloatArray>): void;
  19184. /**
  19185. * Gets the tangent data stored in this target
  19186. * @returns a FloatArray containing the tangent data (or null if not present)
  19187. */
  19188. getTangents(): Nullable<FloatArray>;
  19189. /**
  19190. * Serializes the current target into a Serialization object
  19191. * @returns the serialized object
  19192. */
  19193. serialize(): any;
  19194. /**
  19195. * Returns the string "MorphTarget"
  19196. * @returns "MorphTarget"
  19197. */
  19198. getClassName(): string;
  19199. /**
  19200. * Creates a new target from serialized data
  19201. * @param serializationObject defines the serialized data to use
  19202. * @returns a new MorphTarget
  19203. */
  19204. static Parse(serializationObject: any): MorphTarget;
  19205. /**
  19206. * Creates a MorphTarget from mesh data
  19207. * @param mesh defines the source mesh
  19208. * @param name defines the name to use for the new target
  19209. * @param influence defines the influence to attach to the target
  19210. * @returns a new MorphTarget
  19211. */
  19212. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19213. }
  19214. }
  19215. declare module "babylonjs/Morph/morphTargetManager" {
  19216. import { Nullable } from "babylonjs/types";
  19217. import { Scene } from "babylonjs/scene";
  19218. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19219. /**
  19220. * This class is used to deform meshes using morphing between different targets
  19221. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19222. */
  19223. export class MorphTargetManager {
  19224. private _targets;
  19225. private _targetInfluenceChangedObservers;
  19226. private _targetDataLayoutChangedObservers;
  19227. private _activeTargets;
  19228. private _scene;
  19229. private _influences;
  19230. private _supportsNormals;
  19231. private _supportsTangents;
  19232. private _vertexCount;
  19233. private _uniqueId;
  19234. private _tempInfluences;
  19235. /**
  19236. * Creates a new MorphTargetManager
  19237. * @param scene defines the current scene
  19238. */
  19239. constructor(scene?: Nullable<Scene>);
  19240. /**
  19241. * Gets the unique ID of this manager
  19242. */
  19243. readonly uniqueId: number;
  19244. /**
  19245. * Gets the number of vertices handled by this manager
  19246. */
  19247. readonly vertexCount: number;
  19248. /**
  19249. * Gets a boolean indicating if this manager supports morphing of normals
  19250. */
  19251. readonly supportsNormals: boolean;
  19252. /**
  19253. * Gets a boolean indicating if this manager supports morphing of tangents
  19254. */
  19255. readonly supportsTangents: boolean;
  19256. /**
  19257. * Gets the number of targets stored in this manager
  19258. */
  19259. readonly numTargets: number;
  19260. /**
  19261. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19262. */
  19263. readonly numInfluencers: number;
  19264. /**
  19265. * Gets the list of influences (one per target)
  19266. */
  19267. readonly influences: Float32Array;
  19268. /**
  19269. * Gets the active target at specified index. An active target is a target with an influence > 0
  19270. * @param index defines the index to check
  19271. * @returns the requested target
  19272. */
  19273. getActiveTarget(index: number): MorphTarget;
  19274. /**
  19275. * Gets the target at specified index
  19276. * @param index defines the index to check
  19277. * @returns the requested target
  19278. */
  19279. getTarget(index: number): MorphTarget;
  19280. /**
  19281. * Add a new target to this manager
  19282. * @param target defines the target to add
  19283. */
  19284. addTarget(target: MorphTarget): void;
  19285. /**
  19286. * Removes a target from the manager
  19287. * @param target defines the target to remove
  19288. */
  19289. removeTarget(target: MorphTarget): void;
  19290. /**
  19291. * Serializes the current manager into a Serialization object
  19292. * @returns the serialized object
  19293. */
  19294. serialize(): any;
  19295. private _syncActiveTargets;
  19296. /**
  19297. * Syncrhonize the targets with all the meshes using this morph target manager
  19298. */
  19299. synchronize(): void;
  19300. /**
  19301. * Creates a new MorphTargetManager from serialized data
  19302. * @param serializationObject defines the serialized data
  19303. * @param scene defines the hosting scene
  19304. * @returns the new MorphTargetManager
  19305. */
  19306. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19307. }
  19308. }
  19309. declare module "babylonjs/Meshes/groundMesh" {
  19310. import { Scene } from "babylonjs/scene";
  19311. import { Vector3 } from "babylonjs/Maths/math";
  19312. import { Mesh } from "babylonjs/Meshes/mesh";
  19313. /**
  19314. * Mesh representing the gorund
  19315. */
  19316. export class GroundMesh extends Mesh {
  19317. /** If octree should be generated */
  19318. generateOctree: boolean;
  19319. private _heightQuads;
  19320. /** @hidden */
  19321. _subdivisionsX: number;
  19322. /** @hidden */
  19323. _subdivisionsY: number;
  19324. /** @hidden */
  19325. _width: number;
  19326. /** @hidden */
  19327. _height: number;
  19328. /** @hidden */
  19329. _minX: number;
  19330. /** @hidden */
  19331. _maxX: number;
  19332. /** @hidden */
  19333. _minZ: number;
  19334. /** @hidden */
  19335. _maxZ: number;
  19336. constructor(name: string, scene: Scene);
  19337. /**
  19338. * "GroundMesh"
  19339. * @returns "GroundMesh"
  19340. */
  19341. getClassName(): string;
  19342. /**
  19343. * The minimum of x and y subdivisions
  19344. */
  19345. readonly subdivisions: number;
  19346. /**
  19347. * X subdivisions
  19348. */
  19349. readonly subdivisionsX: number;
  19350. /**
  19351. * Y subdivisions
  19352. */
  19353. readonly subdivisionsY: number;
  19354. /**
  19355. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19356. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19357. * @param chunksCount the number of subdivisions for x and y
  19358. * @param octreeBlocksSize (Default: 32)
  19359. */
  19360. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19361. /**
  19362. * Returns a height (y) value in the Worl system :
  19363. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19364. * @param x x coordinate
  19365. * @param z z coordinate
  19366. * @returns the ground y position if (x, z) are outside the ground surface.
  19367. */
  19368. getHeightAtCoordinates(x: number, z: number): number;
  19369. /**
  19370. * Returns a normalized vector (Vector3) orthogonal to the ground
  19371. * at the ground coordinates (x, z) expressed in the World system.
  19372. * @param x x coordinate
  19373. * @param z z coordinate
  19374. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19375. */
  19376. getNormalAtCoordinates(x: number, z: number): Vector3;
  19377. /**
  19378. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19379. * at the ground coordinates (x, z) expressed in the World system.
  19380. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19381. * @param x x coordinate
  19382. * @param z z coordinate
  19383. * @param ref vector to store the result
  19384. * @returns the GroundMesh.
  19385. */
  19386. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19387. /**
  19388. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19389. * if the ground has been updated.
  19390. * This can be used in the render loop.
  19391. * @returns the GroundMesh.
  19392. */
  19393. updateCoordinateHeights(): GroundMesh;
  19394. private _getFacetAt;
  19395. private _initHeightQuads;
  19396. private _computeHeightQuads;
  19397. /**
  19398. * Serializes this ground mesh
  19399. * @param serializationObject object to write serialization to
  19400. */
  19401. serialize(serializationObject: any): void;
  19402. /**
  19403. * Parses a serialized ground mesh
  19404. * @param parsedMesh the serialized mesh
  19405. * @param scene the scene to create the ground mesh in
  19406. * @returns the created ground mesh
  19407. */
  19408. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19409. }
  19410. }
  19411. declare module "babylonjs/Physics/physicsJoint" {
  19412. import { Vector3 } from "babylonjs/Maths/math";
  19413. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19414. /**
  19415. * Interface for Physics-Joint data
  19416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19417. */
  19418. export interface PhysicsJointData {
  19419. /**
  19420. * The main pivot of the joint
  19421. */
  19422. mainPivot?: Vector3;
  19423. /**
  19424. * The connected pivot of the joint
  19425. */
  19426. connectedPivot?: Vector3;
  19427. /**
  19428. * The main axis of the joint
  19429. */
  19430. mainAxis?: Vector3;
  19431. /**
  19432. * The connected axis of the joint
  19433. */
  19434. connectedAxis?: Vector3;
  19435. /**
  19436. * The collision of the joint
  19437. */
  19438. collision?: boolean;
  19439. /**
  19440. * Native Oimo/Cannon/Energy data
  19441. */
  19442. nativeParams?: any;
  19443. }
  19444. /**
  19445. * This is a holder class for the physics joint created by the physics plugin
  19446. * It holds a set of functions to control the underlying joint
  19447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19448. */
  19449. export class PhysicsJoint {
  19450. /**
  19451. * The type of the physics joint
  19452. */
  19453. type: number;
  19454. /**
  19455. * The data for the physics joint
  19456. */
  19457. jointData: PhysicsJointData;
  19458. private _physicsJoint;
  19459. protected _physicsPlugin: IPhysicsEnginePlugin;
  19460. /**
  19461. * Initializes the physics joint
  19462. * @param type The type of the physics joint
  19463. * @param jointData The data for the physics joint
  19464. */
  19465. constructor(
  19466. /**
  19467. * The type of the physics joint
  19468. */
  19469. type: number,
  19470. /**
  19471. * The data for the physics joint
  19472. */
  19473. jointData: PhysicsJointData);
  19474. /**
  19475. * Gets the physics joint
  19476. */
  19477. /**
  19478. * Sets the physics joint
  19479. */
  19480. physicsJoint: any;
  19481. /**
  19482. * Sets the physics plugin
  19483. */
  19484. physicsPlugin: IPhysicsEnginePlugin;
  19485. /**
  19486. * Execute a function that is physics-plugin specific.
  19487. * @param {Function} func the function that will be executed.
  19488. * It accepts two parameters: the physics world and the physics joint
  19489. */
  19490. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19491. /**
  19492. * Distance-Joint type
  19493. */
  19494. static DistanceJoint: number;
  19495. /**
  19496. * Hinge-Joint type
  19497. */
  19498. static HingeJoint: number;
  19499. /**
  19500. * Ball-and-Socket joint type
  19501. */
  19502. static BallAndSocketJoint: number;
  19503. /**
  19504. * Wheel-Joint type
  19505. */
  19506. static WheelJoint: number;
  19507. /**
  19508. * Slider-Joint type
  19509. */
  19510. static SliderJoint: number;
  19511. /**
  19512. * Prismatic-Joint type
  19513. */
  19514. static PrismaticJoint: number;
  19515. /**
  19516. * Universal-Joint type
  19517. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19518. */
  19519. static UniversalJoint: number;
  19520. /**
  19521. * Hinge-Joint 2 type
  19522. */
  19523. static Hinge2Joint: number;
  19524. /**
  19525. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19526. */
  19527. static PointToPointJoint: number;
  19528. /**
  19529. * Spring-Joint type
  19530. */
  19531. static SpringJoint: number;
  19532. /**
  19533. * Lock-Joint type
  19534. */
  19535. static LockJoint: number;
  19536. }
  19537. /**
  19538. * A class representing a physics distance joint
  19539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19540. */
  19541. export class DistanceJoint extends PhysicsJoint {
  19542. /**
  19543. *
  19544. * @param jointData The data for the Distance-Joint
  19545. */
  19546. constructor(jointData: DistanceJointData);
  19547. /**
  19548. * Update the predefined distance.
  19549. * @param maxDistance The maximum preferred distance
  19550. * @param minDistance The minimum preferred distance
  19551. */
  19552. updateDistance(maxDistance: number, minDistance?: number): void;
  19553. }
  19554. /**
  19555. * Represents a Motor-Enabled Joint
  19556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19557. */
  19558. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19559. /**
  19560. * Initializes the Motor-Enabled Joint
  19561. * @param type The type of the joint
  19562. * @param jointData The physica joint data for the joint
  19563. */
  19564. constructor(type: number, jointData: PhysicsJointData);
  19565. /**
  19566. * Set the motor values.
  19567. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19568. * @param force the force to apply
  19569. * @param maxForce max force for this motor.
  19570. */
  19571. setMotor(force?: number, maxForce?: number): void;
  19572. /**
  19573. * Set the motor's limits.
  19574. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19575. * @param upperLimit The upper limit of the motor
  19576. * @param lowerLimit The lower limit of the motor
  19577. */
  19578. setLimit(upperLimit: number, lowerLimit?: number): void;
  19579. }
  19580. /**
  19581. * This class represents a single physics Hinge-Joint
  19582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19583. */
  19584. export class HingeJoint extends MotorEnabledJoint {
  19585. /**
  19586. * Initializes the Hinge-Joint
  19587. * @param jointData The joint data for the Hinge-Joint
  19588. */
  19589. constructor(jointData: PhysicsJointData);
  19590. /**
  19591. * Set the motor values.
  19592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19593. * @param {number} force the force to apply
  19594. * @param {number} maxForce max force for this motor.
  19595. */
  19596. setMotor(force?: number, maxForce?: number): void;
  19597. /**
  19598. * Set the motor's limits.
  19599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19600. * @param upperLimit The upper limit of the motor
  19601. * @param lowerLimit The lower limit of the motor
  19602. */
  19603. setLimit(upperLimit: number, lowerLimit?: number): void;
  19604. }
  19605. /**
  19606. * This class represents a dual hinge physics joint (same as wheel joint)
  19607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19608. */
  19609. export class Hinge2Joint extends MotorEnabledJoint {
  19610. /**
  19611. * Initializes the Hinge2-Joint
  19612. * @param jointData The joint data for the Hinge2-Joint
  19613. */
  19614. constructor(jointData: PhysicsJointData);
  19615. /**
  19616. * Set the motor values.
  19617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19618. * @param {number} targetSpeed the speed the motor is to reach
  19619. * @param {number} maxForce max force for this motor.
  19620. * @param {motorIndex} the motor's index, 0 or 1.
  19621. */
  19622. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19623. /**
  19624. * Set the motor limits.
  19625. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19626. * @param {number} upperLimit the upper limit
  19627. * @param {number} lowerLimit lower limit
  19628. * @param {motorIndex} the motor's index, 0 or 1.
  19629. */
  19630. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19631. }
  19632. /**
  19633. * Interface for a motor enabled joint
  19634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19635. */
  19636. export interface IMotorEnabledJoint {
  19637. /**
  19638. * Physics joint
  19639. */
  19640. physicsJoint: any;
  19641. /**
  19642. * Sets the motor of the motor-enabled joint
  19643. * @param force The force of the motor
  19644. * @param maxForce The maximum force of the motor
  19645. * @param motorIndex The index of the motor
  19646. */
  19647. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19648. /**
  19649. * Sets the limit of the motor
  19650. * @param upperLimit The upper limit of the motor
  19651. * @param lowerLimit The lower limit of the motor
  19652. * @param motorIndex The index of the motor
  19653. */
  19654. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19655. }
  19656. /**
  19657. * Joint data for a Distance-Joint
  19658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19659. */
  19660. export interface DistanceJointData extends PhysicsJointData {
  19661. /**
  19662. * Max distance the 2 joint objects can be apart
  19663. */
  19664. maxDistance: number;
  19665. }
  19666. /**
  19667. * Joint data from a spring joint
  19668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19669. */
  19670. export interface SpringJointData extends PhysicsJointData {
  19671. /**
  19672. * Length of the spring
  19673. */
  19674. length: number;
  19675. /**
  19676. * Stiffness of the spring
  19677. */
  19678. stiffness: number;
  19679. /**
  19680. * Damping of the spring
  19681. */
  19682. damping: number;
  19683. /** this callback will be called when applying the force to the impostors. */
  19684. forceApplicationCallback: () => void;
  19685. }
  19686. }
  19687. declare module "babylonjs/Physics/IPhysicsEngine" {
  19688. import { Nullable } from "babylonjs/types";
  19689. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19691. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19692. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19693. /**
  19694. * Interface used to describe a physics joint
  19695. */
  19696. export interface PhysicsImpostorJoint {
  19697. /** Defines the main impostor to which the joint is linked */
  19698. mainImpostor: PhysicsImpostor;
  19699. /** Defines the impostor that is connected to the main impostor using this joint */
  19700. connectedImpostor: PhysicsImpostor;
  19701. /** Defines the joint itself */
  19702. joint: PhysicsJoint;
  19703. }
  19704. /** @hidden */
  19705. export interface IPhysicsEnginePlugin {
  19706. world: any;
  19707. name: string;
  19708. setGravity(gravity: Vector3): void;
  19709. setTimeStep(timeStep: number): void;
  19710. getTimeStep(): number;
  19711. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19712. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19713. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19715. removePhysicsBody(impostor: PhysicsImpostor): void;
  19716. generateJoint(joint: PhysicsImpostorJoint): void;
  19717. removeJoint(joint: PhysicsImpostorJoint): void;
  19718. isSupported(): boolean;
  19719. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19720. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19721. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19722. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19724. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19726. getBodyMass(impostor: PhysicsImpostor): number;
  19727. getBodyFriction(impostor: PhysicsImpostor): number;
  19728. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19729. getBodyRestitution(impostor: PhysicsImpostor): number;
  19730. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19731. sleepBody(impostor: PhysicsImpostor): void;
  19732. wakeUpBody(impostor: PhysicsImpostor): void;
  19733. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19734. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19735. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19736. getRadius(impostor: PhysicsImpostor): number;
  19737. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19738. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19739. dispose(): void;
  19740. }
  19741. /**
  19742. * Interface used to define a physics engine
  19743. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19744. */
  19745. export interface IPhysicsEngine {
  19746. /**
  19747. * Gets the gravity vector used by the simulation
  19748. */
  19749. gravity: Vector3;
  19750. /**
  19751. * Sets the gravity vector used by the simulation
  19752. * @param gravity defines the gravity vector to use
  19753. */
  19754. setGravity(gravity: Vector3): void;
  19755. /**
  19756. * Set the time step of the physics engine.
  19757. * Default is 1/60.
  19758. * To slow it down, enter 1/600 for example.
  19759. * To speed it up, 1/30
  19760. * @param newTimeStep the new timestep to apply to this world.
  19761. */
  19762. setTimeStep(newTimeStep: number): void;
  19763. /**
  19764. * Get the time step of the physics engine.
  19765. * @returns the current time step
  19766. */
  19767. getTimeStep(): number;
  19768. /**
  19769. * Release all resources
  19770. */
  19771. dispose(): void;
  19772. /**
  19773. * Gets the name of the current physics plugin
  19774. * @returns the name of the plugin
  19775. */
  19776. getPhysicsPluginName(): string;
  19777. /**
  19778. * Adding a new impostor for the impostor tracking.
  19779. * This will be done by the impostor itself.
  19780. * @param impostor the impostor to add
  19781. */
  19782. addImpostor(impostor: PhysicsImpostor): void;
  19783. /**
  19784. * Remove an impostor from the engine.
  19785. * This impostor and its mesh will not longer be updated by the physics engine.
  19786. * @param impostor the impostor to remove
  19787. */
  19788. removeImpostor(impostor: PhysicsImpostor): void;
  19789. /**
  19790. * Add a joint to the physics engine
  19791. * @param mainImpostor defines the main impostor to which the joint is added.
  19792. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19793. * @param joint defines the joint that will connect both impostors.
  19794. */
  19795. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19796. /**
  19797. * Removes a joint from the simulation
  19798. * @param mainImpostor defines the impostor used with the joint
  19799. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19800. * @param joint defines the joint to remove
  19801. */
  19802. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19803. /**
  19804. * Gets the current plugin used to run the simulation
  19805. * @returns current plugin
  19806. */
  19807. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19808. /**
  19809. * Gets the list of physic impostors
  19810. * @returns an array of PhysicsImpostor
  19811. */
  19812. getImpostors(): Array<PhysicsImpostor>;
  19813. /**
  19814. * Gets the impostor for a physics enabled object
  19815. * @param object defines the object impersonated by the impostor
  19816. * @returns the PhysicsImpostor or null if not found
  19817. */
  19818. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19819. /**
  19820. * Gets the impostor for a physics body object
  19821. * @param body defines physics body used by the impostor
  19822. * @returns the PhysicsImpostor or null if not found
  19823. */
  19824. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19825. /**
  19826. * Called by the scene. No need to call it.
  19827. * @param delta defines the timespam between frames
  19828. */
  19829. _step(delta: number): void;
  19830. }
  19831. }
  19832. declare module "babylonjs/Physics/physicsImpostor" {
  19833. import { Nullable, IndicesArray } from "babylonjs/types";
  19834. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19835. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19837. import { Scene } from "babylonjs/scene";
  19838. import { Bone } from "babylonjs/Bones/bone";
  19839. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19840. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19841. /**
  19842. * The interface for the physics imposter parameters
  19843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19844. */
  19845. export interface PhysicsImpostorParameters {
  19846. /**
  19847. * The mass of the physics imposter
  19848. */
  19849. mass: number;
  19850. /**
  19851. * The friction of the physics imposter
  19852. */
  19853. friction?: number;
  19854. /**
  19855. * The coefficient of restitution of the physics imposter
  19856. */
  19857. restitution?: number;
  19858. /**
  19859. * The native options of the physics imposter
  19860. */
  19861. nativeOptions?: any;
  19862. /**
  19863. * Specifies if the parent should be ignored
  19864. */
  19865. ignoreParent?: boolean;
  19866. /**
  19867. * Specifies if bi-directional transformations should be disabled
  19868. */
  19869. disableBidirectionalTransformation?: boolean;
  19870. }
  19871. /**
  19872. * Interface for a physics-enabled object
  19873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19874. */
  19875. export interface IPhysicsEnabledObject {
  19876. /**
  19877. * The position of the physics-enabled object
  19878. */
  19879. position: Vector3;
  19880. /**
  19881. * The rotation of the physics-enabled object
  19882. */
  19883. rotationQuaternion: Nullable<Quaternion>;
  19884. /**
  19885. * The scale of the physics-enabled object
  19886. */
  19887. scaling: Vector3;
  19888. /**
  19889. * The rotation of the physics-enabled object
  19890. */
  19891. rotation?: Vector3;
  19892. /**
  19893. * The parent of the physics-enabled object
  19894. */
  19895. parent?: any;
  19896. /**
  19897. * The bounding info of the physics-enabled object
  19898. * @returns The bounding info of the physics-enabled object
  19899. */
  19900. getBoundingInfo(): BoundingInfo;
  19901. /**
  19902. * Computes the world matrix
  19903. * @param force Specifies if the world matrix should be computed by force
  19904. * @returns A world matrix
  19905. */
  19906. computeWorldMatrix(force: boolean): Matrix;
  19907. /**
  19908. * Gets the world matrix
  19909. * @returns A world matrix
  19910. */
  19911. getWorldMatrix?(): Matrix;
  19912. /**
  19913. * Gets the child meshes
  19914. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19915. * @returns An array of abstract meshes
  19916. */
  19917. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19918. /**
  19919. * Gets the vertex data
  19920. * @param kind The type of vertex data
  19921. * @returns A nullable array of numbers, or a float32 array
  19922. */
  19923. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19924. /**
  19925. * Gets the indices from the mesh
  19926. * @returns A nullable array of index arrays
  19927. */
  19928. getIndices?(): Nullable<IndicesArray>;
  19929. /**
  19930. * Gets the scene from the mesh
  19931. * @returns the indices array or null
  19932. */
  19933. getScene?(): Scene;
  19934. /**
  19935. * Gets the absolute position from the mesh
  19936. * @returns the absolute position
  19937. */
  19938. getAbsolutePosition(): Vector3;
  19939. /**
  19940. * Gets the absolute pivot point from the mesh
  19941. * @returns the absolute pivot point
  19942. */
  19943. getAbsolutePivotPoint(): Vector3;
  19944. /**
  19945. * Rotates the mesh
  19946. * @param axis The axis of rotation
  19947. * @param amount The amount of rotation
  19948. * @param space The space of the rotation
  19949. * @returns The rotation transform node
  19950. */
  19951. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19952. /**
  19953. * Translates the mesh
  19954. * @param axis The axis of translation
  19955. * @param distance The distance of translation
  19956. * @param space The space of the translation
  19957. * @returns The transform node
  19958. */
  19959. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19960. /**
  19961. * Sets the absolute position of the mesh
  19962. * @param absolutePosition The absolute position of the mesh
  19963. * @returns The transform node
  19964. */
  19965. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19966. /**
  19967. * Gets the class name of the mesh
  19968. * @returns The class name
  19969. */
  19970. getClassName(): string;
  19971. }
  19972. /**
  19973. * Represents a physics imposter
  19974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19975. */
  19976. export class PhysicsImpostor {
  19977. /**
  19978. * The physics-enabled object used as the physics imposter
  19979. */
  19980. object: IPhysicsEnabledObject;
  19981. /**
  19982. * The type of the physics imposter
  19983. */
  19984. type: number;
  19985. private _options;
  19986. private _scene?;
  19987. /**
  19988. * The default object size of the imposter
  19989. */
  19990. static DEFAULT_OBJECT_SIZE: Vector3;
  19991. /**
  19992. * The identity quaternion of the imposter
  19993. */
  19994. static IDENTITY_QUATERNION: Quaternion;
  19995. /** @hidden */
  19996. _pluginData: any;
  19997. private _physicsEngine;
  19998. private _physicsBody;
  19999. private _bodyUpdateRequired;
  20000. private _onBeforePhysicsStepCallbacks;
  20001. private _onAfterPhysicsStepCallbacks;
  20002. /** @hidden */
  20003. _onPhysicsCollideCallbacks: Array<{
  20004. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20005. otherImpostors: Array<PhysicsImpostor>;
  20006. }>;
  20007. private _deltaPosition;
  20008. private _deltaRotation;
  20009. private _deltaRotationConjugated;
  20010. private _parent;
  20011. private _isDisposed;
  20012. private static _tmpVecs;
  20013. private static _tmpQuat;
  20014. /**
  20015. * Specifies if the physics imposter is disposed
  20016. */
  20017. readonly isDisposed: boolean;
  20018. /**
  20019. * Gets the mass of the physics imposter
  20020. */
  20021. mass: number;
  20022. /**
  20023. * Gets the coefficient of friction
  20024. */
  20025. /**
  20026. * Sets the coefficient of friction
  20027. */
  20028. friction: number;
  20029. /**
  20030. * Gets the coefficient of restitution
  20031. */
  20032. /**
  20033. * Sets the coefficient of restitution
  20034. */
  20035. restitution: number;
  20036. /**
  20037. * The unique id of the physics imposter
  20038. * set by the physics engine when adding this impostor to the array
  20039. */
  20040. uniqueId: number;
  20041. private _joints;
  20042. /**
  20043. * Initializes the physics imposter
  20044. * @param object The physics-enabled object used as the physics imposter
  20045. * @param type The type of the physics imposter
  20046. * @param _options The options for the physics imposter
  20047. * @param _scene The Babylon scene
  20048. */
  20049. constructor(
  20050. /**
  20051. * The physics-enabled object used as the physics imposter
  20052. */
  20053. object: IPhysicsEnabledObject,
  20054. /**
  20055. * The type of the physics imposter
  20056. */
  20057. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20058. /**
  20059. * This function will completly initialize this impostor.
  20060. * It will create a new body - but only if this mesh has no parent.
  20061. * If it has, this impostor will not be used other than to define the impostor
  20062. * of the child mesh.
  20063. * @hidden
  20064. */
  20065. _init(): void;
  20066. private _getPhysicsParent;
  20067. /**
  20068. * Should a new body be generated.
  20069. * @returns boolean specifying if body initialization is required
  20070. */
  20071. isBodyInitRequired(): boolean;
  20072. /**
  20073. * Sets the updated scaling
  20074. * @param updated Specifies if the scaling is updated
  20075. */
  20076. setScalingUpdated(): void;
  20077. /**
  20078. * Force a regeneration of this or the parent's impostor's body.
  20079. * Use under cautious - This will remove all joints already implemented.
  20080. */
  20081. forceUpdate(): void;
  20082. /**
  20083. * Gets the body that holds this impostor. Either its own, or its parent.
  20084. */
  20085. /**
  20086. * Set the physics body. Used mainly by the physics engine/plugin
  20087. */
  20088. physicsBody: any;
  20089. /**
  20090. * Get the parent of the physics imposter
  20091. * @returns Physics imposter or null
  20092. */
  20093. /**
  20094. * Sets the parent of the physics imposter
  20095. */
  20096. parent: Nullable<PhysicsImpostor>;
  20097. /**
  20098. * Resets the update flags
  20099. */
  20100. resetUpdateFlags(): void;
  20101. /**
  20102. * Gets the object extend size
  20103. * @returns the object extend size
  20104. */
  20105. getObjectExtendSize(): Vector3;
  20106. /**
  20107. * Gets the object center
  20108. * @returns The object center
  20109. */
  20110. getObjectCenter(): Vector3;
  20111. /**
  20112. * Get a specific parametes from the options parameter
  20113. * @param paramName The object parameter name
  20114. * @returns The object parameter
  20115. */
  20116. getParam(paramName: string): any;
  20117. /**
  20118. * Sets a specific parameter in the options given to the physics plugin
  20119. * @param paramName The parameter name
  20120. * @param value The value of the parameter
  20121. */
  20122. setParam(paramName: string, value: number): void;
  20123. /**
  20124. * Specifically change the body's mass option. Won't recreate the physics body object
  20125. * @param mass The mass of the physics imposter
  20126. */
  20127. setMass(mass: number): void;
  20128. /**
  20129. * Gets the linear velocity
  20130. * @returns linear velocity or null
  20131. */
  20132. getLinearVelocity(): Nullable<Vector3>;
  20133. /**
  20134. * Sets the linear velocity
  20135. * @param velocity linear velocity or null
  20136. */
  20137. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20138. /**
  20139. * Gets the angular velocity
  20140. * @returns angular velocity or null
  20141. */
  20142. getAngularVelocity(): Nullable<Vector3>;
  20143. /**
  20144. * Sets the angular velocity
  20145. * @param velocity The velocity or null
  20146. */
  20147. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20148. /**
  20149. * Execute a function with the physics plugin native code
  20150. * Provide a function the will have two variables - the world object and the physics body object
  20151. * @param func The function to execute with the physics plugin native code
  20152. */
  20153. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20154. /**
  20155. * Register a function that will be executed before the physics world is stepping forward
  20156. * @param func The function to execute before the physics world is stepped forward
  20157. */
  20158. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20159. /**
  20160. * Unregister a function that will be executed before the physics world is stepping forward
  20161. * @param func The function to execute before the physics world is stepped forward
  20162. */
  20163. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20164. /**
  20165. * Register a function that will be executed after the physics step
  20166. * @param func The function to execute after physics step
  20167. */
  20168. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20169. /**
  20170. * Unregisters a function that will be executed after the physics step
  20171. * @param func The function to execute after physics step
  20172. */
  20173. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20174. /**
  20175. * register a function that will be executed when this impostor collides against a different body
  20176. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20177. * @param func Callback that is executed on collision
  20178. */
  20179. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20180. /**
  20181. * Unregisters the physics imposter on contact
  20182. * @param collideAgainst The physics object to collide against
  20183. * @param func Callback to execute on collision
  20184. */
  20185. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20186. private _tmpQuat;
  20187. private _tmpQuat2;
  20188. /**
  20189. * Get the parent rotation
  20190. * @returns The parent rotation
  20191. */
  20192. getParentsRotation(): Quaternion;
  20193. /**
  20194. * this function is executed by the physics engine.
  20195. */
  20196. beforeStep: () => void;
  20197. /**
  20198. * this function is executed by the physics engine
  20199. */
  20200. afterStep: () => void;
  20201. /**
  20202. * Legacy collision detection event support
  20203. */
  20204. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20205. /**
  20206. * event and body object due to cannon's event-based architecture.
  20207. */
  20208. onCollide: (e: {
  20209. body: any;
  20210. }) => void;
  20211. /**
  20212. * Apply a force
  20213. * @param force The force to apply
  20214. * @param contactPoint The contact point for the force
  20215. * @returns The physics imposter
  20216. */
  20217. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20218. /**
  20219. * Apply an impulse
  20220. * @param force The impulse force
  20221. * @param contactPoint The contact point for the impulse force
  20222. * @returns The physics imposter
  20223. */
  20224. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20225. /**
  20226. * A help function to create a joint
  20227. * @param otherImpostor A physics imposter used to create a joint
  20228. * @param jointType The type of joint
  20229. * @param jointData The data for the joint
  20230. * @returns The physics imposter
  20231. */
  20232. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20233. /**
  20234. * Add a joint to this impostor with a different impostor
  20235. * @param otherImpostor A physics imposter used to add a joint
  20236. * @param joint The joint to add
  20237. * @returns The physics imposter
  20238. */
  20239. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20240. /**
  20241. * Will keep this body still, in a sleep mode.
  20242. * @returns the physics imposter
  20243. */
  20244. sleep(): PhysicsImpostor;
  20245. /**
  20246. * Wake the body up.
  20247. * @returns The physics imposter
  20248. */
  20249. wakeUp(): PhysicsImpostor;
  20250. /**
  20251. * Clones the physics imposter
  20252. * @param newObject The physics imposter clones to this physics-enabled object
  20253. * @returns A nullable physics imposter
  20254. */
  20255. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20256. /**
  20257. * Disposes the physics imposter
  20258. */
  20259. dispose(): void;
  20260. /**
  20261. * Sets the delta position
  20262. * @param position The delta position amount
  20263. */
  20264. setDeltaPosition(position: Vector3): void;
  20265. /**
  20266. * Sets the delta rotation
  20267. * @param rotation The delta rotation amount
  20268. */
  20269. setDeltaRotation(rotation: Quaternion): void;
  20270. /**
  20271. * Gets the box size of the physics imposter and stores the result in the input parameter
  20272. * @param result Stores the box size
  20273. * @returns The physics imposter
  20274. */
  20275. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20276. /**
  20277. * Gets the radius of the physics imposter
  20278. * @returns Radius of the physics imposter
  20279. */
  20280. getRadius(): number;
  20281. /**
  20282. * Sync a bone with this impostor
  20283. * @param bone The bone to sync to the impostor.
  20284. * @param boneMesh The mesh that the bone is influencing.
  20285. * @param jointPivot The pivot of the joint / bone in local space.
  20286. * @param distToJoint Optional distance from the impostor to the joint.
  20287. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20288. */
  20289. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20290. /**
  20291. * Sync impostor to a bone
  20292. * @param bone The bone that the impostor will be synced to.
  20293. * @param boneMesh The mesh that the bone is influencing.
  20294. * @param jointPivot The pivot of the joint / bone in local space.
  20295. * @param distToJoint Optional distance from the impostor to the joint.
  20296. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20297. * @param boneAxis Optional vector3 axis the bone is aligned with
  20298. */
  20299. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20300. /**
  20301. * No-Imposter type
  20302. */
  20303. static NoImpostor: number;
  20304. /**
  20305. * Sphere-Imposter type
  20306. */
  20307. static SphereImpostor: number;
  20308. /**
  20309. * Box-Imposter type
  20310. */
  20311. static BoxImpostor: number;
  20312. /**
  20313. * Plane-Imposter type
  20314. */
  20315. static PlaneImpostor: number;
  20316. /**
  20317. * Mesh-imposter type
  20318. */
  20319. static MeshImpostor: number;
  20320. /**
  20321. * Cylinder-Imposter type
  20322. */
  20323. static CylinderImpostor: number;
  20324. /**
  20325. * Particle-Imposter type
  20326. */
  20327. static ParticleImpostor: number;
  20328. /**
  20329. * Heightmap-Imposter type
  20330. */
  20331. static HeightmapImpostor: number;
  20332. }
  20333. }
  20334. declare module "babylonjs/Meshes/mesh" {
  20335. import { Observable } from "babylonjs/Misc/observable";
  20336. import { IAnimatable } from "babylonjs/Misc/tools";
  20337. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20338. import { Camera } from "babylonjs/Cameras/camera";
  20339. import { Scene } from "babylonjs/scene";
  20340. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20341. import { Engine } from "babylonjs/Engines/engine";
  20342. import { Node } from "babylonjs/node";
  20343. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20344. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20345. import { Buffer } from "babylonjs/Meshes/buffer";
  20346. import { Geometry } from "babylonjs/Meshes/geometry";
  20347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20348. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20349. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20350. import { Effect } from "babylonjs/Materials/effect";
  20351. import { Material } from "babylonjs/Materials/material";
  20352. import { Skeleton } from "babylonjs/Bones/skeleton";
  20353. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20354. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20355. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20356. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20357. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20358. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20359. /**
  20360. * Class used to represent a specific level of detail of a mesh
  20361. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20362. */
  20363. export class MeshLODLevel {
  20364. /** Defines the distance where this level should star being displayed */
  20365. distance: number;
  20366. /** Defines the mesh to use to render this level */
  20367. mesh: Nullable<Mesh>;
  20368. /**
  20369. * Creates a new LOD level
  20370. * @param distance defines the distance where this level should star being displayed
  20371. * @param mesh defines the mesh to use to render this level
  20372. */
  20373. constructor(
  20374. /** Defines the distance where this level should star being displayed */
  20375. distance: number,
  20376. /** Defines the mesh to use to render this level */
  20377. mesh: Nullable<Mesh>);
  20378. }
  20379. /**
  20380. * @hidden
  20381. **/
  20382. export class _CreationDataStorage {
  20383. closePath?: boolean;
  20384. closeArray?: boolean;
  20385. idx: number[];
  20386. dashSize: number;
  20387. gapSize: number;
  20388. path3D: Path3D;
  20389. pathArray: Vector3[][];
  20390. arc: number;
  20391. radius: number;
  20392. cap: number;
  20393. tessellation: number;
  20394. }
  20395. /**
  20396. * @hidden
  20397. **/
  20398. class _InstanceDataStorage {
  20399. visibleInstances: any;
  20400. renderIdForInstances: number[];
  20401. batchCache: _InstancesBatch;
  20402. instancesBufferSize: number;
  20403. instancesBuffer: Nullable<Buffer>;
  20404. instancesData: Float32Array;
  20405. overridenInstanceCount: number;
  20406. }
  20407. /**
  20408. * @hidden
  20409. **/
  20410. export class _InstancesBatch {
  20411. mustReturn: boolean;
  20412. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20413. renderSelf: boolean[];
  20414. }
  20415. /**
  20416. * Class used to represent renderable models
  20417. */
  20418. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20419. /**
  20420. * Mesh side orientation : usually the external or front surface
  20421. */
  20422. static readonly FRONTSIDE: number;
  20423. /**
  20424. * Mesh side orientation : usually the internal or back surface
  20425. */
  20426. static readonly BACKSIDE: number;
  20427. /**
  20428. * Mesh side orientation : both internal and external or front and back surfaces
  20429. */
  20430. static readonly DOUBLESIDE: number;
  20431. /**
  20432. * Mesh side orientation : by default, `FRONTSIDE`
  20433. */
  20434. static readonly DEFAULTSIDE: number;
  20435. /**
  20436. * Mesh cap setting : no cap
  20437. */
  20438. static readonly NO_CAP: number;
  20439. /**
  20440. * Mesh cap setting : one cap at the beginning of the mesh
  20441. */
  20442. static readonly CAP_START: number;
  20443. /**
  20444. * Mesh cap setting : one cap at the end of the mesh
  20445. */
  20446. static readonly CAP_END: number;
  20447. /**
  20448. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20449. */
  20450. static readonly CAP_ALL: number;
  20451. /**
  20452. * Gets the default side orientation.
  20453. * @param orientation the orientation to value to attempt to get
  20454. * @returns the default orientation
  20455. * @hidden
  20456. */
  20457. static _GetDefaultSideOrientation(orientation?: number): number;
  20458. private _onBeforeRenderObservable;
  20459. private _onBeforeBindObservable;
  20460. private _onAfterRenderObservable;
  20461. private _onBeforeDrawObservable;
  20462. /**
  20463. * An event triggered before rendering the mesh
  20464. */
  20465. readonly onBeforeRenderObservable: Observable<Mesh>;
  20466. /**
  20467. * An event triggered before binding the mesh
  20468. */
  20469. readonly onBeforeBindObservable: Observable<Mesh>;
  20470. /**
  20471. * An event triggered after rendering the mesh
  20472. */
  20473. readonly onAfterRenderObservable: Observable<Mesh>;
  20474. /**
  20475. * An event triggered before drawing the mesh
  20476. */
  20477. readonly onBeforeDrawObservable: Observable<Mesh>;
  20478. private _onBeforeDrawObserver;
  20479. /**
  20480. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20481. */
  20482. onBeforeDraw: () => void;
  20483. /**
  20484. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20485. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20486. */
  20487. delayLoadState: number;
  20488. /**
  20489. * Gets the list of instances created from this mesh
  20490. * it is not supposed to be modified manually.
  20491. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20492. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20493. */
  20494. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20495. /**
  20496. * Gets the file containing delay loading data for this mesh
  20497. */
  20498. delayLoadingFile: string;
  20499. /** @hidden */
  20500. _binaryInfo: any;
  20501. private _LODLevels;
  20502. /**
  20503. * User defined function used to change how LOD level selection is done
  20504. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20505. */
  20506. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20507. private _morphTargetManager;
  20508. /**
  20509. * Gets or sets the morph target manager
  20510. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20511. */
  20512. morphTargetManager: Nullable<MorphTargetManager>;
  20513. /** @hidden */
  20514. _creationDataStorage: Nullable<_CreationDataStorage>;
  20515. /** @hidden */
  20516. _geometry: Nullable<Geometry>;
  20517. /** @hidden */
  20518. _delayInfo: Array<string>;
  20519. /** @hidden */
  20520. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20521. /** @hidden */
  20522. _instanceDataStorage: _InstanceDataStorage;
  20523. private _effectiveMaterial;
  20524. /** @hidden */
  20525. _shouldGenerateFlatShading: boolean;
  20526. private _preActivateId;
  20527. /** @hidden */
  20528. _originalBuilderSideOrientation: number;
  20529. /**
  20530. * Use this property to change the original side orientation defined at construction time
  20531. */
  20532. overrideMaterialSideOrientation: Nullable<number>;
  20533. private _areNormalsFrozen;
  20534. private _sourcePositions;
  20535. private _sourceNormals;
  20536. private _source;
  20537. private meshMap;
  20538. /**
  20539. * Gets the source mesh (the one used to clone this one from)
  20540. */
  20541. readonly source: Nullable<Mesh>;
  20542. /**
  20543. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20544. */
  20545. isUnIndexed: boolean;
  20546. /**
  20547. * @constructor
  20548. * @param name The value used by scene.getMeshByName() to do a lookup.
  20549. * @param scene The scene to add this mesh to.
  20550. * @param parent The parent of this mesh, if it has one
  20551. * @param source An optional Mesh from which geometry is shared, cloned.
  20552. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20553. * When false, achieved by calling a clone(), also passing False.
  20554. * This will make creation of children, recursive.
  20555. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20556. */
  20557. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20558. /**
  20559. * Gets the class name
  20560. * @returns the string "Mesh".
  20561. */
  20562. getClassName(): string;
  20563. /** @hidden */
  20564. readonly _isMesh: boolean;
  20565. /**
  20566. * Returns a description of this mesh
  20567. * @param fullDetails define if full details about this mesh must be used
  20568. * @returns a descriptive string representing this mesh
  20569. */
  20570. toString(fullDetails?: boolean): string;
  20571. /** @hidden */
  20572. _unBindEffect(): void;
  20573. /**
  20574. * Gets a boolean indicating if this mesh has LOD
  20575. */
  20576. readonly hasLODLevels: boolean;
  20577. /**
  20578. * Gets the list of MeshLODLevel associated with the current mesh
  20579. * @returns an array of MeshLODLevel
  20580. */
  20581. getLODLevels(): MeshLODLevel[];
  20582. private _sortLODLevels;
  20583. /**
  20584. * Add a mesh as LOD level triggered at the given distance.
  20585. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20586. * @param distance The distance from the center of the object to show this level
  20587. * @param mesh The mesh to be added as LOD level (can be null)
  20588. * @return This mesh (for chaining)
  20589. */
  20590. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20591. /**
  20592. * Returns the LOD level mesh at the passed distance or null if not found.
  20593. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20594. * @param distance The distance from the center of the object to show this level
  20595. * @returns a Mesh or `null`
  20596. */
  20597. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20598. /**
  20599. * Remove a mesh from the LOD array
  20600. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20601. * @param mesh defines the mesh to be removed
  20602. * @return This mesh (for chaining)
  20603. */
  20604. removeLODLevel(mesh: Mesh): Mesh;
  20605. /**
  20606. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20607. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20608. * @param camera defines the camera to use to compute distance
  20609. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20610. * @return This mesh (for chaining)
  20611. */
  20612. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20613. /**
  20614. * Gets the mesh internal Geometry object
  20615. */
  20616. readonly geometry: Nullable<Geometry>;
  20617. /**
  20618. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20619. * @returns the total number of vertices
  20620. */
  20621. getTotalVertices(): number;
  20622. /**
  20623. * Returns the content of an associated vertex buffer
  20624. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20625. * - VertexBuffer.PositionKind
  20626. * - VertexBuffer.UVKind
  20627. * - VertexBuffer.UV2Kind
  20628. * - VertexBuffer.UV3Kind
  20629. * - VertexBuffer.UV4Kind
  20630. * - VertexBuffer.UV5Kind
  20631. * - VertexBuffer.UV6Kind
  20632. * - VertexBuffer.ColorKind
  20633. * - VertexBuffer.MatricesIndicesKind
  20634. * - VertexBuffer.MatricesIndicesExtraKind
  20635. * - VertexBuffer.MatricesWeightsKind
  20636. * - VertexBuffer.MatricesWeightsExtraKind
  20637. * @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
  20638. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20639. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20640. */
  20641. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20642. /**
  20643. * Returns the mesh VertexBuffer object from the requested `kind`
  20644. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20645. * - VertexBuffer.PositionKind
  20646. * - VertexBuffer.UVKind
  20647. * - VertexBuffer.UV2Kind
  20648. * - VertexBuffer.UV3Kind
  20649. * - VertexBuffer.UV4Kind
  20650. * - VertexBuffer.UV5Kind
  20651. * - VertexBuffer.UV6Kind
  20652. * - VertexBuffer.ColorKind
  20653. * - VertexBuffer.MatricesIndicesKind
  20654. * - VertexBuffer.MatricesIndicesExtraKind
  20655. * - VertexBuffer.MatricesWeightsKind
  20656. * - VertexBuffer.MatricesWeightsExtraKind
  20657. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20658. */
  20659. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20660. /**
  20661. * Tests if a specific vertex buffer is associated with this mesh
  20662. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20663. * - VertexBuffer.PositionKind
  20664. * - VertexBuffer.UVKind
  20665. * - VertexBuffer.UV2Kind
  20666. * - VertexBuffer.UV3Kind
  20667. * - VertexBuffer.UV4Kind
  20668. * - VertexBuffer.UV5Kind
  20669. * - VertexBuffer.UV6Kind
  20670. * - VertexBuffer.ColorKind
  20671. * - VertexBuffer.MatricesIndicesKind
  20672. * - VertexBuffer.MatricesIndicesExtraKind
  20673. * - VertexBuffer.MatricesWeightsKind
  20674. * - VertexBuffer.MatricesWeightsExtraKind
  20675. * @returns a boolean
  20676. */
  20677. isVerticesDataPresent(kind: string): boolean;
  20678. /**
  20679. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20680. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20681. * - VertexBuffer.PositionKind
  20682. * - VertexBuffer.UVKind
  20683. * - VertexBuffer.UV2Kind
  20684. * - VertexBuffer.UV3Kind
  20685. * - VertexBuffer.UV4Kind
  20686. * - VertexBuffer.UV5Kind
  20687. * - VertexBuffer.UV6Kind
  20688. * - VertexBuffer.ColorKind
  20689. * - VertexBuffer.MatricesIndicesKind
  20690. * - VertexBuffer.MatricesIndicesExtraKind
  20691. * - VertexBuffer.MatricesWeightsKind
  20692. * - VertexBuffer.MatricesWeightsExtraKind
  20693. * @returns a boolean
  20694. */
  20695. isVertexBufferUpdatable(kind: string): boolean;
  20696. /**
  20697. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20698. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20699. * - VertexBuffer.PositionKind
  20700. * - VertexBuffer.UVKind
  20701. * - VertexBuffer.UV2Kind
  20702. * - VertexBuffer.UV3Kind
  20703. * - VertexBuffer.UV4Kind
  20704. * - VertexBuffer.UV5Kind
  20705. * - VertexBuffer.UV6Kind
  20706. * - VertexBuffer.ColorKind
  20707. * - VertexBuffer.MatricesIndicesKind
  20708. * - VertexBuffer.MatricesIndicesExtraKind
  20709. * - VertexBuffer.MatricesWeightsKind
  20710. * - VertexBuffer.MatricesWeightsExtraKind
  20711. * @returns an array of strings
  20712. */
  20713. getVerticesDataKinds(): string[];
  20714. /**
  20715. * Returns a positive integer : the total number of indices in this mesh geometry.
  20716. * @returns the numner of indices or zero if the mesh has no geometry.
  20717. */
  20718. getTotalIndices(): number;
  20719. /**
  20720. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20721. * @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.
  20722. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20723. * @returns the indices array or an empty array if the mesh has no geometry
  20724. */
  20725. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20726. readonly isBlocked: boolean;
  20727. /**
  20728. * Determine if the current mesh is ready to be rendered
  20729. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20730. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20731. * @returns true if all associated assets are ready (material, textures, shaders)
  20732. */
  20733. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20734. /**
  20735. * 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.
  20736. */
  20737. readonly areNormalsFrozen: boolean;
  20738. /**
  20739. * 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.
  20740. * @returns the current mesh
  20741. */
  20742. freezeNormals(): Mesh;
  20743. /**
  20744. * 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
  20745. * @returns the current mesh
  20746. */
  20747. unfreezeNormals(): Mesh;
  20748. /**
  20749. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20750. */
  20751. overridenInstanceCount: number;
  20752. /** @hidden */
  20753. _preActivate(): Mesh;
  20754. /** @hidden */
  20755. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20756. /** @hidden */
  20757. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20758. /**
  20759. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20760. * This means the mesh underlying bounding box and sphere are recomputed.
  20761. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20762. * @returns the current mesh
  20763. */
  20764. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20765. /** @hidden */
  20766. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20767. /**
  20768. * This function will subdivide the mesh into multiple submeshes
  20769. * @param count defines the expected number of submeshes
  20770. */
  20771. subdivide(count: number): void;
  20772. /**
  20773. * Copy a FloatArray into a specific associated vertex buffer
  20774. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20775. * - VertexBuffer.PositionKind
  20776. * - VertexBuffer.UVKind
  20777. * - VertexBuffer.UV2Kind
  20778. * - VertexBuffer.UV3Kind
  20779. * - VertexBuffer.UV4Kind
  20780. * - VertexBuffer.UV5Kind
  20781. * - VertexBuffer.UV6Kind
  20782. * - VertexBuffer.ColorKind
  20783. * - VertexBuffer.MatricesIndicesKind
  20784. * - VertexBuffer.MatricesIndicesExtraKind
  20785. * - VertexBuffer.MatricesWeightsKind
  20786. * - VertexBuffer.MatricesWeightsExtraKind
  20787. * @param data defines the data source
  20788. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20789. * @param stride defines the data stride size (can be null)
  20790. * @returns the current mesh
  20791. */
  20792. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20793. /**
  20794. * Flags an associated vertex buffer as updatable
  20795. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20796. * - VertexBuffer.PositionKind
  20797. * - VertexBuffer.UVKind
  20798. * - VertexBuffer.UV2Kind
  20799. * - VertexBuffer.UV3Kind
  20800. * - VertexBuffer.UV4Kind
  20801. * - VertexBuffer.UV5Kind
  20802. * - VertexBuffer.UV6Kind
  20803. * - VertexBuffer.ColorKind
  20804. * - VertexBuffer.MatricesIndicesKind
  20805. * - VertexBuffer.MatricesIndicesExtraKind
  20806. * - VertexBuffer.MatricesWeightsKind
  20807. * - VertexBuffer.MatricesWeightsExtraKind
  20808. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20809. */
  20810. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20811. /**
  20812. * Sets the mesh global Vertex Buffer
  20813. * @param buffer defines the buffer to use
  20814. * @returns the current mesh
  20815. */
  20816. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20817. /**
  20818. * Update a specific associated vertex buffer
  20819. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20820. * - VertexBuffer.PositionKind
  20821. * - VertexBuffer.UVKind
  20822. * - VertexBuffer.UV2Kind
  20823. * - VertexBuffer.UV3Kind
  20824. * - VertexBuffer.UV4Kind
  20825. * - VertexBuffer.UV5Kind
  20826. * - VertexBuffer.UV6Kind
  20827. * - VertexBuffer.ColorKind
  20828. * - VertexBuffer.MatricesIndicesKind
  20829. * - VertexBuffer.MatricesIndicesExtraKind
  20830. * - VertexBuffer.MatricesWeightsKind
  20831. * - VertexBuffer.MatricesWeightsExtraKind
  20832. * @param data defines the data source
  20833. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20834. * @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)
  20835. * @returns the current mesh
  20836. */
  20837. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20838. /**
  20839. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20840. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20841. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20842. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20843. * @returns the current mesh
  20844. */
  20845. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20846. /**
  20847. * Creates a un-shared specific occurence of the geometry for the mesh.
  20848. * @returns the current mesh
  20849. */
  20850. makeGeometryUnique(): Mesh;
  20851. /**
  20852. * Set the index buffer of this mesh
  20853. * @param indices defines the source data
  20854. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20855. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20856. * @returns the current mesh
  20857. */
  20858. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20859. /**
  20860. * Update the current index buffer
  20861. * @param indices defines the source data
  20862. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20863. * @returns the current mesh
  20864. */
  20865. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20866. /**
  20867. * Invert the geometry to move from a right handed system to a left handed one.
  20868. * @returns the current mesh
  20869. */
  20870. toLeftHanded(): Mesh;
  20871. /** @hidden */
  20872. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20873. /** @hidden */
  20874. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20875. /**
  20876. * Registers for this mesh a javascript function called just before the rendering process
  20877. * @param func defines the function to call before rendering this mesh
  20878. * @returns the current mesh
  20879. */
  20880. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20881. /**
  20882. * Disposes a previously registered javascript function called before the rendering
  20883. * @param func defines the function to remove
  20884. * @returns the current mesh
  20885. */
  20886. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20887. /**
  20888. * Registers for this mesh a javascript function called just after the rendering is complete
  20889. * @param func defines the function to call after rendering this mesh
  20890. * @returns the current mesh
  20891. */
  20892. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20893. /**
  20894. * Disposes a previously registered javascript function called after the rendering.
  20895. * @param func defines the function to remove
  20896. * @returns the current mesh
  20897. */
  20898. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20899. /** @hidden */
  20900. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20901. /** @hidden */
  20902. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20903. /** @hidden */
  20904. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20905. /**
  20906. * 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
  20907. * @param subMesh defines the subMesh to render
  20908. * @param enableAlphaMode defines if alpha mode can be changed
  20909. * @returns the current mesh
  20910. */
  20911. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20912. private _onBeforeDraw;
  20913. /**
  20914. * Renormalize the mesh and patch it up if there are no weights
  20915. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20916. * However in the case of zero weights then we set just a single influence to 1.
  20917. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20918. */
  20919. cleanMatrixWeights(): void;
  20920. private normalizeSkinFourWeights;
  20921. private normalizeSkinWeightsAndExtra;
  20922. /**
  20923. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20924. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20925. * the user know there was an issue with importing the mesh
  20926. * @returns a validation object with skinned, valid and report string
  20927. */
  20928. validateSkinning(): {
  20929. skinned: boolean;
  20930. valid: boolean;
  20931. report: string;
  20932. };
  20933. /** @hidden */
  20934. _checkDelayState(): Mesh;
  20935. private _queueLoad;
  20936. /**
  20937. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20938. * A mesh is in the frustum if its bounding box intersects the frustum
  20939. * @param frustumPlanes defines the frustum to test
  20940. * @returns true if the mesh is in the frustum planes
  20941. */
  20942. isInFrustum(frustumPlanes: Plane[]): boolean;
  20943. /**
  20944. * Sets the mesh material by the material or multiMaterial `id` property
  20945. * @param id is a string identifying the material or the multiMaterial
  20946. * @returns the current mesh
  20947. */
  20948. setMaterialByID(id: string): Mesh;
  20949. /**
  20950. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20951. * @returns an array of IAnimatable
  20952. */
  20953. getAnimatables(): IAnimatable[];
  20954. /**
  20955. * Modifies the mesh geometry according to the passed transformation matrix.
  20956. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20957. * The mesh normals are modified using the same transformation.
  20958. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20959. * @param transform defines the transform matrix to use
  20960. * @see http://doc.babylonjs.com/resources/baking_transformations
  20961. * @returns the current mesh
  20962. */
  20963. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20964. /**
  20965. * Modifies the mesh geometry according to its own current World Matrix.
  20966. * The mesh World Matrix is then reset.
  20967. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20968. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20969. * @see http://doc.babylonjs.com/resources/baking_transformations
  20970. * @returns the current mesh
  20971. */
  20972. bakeCurrentTransformIntoVertices(): Mesh;
  20973. /** @hidden */
  20974. readonly _positions: Nullable<Vector3[]>;
  20975. /** @hidden */
  20976. _resetPointsArrayCache(): Mesh;
  20977. /** @hidden */
  20978. _generatePointsArray(): boolean;
  20979. /**
  20980. * Returns a new Mesh object generated from the current mesh properties.
  20981. * This method must not get confused with createInstance()
  20982. * @param name is a string, the name given to the new mesh
  20983. * @param newParent can be any Node object (default `null`)
  20984. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20985. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20986. * @returns a new mesh
  20987. */
  20988. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20989. /**
  20990. * Releases resources associated with this mesh.
  20991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20993. */
  20994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20995. /**
  20996. * Modifies the mesh geometry according to a displacement map.
  20997. * 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.
  20998. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20999. * @param url is a string, the URL from the image file is to be downloaded.
  21000. * @param minHeight is the lower limit of the displacement.
  21001. * @param maxHeight is the upper limit of the displacement.
  21002. * @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.
  21003. * @param uvOffset is an optional vector2 used to offset UV.
  21004. * @param uvScale is an optional vector2 used to scale UV.
  21005. * @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.
  21006. * @returns the Mesh.
  21007. */
  21008. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21009. /**
  21010. * Modifies the mesh geometry according to a displacementMap buffer.
  21011. * 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.
  21012. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21013. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21014. * @param heightMapWidth is the width of the buffer image.
  21015. * @param heightMapHeight is the height of the buffer image.
  21016. * @param minHeight is the lower limit of the displacement.
  21017. * @param maxHeight is the upper limit of the displacement.
  21018. * @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.
  21019. * @param uvOffset is an optional vector2 used to offset UV.
  21020. * @param uvScale is an optional vector2 used to scale UV.
  21021. * @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.
  21022. * @returns the Mesh.
  21023. */
  21024. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21025. /**
  21026. * Modify the mesh to get a flat shading rendering.
  21027. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21028. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21029. * @returns current mesh
  21030. */
  21031. convertToFlatShadedMesh(): Mesh;
  21032. /**
  21033. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21034. * In other words, more vertices, no more indices and a single bigger VBO.
  21035. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21036. * @returns current mesh
  21037. */
  21038. convertToUnIndexedMesh(): Mesh;
  21039. /**
  21040. * Inverses facet orientations.
  21041. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21042. * @param flipNormals will also inverts the normals
  21043. * @returns current mesh
  21044. */
  21045. flipFaces(flipNormals?: boolean): Mesh;
  21046. /** @hidden */
  21047. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21048. /** @hidden */
  21049. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21050. /**
  21051. * Creates a new InstancedMesh object from the mesh model.
  21052. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21053. * @param name defines the name of the new instance
  21054. * @returns a new InstancedMesh
  21055. */
  21056. createInstance(name: string): InstancedMesh;
  21057. /**
  21058. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21059. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21060. * @returns the current mesh
  21061. */
  21062. synchronizeInstances(): Mesh;
  21063. /**
  21064. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21065. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21066. * This should be used together with the simplification to avoid disappearing triangles.
  21067. * @param successCallback an optional success callback to be called after the optimization finished.
  21068. * @returns the current mesh
  21069. */
  21070. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21071. /**
  21072. * Serialize current mesh
  21073. * @param serializationObject defines the object which will receive the serialization data
  21074. */
  21075. serialize(serializationObject: any): void;
  21076. /** @hidden */
  21077. _syncGeometryWithMorphTargetManager(): void;
  21078. /** @hidden */
  21079. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21080. /**
  21081. * Returns a new Mesh object parsed from the source provided.
  21082. * @param parsedMesh is the source
  21083. * @param scene defines the hosting scene
  21084. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21085. * @returns a new Mesh
  21086. */
  21087. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21088. /**
  21089. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21090. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21091. * @param name defines the name of the mesh to create
  21092. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21093. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21094. * @param closePath creates a seam between the first and the last points of each path of the path array
  21095. * @param offset is taken in account only if the `pathArray` is containing a single path
  21096. * @param scene defines the hosting scene
  21097. * @param updatable defines if the mesh must be flagged as updatable
  21098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21099. * @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)
  21100. * @returns a new Mesh
  21101. */
  21102. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21103. /**
  21104. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21105. * @param name defines the name of the mesh to create
  21106. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21107. * @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
  21108. * @param scene defines the hosting scene
  21109. * @param updatable defines if the mesh must be flagged as updatable
  21110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21111. * @returns a new Mesh
  21112. */
  21113. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21114. /**
  21115. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21116. * @param name defines the name of the mesh to create
  21117. * @param size sets the size (float) of each box side (default 1)
  21118. * @param scene defines the hosting scene
  21119. * @param updatable defines if the mesh must be flagged as updatable
  21120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21121. * @returns a new Mesh
  21122. */
  21123. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21124. /**
  21125. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21126. * @param name defines the name of the mesh to create
  21127. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21128. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21129. * @param scene defines the hosting scene
  21130. * @param updatable defines if the mesh must be flagged as updatable
  21131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21132. * @returns a new Mesh
  21133. */
  21134. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21135. /**
  21136. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21137. * @param name defines the name of the mesh to create
  21138. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21139. * @param diameterTop set the top cap diameter (floats, default 1)
  21140. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21141. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21142. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21143. * @param scene defines the hosting scene
  21144. * @param updatable defines if the mesh must be flagged as updatable
  21145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21146. * @returns a new Mesh
  21147. */
  21148. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21149. /**
  21150. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21151. * @param name defines the name of the mesh to create
  21152. * @param diameter sets the diameter size (float) of the torus (default 1)
  21153. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21154. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21155. * @param scene defines the hosting scene
  21156. * @param updatable defines if the mesh must be flagged as updatable
  21157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21158. * @returns a new Mesh
  21159. */
  21160. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21161. /**
  21162. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21163. * @param name defines the name of the mesh to create
  21164. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21165. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21166. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21167. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21168. * @param p the number of windings on X axis (positive integers, default 2)
  21169. * @param q the number of windings on Y axis (positive integers, default 3)
  21170. * @param scene defines the hosting scene
  21171. * @param updatable defines if the mesh must be flagged as updatable
  21172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21173. * @returns a new Mesh
  21174. */
  21175. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21176. /**
  21177. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21178. * @param name defines the name of the mesh to create
  21179. * @param points is an array successive Vector3
  21180. * @param scene defines the hosting scene
  21181. * @param updatable defines if the mesh must be flagged as updatable
  21182. * @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).
  21183. * @returns a new Mesh
  21184. */
  21185. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21186. /**
  21187. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21188. * @param name defines the name of the mesh to create
  21189. * @param points is an array successive Vector3
  21190. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21191. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21192. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21193. * @param scene defines the hosting scene
  21194. * @param updatable defines if the mesh must be flagged as updatable
  21195. * @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)
  21196. * @returns a new Mesh
  21197. */
  21198. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21199. /**
  21200. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21201. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21202. * 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.
  21203. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21204. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21205. * Remember you can only change the shape positions, not their number when updating a polygon.
  21206. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21207. * @param name defines the name of the mesh to create
  21208. * @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
  21209. * @param scene defines the hosting scene
  21210. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21211. * @param updatable defines if the mesh must be flagged as updatable
  21212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21213. * @param earcutInjection can be used to inject your own earcut reference
  21214. * @returns a new Mesh
  21215. */
  21216. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21217. /**
  21218. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21219. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21220. * @param name defines the name of the mesh to create
  21221. * @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
  21222. * @param depth defines the height of extrusion
  21223. * @param scene defines the hosting scene
  21224. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21225. * @param updatable defines if the mesh must be flagged as updatable
  21226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21227. * @param earcutInjection can be used to inject your own earcut reference
  21228. * @returns a new Mesh
  21229. */
  21230. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21231. /**
  21232. * Creates an extruded shape mesh.
  21233. * 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
  21234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21235. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21236. * @param name defines the name of the mesh to create
  21237. * @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
  21238. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21239. * @param scale is the value to scale the shape
  21240. * @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
  21241. * @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
  21242. * @param scene defines the hosting scene
  21243. * @param updatable defines if the mesh must be flagged as updatable
  21244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21245. * @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)
  21246. * @returns a new Mesh
  21247. */
  21248. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21249. /**
  21250. * Creates an custom extruded shape mesh.
  21251. * The custom extrusion is a parametric shape.
  21252. * It has no predefined shape. Its final shape will depend on the input parameters.
  21253. * Please consider using the same method from the MeshBuilder class instead
  21254. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21255. * @param name defines the name of the mesh to create
  21256. * @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
  21257. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21258. * @param scaleFunction is a custom Javascript function called on each path point
  21259. * @param rotationFunction is a custom Javascript function called on each path point
  21260. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21261. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21262. * @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
  21263. * @param scene defines the hosting scene
  21264. * @param updatable defines if the mesh must be flagged as updatable
  21265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21266. * @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)
  21267. * @returns a new Mesh
  21268. */
  21269. 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;
  21270. /**
  21271. * Creates lathe mesh.
  21272. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21273. * Please consider using the same method from the MeshBuilder class instead
  21274. * @param name defines the name of the mesh to create
  21275. * @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
  21276. * @param radius is the radius value of the lathe
  21277. * @param tessellation is the side number of the lathe.
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21281. * @returns a new Mesh
  21282. */
  21283. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21284. /**
  21285. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21288. * @param scene defines the hosting scene
  21289. * @param updatable defines if the mesh must be flagged as updatable
  21290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21291. * @returns a new Mesh
  21292. */
  21293. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21294. /**
  21295. * Creates a ground mesh.
  21296. * Please consider using the same method from the MeshBuilder class instead
  21297. * @param name defines the name of the mesh to create
  21298. * @param width set the width of the ground
  21299. * @param height set the height of the ground
  21300. * @param subdivisions sets the number of subdivisions per side
  21301. * @param scene defines the hosting scene
  21302. * @param updatable defines if the mesh must be flagged as updatable
  21303. * @returns a new Mesh
  21304. */
  21305. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21306. /**
  21307. * Creates a tiled ground mesh.
  21308. * Please consider using the same method from the MeshBuilder class instead
  21309. * @param name defines the name of the mesh to create
  21310. * @param xmin set the ground minimum X coordinate
  21311. * @param zmin set the ground minimum Y coordinate
  21312. * @param xmax set the ground maximum X coordinate
  21313. * @param zmax set the ground maximum Z coordinate
  21314. * @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
  21315. * @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
  21316. * @param scene defines the hosting scene
  21317. * @param updatable defines if the mesh must be flagged as updatable
  21318. * @returns a new Mesh
  21319. */
  21320. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21321. w: number;
  21322. h: number;
  21323. }, precision: {
  21324. w: number;
  21325. h: number;
  21326. }, scene: Scene, updatable?: boolean): Mesh;
  21327. /**
  21328. * Creates a ground mesh from a height map.
  21329. * Please consider using the same method from the MeshBuilder class instead
  21330. * @see http://doc.babylonjs.com/babylon101/height_map
  21331. * @param name defines the name of the mesh to create
  21332. * @param url sets the URL of the height map image resource
  21333. * @param width set the ground width size
  21334. * @param height set the ground height size
  21335. * @param subdivisions sets the number of subdivision per side
  21336. * @param minHeight is the minimum altitude on the ground
  21337. * @param maxHeight is the maximum altitude on the ground
  21338. * @param scene defines the hosting scene
  21339. * @param updatable defines if the mesh must be flagged as updatable
  21340. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21341. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21342. * @returns a new Mesh
  21343. */
  21344. 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;
  21345. /**
  21346. * Creates a tube mesh.
  21347. * The tube is a parametric shape.
  21348. * It has no predefined shape. Its final shape will depend on the input parameters.
  21349. * Please consider using the same method from the MeshBuilder class instead
  21350. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21351. * @param name defines the name of the mesh to create
  21352. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21353. * @param radius sets the tube radius size
  21354. * @param tessellation is the number of sides on the tubular surface
  21355. * @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
  21356. * @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
  21357. * @param scene defines the hosting scene
  21358. * @param updatable defines if the mesh must be flagged as updatable
  21359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21360. * @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)
  21361. * @returns a new Mesh
  21362. */
  21363. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21364. (i: number, distance: number): number;
  21365. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21366. /**
  21367. * Creates a polyhedron mesh.
  21368. * Please consider using the same method from the MeshBuilder class instead.
  21369. * * 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
  21370. * * The parameter `size` (positive float, default 1) sets the polygon size
  21371. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21372. * * 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`
  21373. * * 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
  21374. * * 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)`)
  21375. * * 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
  21376. * * 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
  21377. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21378. * * If you create a double-sided mesh, you can choose what parts of 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
  21379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21380. * @param name defines the name of the mesh to create
  21381. * @param options defines the options used to create the mesh
  21382. * @param scene defines the hosting scene
  21383. * @returns a new Mesh
  21384. */
  21385. static CreatePolyhedron(name: string, options: {
  21386. type?: number;
  21387. size?: number;
  21388. sizeX?: number;
  21389. sizeY?: number;
  21390. sizeZ?: number;
  21391. custom?: any;
  21392. faceUV?: Vector4[];
  21393. faceColors?: Color4[];
  21394. updatable?: boolean;
  21395. sideOrientation?: number;
  21396. }, scene: Scene): Mesh;
  21397. /**
  21398. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21399. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21400. * * 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`)
  21401. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21402. * * 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
  21403. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21404. * * If you create a double-sided mesh, you can choose what parts of 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
  21405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21406. * @param name defines the name of the mesh
  21407. * @param options defines the options used to create the mesh
  21408. * @param scene defines the hosting scene
  21409. * @returns a new Mesh
  21410. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21411. */
  21412. static CreateIcoSphere(name: string, options: {
  21413. radius?: number;
  21414. flat?: boolean;
  21415. subdivisions?: number;
  21416. sideOrientation?: number;
  21417. updatable?: boolean;
  21418. }, scene: Scene): Mesh;
  21419. /**
  21420. * Creates a decal mesh.
  21421. * Please consider using the same method from the MeshBuilder class instead.
  21422. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21423. * @param name defines the name of the mesh
  21424. * @param sourceMesh defines the mesh receiving the decal
  21425. * @param position sets the position of the decal in world coordinates
  21426. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21427. * @param size sets the decal scaling
  21428. * @param angle sets the angle to rotate the decal
  21429. * @returns a new Mesh
  21430. */
  21431. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21432. /**
  21433. * Prepare internal position array for software CPU skinning
  21434. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21435. */
  21436. setPositionsForCPUSkinning(): Float32Array;
  21437. /**
  21438. * Prepare internal normal array for software CPU skinning
  21439. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21440. */
  21441. setNormalsForCPUSkinning(): Float32Array;
  21442. /**
  21443. * Updates the vertex buffer by applying transformation from the bones
  21444. * @param skeleton defines the skeleton to apply to current mesh
  21445. * @returns the current mesh
  21446. */
  21447. applySkeleton(skeleton: Skeleton): Mesh;
  21448. /**
  21449. * 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
  21450. * @param meshes defines the list of meshes to scan
  21451. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21452. */
  21453. static MinMax(meshes: AbstractMesh[]): {
  21454. min: Vector3;
  21455. max: Vector3;
  21456. };
  21457. /**
  21458. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21459. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21460. * @returns a vector3
  21461. */
  21462. static Center(meshesOrMinMaxVector: {
  21463. min: Vector3;
  21464. max: Vector3;
  21465. } | AbstractMesh[]): Vector3;
  21466. /**
  21467. * Merge the array of meshes into a single mesh for performance reasons.
  21468. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21469. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21470. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21471. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21472. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21473. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21474. * @returns a new mesh
  21475. */
  21476. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21477. /** @hidden */
  21478. addInstance(instance: InstancedMesh): void;
  21479. /** @hidden */
  21480. removeInstance(instance: InstancedMesh): void;
  21481. }
  21482. }
  21483. declare module "babylonjs/Materials/material" {
  21484. import { IAnimatable } from "babylonjs/Misc/tools";
  21485. import { SmartArray } from "babylonjs/Misc/smartArray";
  21486. import { Observable } from "babylonjs/Misc/observable";
  21487. import { Nullable } from "babylonjs/types";
  21488. import { Scene } from "babylonjs/scene";
  21489. import { Matrix } from "babylonjs/Maths/math";
  21490. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21492. import { Mesh } from "babylonjs/Meshes/mesh";
  21493. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21494. import { Effect } from "babylonjs/Materials/effect";
  21495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21496. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21497. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21498. import { Animation } from "babylonjs/Animations/animation";
  21499. /**
  21500. * Base class for the main features of a material in Babylon.js
  21501. */
  21502. export class Material implements IAnimatable {
  21503. /**
  21504. * Returns the triangle fill mode
  21505. */
  21506. static readonly TriangleFillMode: number;
  21507. /**
  21508. * Returns the wireframe mode
  21509. */
  21510. static readonly WireFrameFillMode: number;
  21511. /**
  21512. * Returns the point fill mode
  21513. */
  21514. static readonly PointFillMode: number;
  21515. /**
  21516. * Returns the point list draw mode
  21517. */
  21518. static readonly PointListDrawMode: number;
  21519. /**
  21520. * Returns the line list draw mode
  21521. */
  21522. static readonly LineListDrawMode: number;
  21523. /**
  21524. * Returns the line loop draw mode
  21525. */
  21526. static readonly LineLoopDrawMode: number;
  21527. /**
  21528. * Returns the line strip draw mode
  21529. */
  21530. static readonly LineStripDrawMode: number;
  21531. /**
  21532. * Returns the triangle strip draw mode
  21533. */
  21534. static readonly TriangleStripDrawMode: number;
  21535. /**
  21536. * Returns the triangle fan draw mode
  21537. */
  21538. static readonly TriangleFanDrawMode: number;
  21539. /**
  21540. * Stores the clock-wise side orientation
  21541. */
  21542. static readonly ClockWiseSideOrientation: number;
  21543. /**
  21544. * Stores the counter clock-wise side orientation
  21545. */
  21546. static readonly CounterClockWiseSideOrientation: number;
  21547. /**
  21548. * The dirty texture flag value
  21549. */
  21550. static readonly TextureDirtyFlag: number;
  21551. /**
  21552. * The dirty light flag value
  21553. */
  21554. static readonly LightDirtyFlag: number;
  21555. /**
  21556. * The dirty fresnel flag value
  21557. */
  21558. static readonly FresnelDirtyFlag: number;
  21559. /**
  21560. * The dirty attribute flag value
  21561. */
  21562. static readonly AttributesDirtyFlag: number;
  21563. /**
  21564. * The dirty misc flag value
  21565. */
  21566. static readonly MiscDirtyFlag: number;
  21567. /**
  21568. * The all dirty flag value
  21569. */
  21570. static readonly AllDirtyFlag: number;
  21571. /**
  21572. * The ID of the material
  21573. */
  21574. id: string;
  21575. /**
  21576. * Gets or sets the unique id of the material
  21577. */
  21578. uniqueId: number;
  21579. /**
  21580. * The name of the material
  21581. */
  21582. name: string;
  21583. /**
  21584. * Gets or sets user defined metadata
  21585. */
  21586. metadata: any;
  21587. /**
  21588. * For internal use only. Please do not use.
  21589. */
  21590. reservedDataStore: any;
  21591. /**
  21592. * Specifies if the ready state should be checked on each call
  21593. */
  21594. checkReadyOnEveryCall: boolean;
  21595. /**
  21596. * Specifies if the ready state should be checked once
  21597. */
  21598. checkReadyOnlyOnce: boolean;
  21599. /**
  21600. * The state of the material
  21601. */
  21602. state: string;
  21603. /**
  21604. * The alpha value of the material
  21605. */
  21606. protected _alpha: number;
  21607. /**
  21608. * Sets the alpha value of the material
  21609. */
  21610. /**
  21611. * Gets the alpha value of the material
  21612. */
  21613. alpha: number;
  21614. /**
  21615. * Specifies if back face culling is enabled
  21616. */
  21617. protected _backFaceCulling: boolean;
  21618. /**
  21619. * Sets the back-face culling state
  21620. */
  21621. /**
  21622. * Gets the back-face culling state
  21623. */
  21624. backFaceCulling: boolean;
  21625. /**
  21626. * Stores the value for side orientation
  21627. */
  21628. sideOrientation: number;
  21629. /**
  21630. * Callback triggered when the material is compiled
  21631. */
  21632. onCompiled: (effect: Effect) => void;
  21633. /**
  21634. * Callback triggered when an error occurs
  21635. */
  21636. onError: (effect: Effect, errors: string) => void;
  21637. /**
  21638. * Callback triggered to get the render target textures
  21639. */
  21640. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21641. /**
  21642. * Gets a boolean indicating that current material needs to register RTT
  21643. */
  21644. readonly hasRenderTargetTextures: boolean;
  21645. /**
  21646. * Specifies if the material should be serialized
  21647. */
  21648. doNotSerialize: boolean;
  21649. /**
  21650. * @hidden
  21651. */
  21652. _storeEffectOnSubMeshes: boolean;
  21653. /**
  21654. * Stores the animations for the material
  21655. */
  21656. animations: Array<Animation>;
  21657. /**
  21658. * An event triggered when the material is disposed
  21659. */
  21660. onDisposeObservable: Observable<Material>;
  21661. /**
  21662. * An observer which watches for dispose events
  21663. */
  21664. private _onDisposeObserver;
  21665. private _onUnBindObservable;
  21666. /**
  21667. * Called during a dispose event
  21668. */
  21669. onDispose: () => void;
  21670. private _onBindObservable;
  21671. /**
  21672. * An event triggered when the material is bound
  21673. */
  21674. readonly onBindObservable: Observable<AbstractMesh>;
  21675. /**
  21676. * An observer which watches for bind events
  21677. */
  21678. private _onBindObserver;
  21679. /**
  21680. * Called during a bind event
  21681. */
  21682. onBind: (Mesh: AbstractMesh) => void;
  21683. /**
  21684. * An event triggered when the material is unbound
  21685. */
  21686. readonly onUnBindObservable: Observable<Material>;
  21687. /**
  21688. * Stores the value of the alpha mode
  21689. */
  21690. private _alphaMode;
  21691. /**
  21692. * Sets the value of the alpha mode.
  21693. *
  21694. * | Value | Type | Description |
  21695. * | --- | --- | --- |
  21696. * | 0 | ALPHA_DISABLE | |
  21697. * | 1 | ALPHA_ADD | |
  21698. * | 2 | ALPHA_COMBINE | |
  21699. * | 3 | ALPHA_SUBTRACT | |
  21700. * | 4 | ALPHA_MULTIPLY | |
  21701. * | 5 | ALPHA_MAXIMIZED | |
  21702. * | 6 | ALPHA_ONEONE | |
  21703. * | 7 | ALPHA_PREMULTIPLIED | |
  21704. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21705. * | 9 | ALPHA_INTERPOLATE | |
  21706. * | 10 | ALPHA_SCREENMODE | |
  21707. *
  21708. */
  21709. /**
  21710. * Gets the value of the alpha mode
  21711. */
  21712. alphaMode: number;
  21713. /**
  21714. * Stores the state of the need depth pre-pass value
  21715. */
  21716. private _needDepthPrePass;
  21717. /**
  21718. * Sets the need depth pre-pass value
  21719. */
  21720. /**
  21721. * Gets the depth pre-pass value
  21722. */
  21723. needDepthPrePass: boolean;
  21724. /**
  21725. * Specifies if depth writing should be disabled
  21726. */
  21727. disableDepthWrite: boolean;
  21728. /**
  21729. * Specifies if depth writing should be forced
  21730. */
  21731. forceDepthWrite: boolean;
  21732. /**
  21733. * Specifies if there should be a separate pass for culling
  21734. */
  21735. separateCullingPass: boolean;
  21736. /**
  21737. * Stores the state specifing if fog should be enabled
  21738. */
  21739. private _fogEnabled;
  21740. /**
  21741. * Sets the state for enabling fog
  21742. */
  21743. /**
  21744. * Gets the value of the fog enabled state
  21745. */
  21746. fogEnabled: boolean;
  21747. /**
  21748. * Stores the size of points
  21749. */
  21750. pointSize: number;
  21751. /**
  21752. * Stores the z offset value
  21753. */
  21754. zOffset: number;
  21755. /**
  21756. * Gets a value specifying if wireframe mode is enabled
  21757. */
  21758. /**
  21759. * Sets the state of wireframe mode
  21760. */
  21761. wireframe: boolean;
  21762. /**
  21763. * Gets the value specifying if point clouds are enabled
  21764. */
  21765. /**
  21766. * Sets the state of point cloud mode
  21767. */
  21768. pointsCloud: boolean;
  21769. /**
  21770. * Gets the material fill mode
  21771. */
  21772. /**
  21773. * Sets the material fill mode
  21774. */
  21775. fillMode: number;
  21776. /**
  21777. * @hidden
  21778. * Stores the effects for the material
  21779. */
  21780. _effect: Nullable<Effect>;
  21781. /**
  21782. * @hidden
  21783. * Specifies if the material was previously ready
  21784. */
  21785. _wasPreviouslyReady: boolean;
  21786. /**
  21787. * Specifies if uniform buffers should be used
  21788. */
  21789. private _useUBO;
  21790. /**
  21791. * Stores a reference to the scene
  21792. */
  21793. private _scene;
  21794. /**
  21795. * Stores the fill mode state
  21796. */
  21797. private _fillMode;
  21798. /**
  21799. * Specifies if the depth write state should be cached
  21800. */
  21801. private _cachedDepthWriteState;
  21802. /**
  21803. * Stores the uniform buffer
  21804. */
  21805. protected _uniformBuffer: UniformBuffer;
  21806. /** @hidden */
  21807. _indexInSceneMaterialArray: number;
  21808. /** @hidden */
  21809. meshMap: Nullable<{
  21810. [id: string]: AbstractMesh | undefined;
  21811. }>;
  21812. /**
  21813. * Creates a material instance
  21814. * @param name defines the name of the material
  21815. * @param scene defines the scene to reference
  21816. * @param doNotAdd specifies if the material should be added to the scene
  21817. */
  21818. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21819. /**
  21820. * Returns a string representation of the current material
  21821. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21822. * @returns a string with material information
  21823. */
  21824. toString(fullDetails?: boolean): string;
  21825. /**
  21826. * Gets the class name of the material
  21827. * @returns a string with the class name of the material
  21828. */
  21829. getClassName(): string;
  21830. /**
  21831. * Specifies if updates for the material been locked
  21832. */
  21833. readonly isFrozen: boolean;
  21834. /**
  21835. * Locks updates for the material
  21836. */
  21837. freeze(): void;
  21838. /**
  21839. * Unlocks updates for the material
  21840. */
  21841. unfreeze(): void;
  21842. /**
  21843. * Specifies if the material is ready to be used
  21844. * @param mesh defines the mesh to check
  21845. * @param useInstances specifies if instances should be used
  21846. * @returns a boolean indicating if the material is ready to be used
  21847. */
  21848. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21849. /**
  21850. * Specifies that the submesh is ready to be used
  21851. * @param mesh defines the mesh to check
  21852. * @param subMesh defines which submesh to check
  21853. * @param useInstances specifies that instances should be used
  21854. * @returns a boolean indicating that the submesh is ready or not
  21855. */
  21856. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21857. /**
  21858. * Returns the material effect
  21859. * @returns the effect associated with the material
  21860. */
  21861. getEffect(): Nullable<Effect>;
  21862. /**
  21863. * Returns the current scene
  21864. * @returns a Scene
  21865. */
  21866. getScene(): Scene;
  21867. /**
  21868. * Specifies if the material will require alpha blending
  21869. * @returns a boolean specifying if alpha blending is needed
  21870. */
  21871. needAlphaBlending(): boolean;
  21872. /**
  21873. * Specifies if the mesh will require alpha blending
  21874. * @param mesh defines the mesh to check
  21875. * @returns a boolean specifying if alpha blending is needed for the mesh
  21876. */
  21877. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21878. /**
  21879. * Specifies if this material should be rendered in alpha test mode
  21880. * @returns a boolean specifying if an alpha test is needed.
  21881. */
  21882. needAlphaTesting(): boolean;
  21883. /**
  21884. * Gets the texture used for the alpha test
  21885. * @returns the texture to use for alpha testing
  21886. */
  21887. getAlphaTestTexture(): Nullable<BaseTexture>;
  21888. /**
  21889. * Marks the material to indicate that it needs to be re-calculated
  21890. */
  21891. markDirty(): void;
  21892. /** @hidden */
  21893. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21894. /**
  21895. * Binds the material to the mesh
  21896. * @param world defines the world transformation matrix
  21897. * @param mesh defines the mesh to bind the material to
  21898. */
  21899. bind(world: Matrix, mesh?: Mesh): void;
  21900. /**
  21901. * Binds the submesh to the material
  21902. * @param world defines the world transformation matrix
  21903. * @param mesh defines the mesh containing the submesh
  21904. * @param subMesh defines the submesh to bind the material to
  21905. */
  21906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21907. /**
  21908. * Binds the world matrix to the material
  21909. * @param world defines the world transformation matrix
  21910. */
  21911. bindOnlyWorldMatrix(world: Matrix): void;
  21912. /**
  21913. * Binds the scene's uniform buffer to the effect.
  21914. * @param effect defines the effect to bind to the scene uniform buffer
  21915. * @param sceneUbo defines the uniform buffer storing scene data
  21916. */
  21917. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21918. /**
  21919. * Binds the view matrix to the effect
  21920. * @param effect defines the effect to bind the view matrix to
  21921. */
  21922. bindView(effect: Effect): void;
  21923. /**
  21924. * Binds the view projection matrix to the effect
  21925. * @param effect defines the effect to bind the view projection matrix to
  21926. */
  21927. bindViewProjection(effect: Effect): void;
  21928. /**
  21929. * Specifies if material alpha testing should be turned on for the mesh
  21930. * @param mesh defines the mesh to check
  21931. */
  21932. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21933. /**
  21934. * Processes to execute after binding the material to a mesh
  21935. * @param mesh defines the rendered mesh
  21936. */
  21937. protected _afterBind(mesh?: Mesh): void;
  21938. /**
  21939. * Unbinds the material from the mesh
  21940. */
  21941. unbind(): void;
  21942. /**
  21943. * Gets the active textures from the material
  21944. * @returns an array of textures
  21945. */
  21946. getActiveTextures(): BaseTexture[];
  21947. /**
  21948. * Specifies if the material uses a texture
  21949. * @param texture defines the texture to check against the material
  21950. * @returns a boolean specifying if the material uses the texture
  21951. */
  21952. hasTexture(texture: BaseTexture): boolean;
  21953. /**
  21954. * Makes a duplicate of the material, and gives it a new name
  21955. * @param name defines the new name for the duplicated material
  21956. * @returns the cloned material
  21957. */
  21958. clone(name: string): Nullable<Material>;
  21959. /**
  21960. * Gets the meshes bound to the material
  21961. * @returns an array of meshes bound to the material
  21962. */
  21963. getBindedMeshes(): AbstractMesh[];
  21964. /**
  21965. * Force shader compilation
  21966. * @param mesh defines the mesh associated with this material
  21967. * @param onCompiled defines a function to execute once the material is compiled
  21968. * @param options defines the options to configure the compilation
  21969. */
  21970. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21971. clipPlane: boolean;
  21972. }>): void;
  21973. /**
  21974. * Force shader compilation
  21975. * @param mesh defines the mesh that will use this material
  21976. * @param options defines additional options for compiling the shaders
  21977. * @returns a promise that resolves when the compilation completes
  21978. */
  21979. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21980. clipPlane: boolean;
  21981. }>): Promise<void>;
  21982. private static readonly _ImageProcessingDirtyCallBack;
  21983. private static readonly _TextureDirtyCallBack;
  21984. private static readonly _FresnelDirtyCallBack;
  21985. private static readonly _MiscDirtyCallBack;
  21986. private static readonly _LightsDirtyCallBack;
  21987. private static readonly _AttributeDirtyCallBack;
  21988. private static _FresnelAndMiscDirtyCallBack;
  21989. private static _TextureAndMiscDirtyCallBack;
  21990. private static readonly _DirtyCallbackArray;
  21991. private static readonly _RunDirtyCallBacks;
  21992. /**
  21993. * Marks a define in the material to indicate that it needs to be re-computed
  21994. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21995. */
  21996. markAsDirty(flag: number): void;
  21997. /**
  21998. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21999. * @param func defines a function which checks material defines against the submeshes
  22000. */
  22001. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22002. /**
  22003. * Indicates that image processing needs to be re-calculated for all submeshes
  22004. */
  22005. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22006. /**
  22007. * Indicates that textures need to be re-calculated for all submeshes
  22008. */
  22009. protected _markAllSubMeshesAsTexturesDirty(): void;
  22010. /**
  22011. * Indicates that fresnel needs to be re-calculated for all submeshes
  22012. */
  22013. protected _markAllSubMeshesAsFresnelDirty(): void;
  22014. /**
  22015. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22016. */
  22017. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22018. /**
  22019. * Indicates that lights need to be re-calculated for all submeshes
  22020. */
  22021. protected _markAllSubMeshesAsLightsDirty(): void;
  22022. /**
  22023. * Indicates that attributes need to be re-calculated for all submeshes
  22024. */
  22025. protected _markAllSubMeshesAsAttributesDirty(): void;
  22026. /**
  22027. * Indicates that misc needs to be re-calculated for all submeshes
  22028. */
  22029. protected _markAllSubMeshesAsMiscDirty(): void;
  22030. /**
  22031. * Indicates that textures and misc need to be re-calculated for all submeshes
  22032. */
  22033. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22034. /**
  22035. * Disposes the material
  22036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22039. */
  22040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22041. /** @hidden */
  22042. private releaseVertexArrayObject;
  22043. /**
  22044. * Serializes this material
  22045. * @returns the serialized material object
  22046. */
  22047. serialize(): any;
  22048. /**
  22049. * Creates a material from parsed material data
  22050. * @param parsedMaterial defines parsed material data
  22051. * @param scene defines the hosting scene
  22052. * @param rootUrl defines the root URL to use to load textures
  22053. * @returns a new material
  22054. */
  22055. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22056. }
  22057. }
  22058. declare module "babylonjs/Meshes/subMesh" {
  22059. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22060. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22061. import { Engine } from "babylonjs/Engines/engine";
  22062. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22063. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22064. import { Effect } from "babylonjs/Materials/effect";
  22065. import { Collider } from "babylonjs/Collisions/collider";
  22066. import { Material } from "babylonjs/Materials/material";
  22067. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22069. import { Mesh } from "babylonjs/Meshes/mesh";
  22070. import { Ray } from "babylonjs/Culling/ray";
  22071. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22072. /**
  22073. * Base class for submeshes
  22074. */
  22075. export class BaseSubMesh {
  22076. /** @hidden */
  22077. _materialDefines: Nullable<MaterialDefines>;
  22078. /** @hidden */
  22079. _materialEffect: Nullable<Effect>;
  22080. /**
  22081. * Gets associated effect
  22082. */
  22083. readonly effect: Nullable<Effect>;
  22084. /**
  22085. * Sets associated effect (effect used to render this submesh)
  22086. * @param effect defines the effect to associate with
  22087. * @param defines defines the set of defines used to compile this effect
  22088. */
  22089. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22090. }
  22091. /**
  22092. * Defines a subdivision inside a mesh
  22093. */
  22094. export class SubMesh extends BaseSubMesh implements ICullable {
  22095. /** the material index to use */
  22096. materialIndex: number;
  22097. /** vertex index start */
  22098. verticesStart: number;
  22099. /** vertices count */
  22100. verticesCount: number;
  22101. /** index start */
  22102. indexStart: number;
  22103. /** indices count */
  22104. indexCount: number;
  22105. /** @hidden */
  22106. _linesIndexCount: number;
  22107. private _mesh;
  22108. private _renderingMesh;
  22109. private _boundingInfo;
  22110. private _linesIndexBuffer;
  22111. /** @hidden */
  22112. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22113. /** @hidden */
  22114. _trianglePlanes: Plane[];
  22115. /** @hidden */
  22116. _lastColliderTransformMatrix: Matrix;
  22117. /** @hidden */
  22118. _renderId: number;
  22119. /** @hidden */
  22120. _alphaIndex: number;
  22121. /** @hidden */
  22122. _distanceToCamera: number;
  22123. /** @hidden */
  22124. _id: number;
  22125. private _currentMaterial;
  22126. /**
  22127. * Add a new submesh to a mesh
  22128. * @param materialIndex defines the material index to use
  22129. * @param verticesStart defines vertex index start
  22130. * @param verticesCount defines vertices count
  22131. * @param indexStart defines index start
  22132. * @param indexCount defines indices count
  22133. * @param mesh defines the parent mesh
  22134. * @param renderingMesh defines an optional rendering mesh
  22135. * @param createBoundingBox defines if bounding box should be created for this submesh
  22136. * @returns the new submesh
  22137. */
  22138. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22139. /**
  22140. * Creates a new submesh
  22141. * @param materialIndex defines the material index to use
  22142. * @param verticesStart defines vertex index start
  22143. * @param verticesCount defines vertices count
  22144. * @param indexStart defines index start
  22145. * @param indexCount defines indices count
  22146. * @param mesh defines the parent mesh
  22147. * @param renderingMesh defines an optional rendering mesh
  22148. * @param createBoundingBox defines if bounding box should be created for this submesh
  22149. */
  22150. constructor(
  22151. /** the material index to use */
  22152. materialIndex: number,
  22153. /** vertex index start */
  22154. verticesStart: number,
  22155. /** vertices count */
  22156. verticesCount: number,
  22157. /** index start */
  22158. indexStart: number,
  22159. /** indices count */
  22160. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22161. /**
  22162. * Returns true if this submesh covers the entire parent mesh
  22163. * @ignorenaming
  22164. */
  22165. readonly IsGlobal: boolean;
  22166. /**
  22167. * Returns the submesh BoudingInfo object
  22168. * @returns current bounding info (or mesh's one if the submesh is global)
  22169. */
  22170. getBoundingInfo(): BoundingInfo;
  22171. /**
  22172. * Sets the submesh BoundingInfo
  22173. * @param boundingInfo defines the new bounding info to use
  22174. * @returns the SubMesh
  22175. */
  22176. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22177. /**
  22178. * Returns the mesh of the current submesh
  22179. * @return the parent mesh
  22180. */
  22181. getMesh(): AbstractMesh;
  22182. /**
  22183. * Returns the rendering mesh of the submesh
  22184. * @returns the rendering mesh (could be different from parent mesh)
  22185. */
  22186. getRenderingMesh(): Mesh;
  22187. /**
  22188. * Returns the submesh material
  22189. * @returns null or the current material
  22190. */
  22191. getMaterial(): Nullable<Material>;
  22192. /**
  22193. * Sets a new updated BoundingInfo object to the submesh
  22194. * @returns the SubMesh
  22195. */
  22196. refreshBoundingInfo(): SubMesh;
  22197. /** @hidden */
  22198. _checkCollision(collider: Collider): boolean;
  22199. /**
  22200. * Updates the submesh BoundingInfo
  22201. * @param world defines the world matrix to use to update the bounding info
  22202. * @returns the submesh
  22203. */
  22204. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22205. /**
  22206. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22207. * @param frustumPlanes defines the frustum planes
  22208. * @returns true if the submesh is intersecting with the frustum
  22209. */
  22210. isInFrustum(frustumPlanes: Plane[]): boolean;
  22211. /**
  22212. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22213. * @param frustumPlanes defines the frustum planes
  22214. * @returns true if the submesh is inside the frustum
  22215. */
  22216. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22217. /**
  22218. * Renders the submesh
  22219. * @param enableAlphaMode defines if alpha needs to be used
  22220. * @returns the submesh
  22221. */
  22222. render(enableAlphaMode: boolean): SubMesh;
  22223. /**
  22224. * @hidden
  22225. */
  22226. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22227. /**
  22228. * Checks if the submesh intersects with a ray
  22229. * @param ray defines the ray to test
  22230. * @returns true is the passed ray intersects the submesh bounding box
  22231. */
  22232. canIntersects(ray: Ray): boolean;
  22233. /**
  22234. * Intersects current submesh with a ray
  22235. * @param ray defines the ray to test
  22236. * @param positions defines mesh's positions array
  22237. * @param indices defines mesh's indices array
  22238. * @param fastCheck defines if only bounding info should be used
  22239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22240. * @returns intersection info or null if no intersection
  22241. */
  22242. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22243. /** @hidden */
  22244. private _intersectLines;
  22245. /** @hidden */
  22246. private _intersectTriangles;
  22247. /** @hidden */
  22248. _rebuild(): void;
  22249. /**
  22250. * Creates a new submesh from the passed mesh
  22251. * @param newMesh defines the new hosting mesh
  22252. * @param newRenderingMesh defines an optional rendering mesh
  22253. * @returns the new submesh
  22254. */
  22255. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22256. /**
  22257. * Release associated resources
  22258. */
  22259. dispose(): void;
  22260. /**
  22261. * Gets the class name
  22262. * @returns the string "SubMesh".
  22263. */
  22264. getClassName(): string;
  22265. /**
  22266. * Creates a new submesh from indices data
  22267. * @param materialIndex the index of the main mesh material
  22268. * @param startIndex the index where to start the copy in the mesh indices array
  22269. * @param indexCount the number of indices to copy then from the startIndex
  22270. * @param mesh the main mesh to create the submesh from
  22271. * @param renderingMesh the optional rendering mesh
  22272. * @returns a new submesh
  22273. */
  22274. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22275. }
  22276. }
  22277. declare module "babylonjs/Meshes/geometry" {
  22278. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22279. import { Scene } from "babylonjs/scene";
  22280. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22281. import { Engine } from "babylonjs/Engines/engine";
  22282. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22283. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22284. import { Effect } from "babylonjs/Materials/effect";
  22285. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22286. import { Mesh } from "babylonjs/Meshes/mesh";
  22287. /**
  22288. * Class used to store geometry data (vertex buffers + index buffer)
  22289. */
  22290. export class Geometry implements IGetSetVerticesData {
  22291. /**
  22292. * Gets or sets the ID of the geometry
  22293. */
  22294. id: string;
  22295. /**
  22296. * Gets or sets the unique ID of the geometry
  22297. */
  22298. uniqueId: number;
  22299. /**
  22300. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22301. */
  22302. delayLoadState: number;
  22303. /**
  22304. * Gets the file containing the data to load when running in delay load state
  22305. */
  22306. delayLoadingFile: Nullable<string>;
  22307. /**
  22308. * Callback called when the geometry is updated
  22309. */
  22310. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22311. private _scene;
  22312. private _engine;
  22313. private _meshes;
  22314. private _totalVertices;
  22315. /** @hidden */
  22316. _indices: IndicesArray;
  22317. /** @hidden */
  22318. _vertexBuffers: {
  22319. [key: string]: VertexBuffer;
  22320. };
  22321. private _isDisposed;
  22322. private _extend;
  22323. private _boundingBias;
  22324. /** @hidden */
  22325. _delayInfo: Array<string>;
  22326. private _indexBuffer;
  22327. private _indexBufferIsUpdatable;
  22328. /** @hidden */
  22329. _boundingInfo: Nullable<BoundingInfo>;
  22330. /** @hidden */
  22331. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22332. /** @hidden */
  22333. _softwareSkinningFrameId: number;
  22334. private _vertexArrayObjects;
  22335. private _updatable;
  22336. /** @hidden */
  22337. _positions: Nullable<Vector3[]>;
  22338. /**
  22339. * 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
  22340. */
  22341. /**
  22342. * 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
  22343. */
  22344. boundingBias: Vector2;
  22345. /**
  22346. * Static function used to attach a new empty geometry to a mesh
  22347. * @param mesh defines the mesh to attach the geometry to
  22348. * @returns the new Geometry
  22349. */
  22350. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22351. /**
  22352. * Creates a new geometry
  22353. * @param id defines the unique ID
  22354. * @param scene defines the hosting scene
  22355. * @param vertexData defines the VertexData used to get geometry data
  22356. * @param updatable defines if geometry must be updatable (false by default)
  22357. * @param mesh defines the mesh that will be associated with the geometry
  22358. */
  22359. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22360. /**
  22361. * Gets the current extend of the geometry
  22362. */
  22363. readonly extend: {
  22364. minimum: Vector3;
  22365. maximum: Vector3;
  22366. };
  22367. /**
  22368. * Gets the hosting scene
  22369. * @returns the hosting Scene
  22370. */
  22371. getScene(): Scene;
  22372. /**
  22373. * Gets the hosting engine
  22374. * @returns the hosting Engine
  22375. */
  22376. getEngine(): Engine;
  22377. /**
  22378. * Defines if the geometry is ready to use
  22379. * @returns true if the geometry is ready to be used
  22380. */
  22381. isReady(): boolean;
  22382. /**
  22383. * Gets a value indicating that the geometry should not be serialized
  22384. */
  22385. readonly doNotSerialize: boolean;
  22386. /** @hidden */
  22387. _rebuild(): void;
  22388. /**
  22389. * Affects all geometry data in one call
  22390. * @param vertexData defines the geometry data
  22391. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22392. */
  22393. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22394. /**
  22395. * Set specific vertex data
  22396. * @param kind defines the data kind (Position, normal, etc...)
  22397. * @param data defines the vertex data to use
  22398. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22399. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22400. */
  22401. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22402. /**
  22403. * Removes a specific vertex data
  22404. * @param kind defines the data kind (Position, normal, etc...)
  22405. */
  22406. removeVerticesData(kind: string): void;
  22407. /**
  22408. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22409. * @param buffer defines the vertex buffer to use
  22410. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22411. */
  22412. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22413. /**
  22414. * Update a specific vertex buffer
  22415. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22416. * It will do nothing if the buffer is not updatable
  22417. * @param kind defines the data kind (Position, normal, etc...)
  22418. * @param data defines the data to use
  22419. * @param offset defines the offset in the target buffer where to store the data
  22420. * @param useBytes set to true if the offset is in bytes
  22421. */
  22422. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22423. /**
  22424. * Update a specific vertex buffer
  22425. * This function will create a new buffer if the current one is not updatable
  22426. * @param kind defines the data kind (Position, normal, etc...)
  22427. * @param data defines the data to use
  22428. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22429. */
  22430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22431. private _updateBoundingInfo;
  22432. /** @hidden */
  22433. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22434. /**
  22435. * Gets total number of vertices
  22436. * @returns the total number of vertices
  22437. */
  22438. getTotalVertices(): number;
  22439. /**
  22440. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22441. * @param kind defines the data kind (Position, normal, etc...)
  22442. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22443. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22444. * @returns a float array containing vertex data
  22445. */
  22446. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22447. /**
  22448. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22449. * @param kind defines the data kind (Position, normal, etc...)
  22450. * @returns true if the vertex buffer with the specified kind is updatable
  22451. */
  22452. isVertexBufferUpdatable(kind: string): boolean;
  22453. /**
  22454. * Gets a specific vertex buffer
  22455. * @param kind defines the data kind (Position, normal, etc...)
  22456. * @returns a VertexBuffer
  22457. */
  22458. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22459. /**
  22460. * Returns all vertex buffers
  22461. * @return an object holding all vertex buffers indexed by kind
  22462. */
  22463. getVertexBuffers(): Nullable<{
  22464. [key: string]: VertexBuffer;
  22465. }>;
  22466. /**
  22467. * Gets a boolean indicating if specific vertex buffer is present
  22468. * @param kind defines the data kind (Position, normal, etc...)
  22469. * @returns true if data is present
  22470. */
  22471. isVerticesDataPresent(kind: string): boolean;
  22472. /**
  22473. * Gets a list of all attached data kinds (Position, normal, etc...)
  22474. * @returns a list of string containing all kinds
  22475. */
  22476. getVerticesDataKinds(): string[];
  22477. /**
  22478. * Update index buffer
  22479. * @param indices defines the indices to store in the index buffer
  22480. * @param offset defines the offset in the target buffer where to store the data
  22481. */
  22482. updateIndices(indices: IndicesArray, offset?: number): void;
  22483. /**
  22484. * Creates a new index buffer
  22485. * @param indices defines the indices to store in the index buffer
  22486. * @param totalVertices defines the total number of vertices (could be null)
  22487. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22488. */
  22489. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22490. /**
  22491. * Return the total number of indices
  22492. * @returns the total number of indices
  22493. */
  22494. getTotalIndices(): number;
  22495. /**
  22496. * Gets the index buffer array
  22497. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22498. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22499. * @returns the index buffer array
  22500. */
  22501. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22502. /**
  22503. * Gets the index buffer
  22504. * @return the index buffer
  22505. */
  22506. getIndexBuffer(): Nullable<WebGLBuffer>;
  22507. /** @hidden */
  22508. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22509. /**
  22510. * Release the associated resources for a specific mesh
  22511. * @param mesh defines the source mesh
  22512. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22513. */
  22514. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22515. /**
  22516. * Apply current geometry to a given mesh
  22517. * @param mesh defines the mesh to apply geometry to
  22518. */
  22519. applyToMesh(mesh: Mesh): void;
  22520. private _updateExtend;
  22521. private _applyToMesh;
  22522. private notifyUpdate;
  22523. /**
  22524. * Load the geometry if it was flagged as delay loaded
  22525. * @param scene defines the hosting scene
  22526. * @param onLoaded defines a callback called when the geometry is loaded
  22527. */
  22528. load(scene: Scene, onLoaded?: () => void): void;
  22529. private _queueLoad;
  22530. /**
  22531. * Invert the geometry to move from a right handed system to a left handed one.
  22532. */
  22533. toLeftHanded(): void;
  22534. /** @hidden */
  22535. _resetPointsArrayCache(): void;
  22536. /** @hidden */
  22537. _generatePointsArray(): boolean;
  22538. /**
  22539. * Gets a value indicating if the geometry is disposed
  22540. * @returns true if the geometry was disposed
  22541. */
  22542. isDisposed(): boolean;
  22543. private _disposeVertexArrayObjects;
  22544. /**
  22545. * Free all associated resources
  22546. */
  22547. dispose(): void;
  22548. /**
  22549. * Clone the current geometry into a new geometry
  22550. * @param id defines the unique ID of the new geometry
  22551. * @returns a new geometry object
  22552. */
  22553. copy(id: string): Geometry;
  22554. /**
  22555. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22556. * @return a JSON representation of the current geometry data (without the vertices data)
  22557. */
  22558. serialize(): any;
  22559. private toNumberArray;
  22560. /**
  22561. * Serialize all vertices data into a JSON oject
  22562. * @returns a JSON representation of the current geometry data
  22563. */
  22564. serializeVerticeData(): any;
  22565. /**
  22566. * Extracts a clone of a mesh geometry
  22567. * @param mesh defines the source mesh
  22568. * @param id defines the unique ID of the new geometry object
  22569. * @returns the new geometry object
  22570. */
  22571. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22572. /**
  22573. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22574. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22575. * Be aware Math.random() could cause collisions, but:
  22576. * "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"
  22577. * @returns a string containing a new GUID
  22578. */
  22579. static RandomId(): string;
  22580. /** @hidden */
  22581. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22582. private static _CleanMatricesWeights;
  22583. /**
  22584. * Create a new geometry from persisted data (Using .babylon file format)
  22585. * @param parsedVertexData defines the persisted data
  22586. * @param scene defines the hosting scene
  22587. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22588. * @returns the new geometry object
  22589. */
  22590. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22591. }
  22592. }
  22593. declare module "babylonjs/Meshes/mesh.vertexData" {
  22594. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22595. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22596. import { Geometry } from "babylonjs/Meshes/geometry";
  22597. import { Mesh } from "babylonjs/Meshes/mesh";
  22598. /**
  22599. * Define an interface for all classes that will get and set the data on vertices
  22600. */
  22601. export interface IGetSetVerticesData {
  22602. /**
  22603. * Gets a boolean indicating if specific vertex data is present
  22604. * @param kind defines the vertex data kind to use
  22605. * @returns true is data kind is present
  22606. */
  22607. isVerticesDataPresent(kind: string): boolean;
  22608. /**
  22609. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22610. * @param kind defines the data kind (Position, normal, etc...)
  22611. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22613. * @returns a float array containing vertex data
  22614. */
  22615. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22616. /**
  22617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22618. * @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.
  22619. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22620. * @returns the indices array or an empty array if the mesh has no geometry
  22621. */
  22622. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22623. /**
  22624. * Set specific vertex data
  22625. * @param kind defines the data kind (Position, normal, etc...)
  22626. * @param data defines the vertex data to use
  22627. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22628. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22629. */
  22630. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22631. /**
  22632. * Update a specific associated vertex buffer
  22633. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22634. * - VertexBuffer.PositionKind
  22635. * - VertexBuffer.UVKind
  22636. * - VertexBuffer.UV2Kind
  22637. * - VertexBuffer.UV3Kind
  22638. * - VertexBuffer.UV4Kind
  22639. * - VertexBuffer.UV5Kind
  22640. * - VertexBuffer.UV6Kind
  22641. * - VertexBuffer.ColorKind
  22642. * - VertexBuffer.MatricesIndicesKind
  22643. * - VertexBuffer.MatricesIndicesExtraKind
  22644. * - VertexBuffer.MatricesWeightsKind
  22645. * - VertexBuffer.MatricesWeightsExtraKind
  22646. * @param data defines the data source
  22647. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22648. * @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)
  22649. */
  22650. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22651. /**
  22652. * Creates a new index buffer
  22653. * @param indices defines the indices to store in the index buffer
  22654. * @param totalVertices defines the total number of vertices (could be null)
  22655. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22656. */
  22657. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22658. }
  22659. /**
  22660. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22661. */
  22662. export class VertexData {
  22663. /**
  22664. * Mesh side orientation : usually the external or front surface
  22665. */
  22666. static readonly FRONTSIDE: number;
  22667. /**
  22668. * Mesh side orientation : usually the internal or back surface
  22669. */
  22670. static readonly BACKSIDE: number;
  22671. /**
  22672. * Mesh side orientation : both internal and external or front and back surfaces
  22673. */
  22674. static readonly DOUBLESIDE: number;
  22675. /**
  22676. * Mesh side orientation : by default, `FRONTSIDE`
  22677. */
  22678. static readonly DEFAULTSIDE: number;
  22679. /**
  22680. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22681. */
  22682. positions: Nullable<FloatArray>;
  22683. /**
  22684. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22685. */
  22686. normals: Nullable<FloatArray>;
  22687. /**
  22688. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22689. */
  22690. tangents: Nullable<FloatArray>;
  22691. /**
  22692. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22693. */
  22694. uvs: Nullable<FloatArray>;
  22695. /**
  22696. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22697. */
  22698. uvs2: Nullable<FloatArray>;
  22699. /**
  22700. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22701. */
  22702. uvs3: Nullable<FloatArray>;
  22703. /**
  22704. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22705. */
  22706. uvs4: Nullable<FloatArray>;
  22707. /**
  22708. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22709. */
  22710. uvs5: Nullable<FloatArray>;
  22711. /**
  22712. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22713. */
  22714. uvs6: Nullable<FloatArray>;
  22715. /**
  22716. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22717. */
  22718. colors: Nullable<FloatArray>;
  22719. /**
  22720. * 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).
  22721. */
  22722. matricesIndices: Nullable<FloatArray>;
  22723. /**
  22724. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22725. */
  22726. matricesWeights: Nullable<FloatArray>;
  22727. /**
  22728. * An array extending the number of possible indices
  22729. */
  22730. matricesIndicesExtra: Nullable<FloatArray>;
  22731. /**
  22732. * An array extending the number of possible weights when the number of indices is extended
  22733. */
  22734. matricesWeightsExtra: Nullable<FloatArray>;
  22735. /**
  22736. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22737. */
  22738. indices: Nullable<IndicesArray>;
  22739. /**
  22740. * Uses the passed data array to set the set the values for the specified kind of data
  22741. * @param data a linear array of floating numbers
  22742. * @param kind the type of data that is being set, eg positions, colors etc
  22743. */
  22744. set(data: FloatArray, kind: string): void;
  22745. /**
  22746. * Associates the vertexData to the passed Mesh.
  22747. * Sets it as updatable or not (default `false`)
  22748. * @param mesh the mesh the vertexData is applied to
  22749. * @param updatable when used and having the value true allows new data to update the vertexData
  22750. * @returns the VertexData
  22751. */
  22752. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22753. /**
  22754. * Associates the vertexData to the passed Geometry.
  22755. * Sets it as updatable or not (default `false`)
  22756. * @param geometry the geometry the vertexData is applied to
  22757. * @param updatable when used and having the value true allows new data to update the vertexData
  22758. * @returns VertexData
  22759. */
  22760. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22761. /**
  22762. * Updates the associated mesh
  22763. * @param mesh the mesh to be updated
  22764. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22765. * @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
  22766. * @returns VertexData
  22767. */
  22768. updateMesh(mesh: Mesh): VertexData;
  22769. /**
  22770. * Updates the associated geometry
  22771. * @param geometry the geometry to be updated
  22772. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22773. * @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
  22774. * @returns VertexData.
  22775. */
  22776. updateGeometry(geometry: Geometry): VertexData;
  22777. private _applyTo;
  22778. private _update;
  22779. /**
  22780. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22781. * @param matrix the transforming matrix
  22782. * @returns the VertexData
  22783. */
  22784. transform(matrix: Matrix): VertexData;
  22785. /**
  22786. * Merges the passed VertexData into the current one
  22787. * @param other the VertexData to be merged into the current one
  22788. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22789. * @returns the modified VertexData
  22790. */
  22791. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22792. private _mergeElement;
  22793. private _validate;
  22794. /**
  22795. * Serializes the VertexData
  22796. * @returns a serialized object
  22797. */
  22798. serialize(): any;
  22799. /**
  22800. * Extracts the vertexData from a mesh
  22801. * @param mesh the mesh from which to extract the VertexData
  22802. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22803. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22804. * @returns the object VertexData associated to the passed mesh
  22805. */
  22806. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22807. /**
  22808. * Extracts the vertexData from the geometry
  22809. * @param geometry the geometry from which to extract the VertexData
  22810. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22811. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22812. * @returns the object VertexData associated to the passed mesh
  22813. */
  22814. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22815. private static _ExtractFrom;
  22816. /**
  22817. * Creates the VertexData for a Ribbon
  22818. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22819. * * pathArray array of paths, each of which an array of successive Vector3
  22820. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22821. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22822. * * 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
  22823. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22824. * * 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)
  22825. * * 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)
  22826. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22827. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22828. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22829. * @returns the VertexData of the ribbon
  22830. */
  22831. static CreateRibbon(options: {
  22832. pathArray: Vector3[][];
  22833. closeArray?: boolean;
  22834. closePath?: boolean;
  22835. offset?: number;
  22836. sideOrientation?: number;
  22837. frontUVs?: Vector4;
  22838. backUVs?: Vector4;
  22839. invertUV?: boolean;
  22840. uvs?: Vector2[];
  22841. colors?: Color4[];
  22842. }): VertexData;
  22843. /**
  22844. * Creates the VertexData for a box
  22845. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22846. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22847. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22848. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22849. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22850. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22851. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22853. * * 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)
  22854. * * 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)
  22855. * @returns the VertexData of the box
  22856. */
  22857. static CreateBox(options: {
  22858. size?: number;
  22859. width?: number;
  22860. height?: number;
  22861. depth?: number;
  22862. faceUV?: Vector4[];
  22863. faceColors?: Color4[];
  22864. sideOrientation?: number;
  22865. frontUVs?: Vector4;
  22866. backUVs?: Vector4;
  22867. }): VertexData;
  22868. /**
  22869. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22870. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22871. * * segments sets the number of horizontal strips optional, default 32
  22872. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22873. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22874. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22875. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22876. * * 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
  22877. * * 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
  22878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22879. * * 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)
  22880. * * 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)
  22881. * @returns the VertexData of the ellipsoid
  22882. */
  22883. static CreateSphere(options: {
  22884. segments?: number;
  22885. diameter?: number;
  22886. diameterX?: number;
  22887. diameterY?: number;
  22888. diameterZ?: number;
  22889. arc?: number;
  22890. slice?: number;
  22891. sideOrientation?: number;
  22892. frontUVs?: Vector4;
  22893. backUVs?: Vector4;
  22894. }): VertexData;
  22895. /**
  22896. * Creates the VertexData for a cylinder, cone or prism
  22897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22898. * * height sets the height (y direction) of the cylinder, optional, default 2
  22899. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22900. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22901. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22902. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22903. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22904. * * 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
  22905. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22907. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22908. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22910. * * 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)
  22911. * * 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)
  22912. * @returns the VertexData of the cylinder, cone or prism
  22913. */
  22914. static CreateCylinder(options: {
  22915. height?: number;
  22916. diameterTop?: number;
  22917. diameterBottom?: number;
  22918. diameter?: number;
  22919. tessellation?: number;
  22920. subdivisions?: number;
  22921. arc?: number;
  22922. faceColors?: Color4[];
  22923. faceUV?: Vector4[];
  22924. hasRings?: boolean;
  22925. enclose?: boolean;
  22926. sideOrientation?: number;
  22927. frontUVs?: Vector4;
  22928. backUVs?: Vector4;
  22929. }): VertexData;
  22930. /**
  22931. * Creates the VertexData for a torus
  22932. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22933. * * diameter the diameter of the torus, optional default 1
  22934. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22935. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22936. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22937. * * 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)
  22938. * * 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)
  22939. * @returns the VertexData of the torus
  22940. */
  22941. static CreateTorus(options: {
  22942. diameter?: number;
  22943. thickness?: number;
  22944. tessellation?: number;
  22945. sideOrientation?: number;
  22946. frontUVs?: Vector4;
  22947. backUVs?: Vector4;
  22948. }): VertexData;
  22949. /**
  22950. * Creates the VertexData of the LineSystem
  22951. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22952. * - lines an array of lines, each line being an array of successive Vector3
  22953. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22954. * @returns the VertexData of the LineSystem
  22955. */
  22956. static CreateLineSystem(options: {
  22957. lines: Vector3[][];
  22958. colors?: Nullable<Color4[][]>;
  22959. }): VertexData;
  22960. /**
  22961. * Create the VertexData for a DashedLines
  22962. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22963. * - points an array successive Vector3
  22964. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22965. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22966. * - dashNb the intended total number of dashes, optional, default 200
  22967. * @returns the VertexData for the DashedLines
  22968. */
  22969. static CreateDashedLines(options: {
  22970. points: Vector3[];
  22971. dashSize?: number;
  22972. gapSize?: number;
  22973. dashNb?: number;
  22974. }): VertexData;
  22975. /**
  22976. * Creates the VertexData for a Ground
  22977. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22978. * - width the width (x direction) of the ground, optional, default 1
  22979. * - height the height (z direction) of the ground, optional, default 1
  22980. * - subdivisions the number of subdivisions per side, optional, default 1
  22981. * @returns the VertexData of the Ground
  22982. */
  22983. static CreateGround(options: {
  22984. width?: number;
  22985. height?: number;
  22986. subdivisions?: number;
  22987. subdivisionsX?: number;
  22988. subdivisionsY?: number;
  22989. }): VertexData;
  22990. /**
  22991. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22992. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22993. * * xmin the ground minimum X coordinate, optional, default -1
  22994. * * zmin the ground minimum Z coordinate, optional, default -1
  22995. * * xmax the ground maximum X coordinate, optional, default 1
  22996. * * zmax the ground maximum Z coordinate, optional, default 1
  22997. * * 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}
  22998. * * 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}
  22999. * @returns the VertexData of the TiledGround
  23000. */
  23001. static CreateTiledGround(options: {
  23002. xmin: number;
  23003. zmin: number;
  23004. xmax: number;
  23005. zmax: number;
  23006. subdivisions?: {
  23007. w: number;
  23008. h: number;
  23009. };
  23010. precision?: {
  23011. w: number;
  23012. h: number;
  23013. };
  23014. }): VertexData;
  23015. /**
  23016. * Creates the VertexData of the Ground designed from a heightmap
  23017. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23018. * * width the width (x direction) of the ground
  23019. * * height the height (z direction) of the ground
  23020. * * subdivisions the number of subdivisions per side
  23021. * * minHeight the minimum altitude on the ground, optional, default 0
  23022. * * maxHeight the maximum altitude on the ground, optional default 1
  23023. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23024. * * buffer the array holding the image color data
  23025. * * bufferWidth the width of image
  23026. * * bufferHeight the height of image
  23027. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23028. * @returns the VertexData of the Ground designed from a heightmap
  23029. */
  23030. static CreateGroundFromHeightMap(options: {
  23031. width: number;
  23032. height: number;
  23033. subdivisions: number;
  23034. minHeight: number;
  23035. maxHeight: number;
  23036. colorFilter: Color3;
  23037. buffer: Uint8Array;
  23038. bufferWidth: number;
  23039. bufferHeight: number;
  23040. alphaFilter: number;
  23041. }): VertexData;
  23042. /**
  23043. * Creates the VertexData for a Plane
  23044. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23045. * * size sets the width and height of the plane to the value of size, optional default 1
  23046. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23047. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23049. * * 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)
  23050. * * 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)
  23051. * @returns the VertexData of the box
  23052. */
  23053. static CreatePlane(options: {
  23054. size?: number;
  23055. width?: number;
  23056. height?: number;
  23057. sideOrientation?: number;
  23058. frontUVs?: Vector4;
  23059. backUVs?: Vector4;
  23060. }): VertexData;
  23061. /**
  23062. * Creates the VertexData of the Disc or regular Polygon
  23063. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23064. * * radius the radius of the disc, optional default 0.5
  23065. * * tessellation the number of polygon sides, optional, default 64
  23066. * * 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
  23067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23068. * * 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)
  23069. * * 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)
  23070. * @returns the VertexData of the box
  23071. */
  23072. static CreateDisc(options: {
  23073. radius?: number;
  23074. tessellation?: number;
  23075. arc?: number;
  23076. sideOrientation?: number;
  23077. frontUVs?: Vector4;
  23078. backUVs?: Vector4;
  23079. }): VertexData;
  23080. /**
  23081. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23082. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23083. * @param polygon a mesh built from polygonTriangulation.build()
  23084. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23085. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23086. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23087. * @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)
  23088. * @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)
  23089. * @returns the VertexData of the Polygon
  23090. */
  23091. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23092. /**
  23093. * Creates the VertexData of the IcoSphere
  23094. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23095. * * radius the radius of the IcoSphere, optional default 1
  23096. * * radiusX allows stretching in the x direction, optional, default radius
  23097. * * radiusY allows stretching in the y direction, optional, default radius
  23098. * * radiusZ allows stretching in the z direction, optional, default radius
  23099. * * flat when true creates a flat shaded mesh, optional, default true
  23100. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23102. * * 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)
  23103. * * 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)
  23104. * @returns the VertexData of the IcoSphere
  23105. */
  23106. static CreateIcoSphere(options: {
  23107. radius?: number;
  23108. radiusX?: number;
  23109. radiusY?: number;
  23110. radiusZ?: number;
  23111. flat?: boolean;
  23112. subdivisions?: number;
  23113. sideOrientation?: number;
  23114. frontUVs?: Vector4;
  23115. backUVs?: Vector4;
  23116. }): VertexData;
  23117. /**
  23118. * Creates the VertexData for a Polyhedron
  23119. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23120. * * type provided types are:
  23121. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23122. * * 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)
  23123. * * size the size of the IcoSphere, optional default 1
  23124. * * sizeX allows stretching in the x direction, optional, default size
  23125. * * sizeY allows stretching in the y direction, optional, default size
  23126. * * sizeZ allows stretching in the z direction, optional, default size
  23127. * * 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
  23128. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23129. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23130. * * flat when true creates a flat shaded mesh, optional, default true
  23131. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23133. * * 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)
  23134. * * 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)
  23135. * @returns the VertexData of the Polyhedron
  23136. */
  23137. static CreatePolyhedron(options: {
  23138. type?: number;
  23139. size?: number;
  23140. sizeX?: number;
  23141. sizeY?: number;
  23142. sizeZ?: number;
  23143. custom?: any;
  23144. faceUV?: Vector4[];
  23145. faceColors?: Color4[];
  23146. flat?: boolean;
  23147. sideOrientation?: number;
  23148. frontUVs?: Vector4;
  23149. backUVs?: Vector4;
  23150. }): VertexData;
  23151. /**
  23152. * Creates the VertexData for a TorusKnot
  23153. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23154. * * radius the radius of the torus knot, optional, default 2
  23155. * * tube the thickness of the tube, optional, default 0.5
  23156. * * radialSegments the number of sides on each tube segments, optional, default 32
  23157. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23158. * * p the number of windings around the z axis, optional, default 2
  23159. * * q the number of windings around the x axis, optional, default 3
  23160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23161. * * 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)
  23162. * * 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)
  23163. * @returns the VertexData of the Torus Knot
  23164. */
  23165. static CreateTorusKnot(options: {
  23166. radius?: number;
  23167. tube?: number;
  23168. radialSegments?: number;
  23169. tubularSegments?: number;
  23170. p?: number;
  23171. q?: number;
  23172. sideOrientation?: number;
  23173. frontUVs?: Vector4;
  23174. backUVs?: Vector4;
  23175. }): VertexData;
  23176. /**
  23177. * Compute normals for given positions and indices
  23178. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23179. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23180. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23181. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23182. * * facetNormals : optional array of facet normals (vector3)
  23183. * * facetPositions : optional array of facet positions (vector3)
  23184. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23185. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23186. * * bInfo : optional bounding info, required for facetPartitioning computation
  23187. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23188. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23189. * * useRightHandedSystem: optional boolean to for right handed system computation
  23190. * * depthSort : optional boolean to enable the facet depth sort computation
  23191. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23192. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23193. */
  23194. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23195. facetNormals?: any;
  23196. facetPositions?: any;
  23197. facetPartitioning?: any;
  23198. ratio?: number;
  23199. bInfo?: any;
  23200. bbSize?: Vector3;
  23201. subDiv?: any;
  23202. useRightHandedSystem?: boolean;
  23203. depthSort?: boolean;
  23204. distanceTo?: Vector3;
  23205. depthSortedFacets?: any;
  23206. }): void;
  23207. /** @hidden */
  23208. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23209. /**
  23210. * Applies VertexData created from the imported parameters to the geometry
  23211. * @param parsedVertexData the parsed data from an imported file
  23212. * @param geometry the geometry to apply the VertexData to
  23213. */
  23214. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23215. }
  23216. }
  23217. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23218. import { Nullable } from "babylonjs/types";
  23219. import { Scene } from "babylonjs/scene";
  23220. import { Vector4 } from "babylonjs/Maths/math";
  23221. import { Mesh } from "babylonjs/Meshes/mesh";
  23222. /**
  23223. * Class containing static functions to help procedurally build meshes
  23224. */
  23225. export class DiscBuilder {
  23226. /**
  23227. * Creates a plane polygonal mesh. By default, this is a disc
  23228. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23229. * * 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
  23230. * * 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
  23231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23234. * @param name defines the name of the mesh
  23235. * @param options defines the options used to create the mesh
  23236. * @param scene defines the hosting scene
  23237. * @returns the plane polygonal mesh
  23238. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23239. */
  23240. static CreateDisc(name: string, options: {
  23241. radius?: number;
  23242. tessellation?: number;
  23243. arc?: number;
  23244. updatable?: boolean;
  23245. sideOrientation?: number;
  23246. frontUVs?: Vector4;
  23247. backUVs?: Vector4;
  23248. }, scene?: Nullable<Scene>): Mesh;
  23249. }
  23250. }
  23251. declare module "babylonjs/Particles/solidParticleSystem" {
  23252. import { Vector3 } from "babylonjs/Maths/math";
  23253. import { Mesh } from "babylonjs/Meshes/mesh";
  23254. import { Scene, IDisposable } from "babylonjs/scene";
  23255. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23256. /**
  23257. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23258. *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.
  23259. * The SPS is also a particle system. It provides some methods to manage the particles.
  23260. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23261. *
  23262. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23263. */
  23264. export class SolidParticleSystem implements IDisposable {
  23265. /**
  23266. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23267. * Example : var p = SPS.particles[i];
  23268. */
  23269. particles: SolidParticle[];
  23270. /**
  23271. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23272. */
  23273. nbParticles: number;
  23274. /**
  23275. * If the particles must ever face the camera (default false). Useful for planar particles.
  23276. */
  23277. billboard: boolean;
  23278. /**
  23279. * Recompute normals when adding a shape
  23280. */
  23281. recomputeNormals: boolean;
  23282. /**
  23283. * This a counter ofr your own usage. It's not set by any SPS functions.
  23284. */
  23285. counter: number;
  23286. /**
  23287. * The SPS name. This name is also given to the underlying mesh.
  23288. */
  23289. name: string;
  23290. /**
  23291. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23292. */
  23293. mesh: Mesh;
  23294. /**
  23295. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23296. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23297. */
  23298. vars: any;
  23299. /**
  23300. * This array is populated when the SPS is set as 'pickable'.
  23301. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23302. * Each element of this array is an object `{idx: int, faceId: int}`.
  23303. * `idx` is the picked particle index in the `SPS.particles` array
  23304. * `faceId` is the picked face index counted within this particle.
  23305. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23306. */
  23307. pickedParticles: {
  23308. idx: number;
  23309. faceId: number;
  23310. }[];
  23311. /**
  23312. * This array is populated when `enableDepthSort` is set to true.
  23313. * Each element of this array is an instance of the class DepthSortedParticle.
  23314. */
  23315. depthSortedParticles: DepthSortedParticle[];
  23316. /**
  23317. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23318. * @hidden
  23319. */
  23320. _bSphereOnly: boolean;
  23321. /**
  23322. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23323. * @hidden
  23324. */
  23325. _bSphereRadiusFactor: number;
  23326. private _scene;
  23327. private _positions;
  23328. private _indices;
  23329. private _normals;
  23330. private _colors;
  23331. private _uvs;
  23332. private _indices32;
  23333. private _positions32;
  23334. private _normals32;
  23335. private _fixedNormal32;
  23336. private _colors32;
  23337. private _uvs32;
  23338. private _index;
  23339. private _updatable;
  23340. private _pickable;
  23341. private _isVisibilityBoxLocked;
  23342. private _alwaysVisible;
  23343. private _depthSort;
  23344. private _shapeCounter;
  23345. private _copy;
  23346. private _color;
  23347. private _computeParticleColor;
  23348. private _computeParticleTexture;
  23349. private _computeParticleRotation;
  23350. private _computeParticleVertex;
  23351. private _computeBoundingBox;
  23352. private _depthSortParticles;
  23353. private _camera;
  23354. private _mustUnrotateFixedNormals;
  23355. private _particlesIntersect;
  23356. private _needs32Bits;
  23357. /**
  23358. * Creates a SPS (Solid Particle System) object.
  23359. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23360. * @param scene (Scene) is the scene in which the SPS is added.
  23361. * @param options defines the options of the sps e.g.
  23362. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23363. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23364. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23365. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23366. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23367. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23368. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23369. */
  23370. constructor(name: string, scene: Scene, options?: {
  23371. updatable?: boolean;
  23372. isPickable?: boolean;
  23373. enableDepthSort?: boolean;
  23374. particleIntersection?: boolean;
  23375. boundingSphereOnly?: boolean;
  23376. bSphereRadiusFactor?: number;
  23377. });
  23378. /**
  23379. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23380. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23381. * @returns the created mesh
  23382. */
  23383. buildMesh(): Mesh;
  23384. /**
  23385. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23386. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23387. * Thus the particles generated from `digest()` have their property `position` set yet.
  23388. * @param mesh ( Mesh ) is the mesh to be digested
  23389. * @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
  23390. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23391. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23392. * @returns the current SPS
  23393. */
  23394. digest(mesh: Mesh, options?: {
  23395. facetNb?: number;
  23396. number?: number;
  23397. delta?: number;
  23398. }): SolidParticleSystem;
  23399. private _unrotateFixedNormals;
  23400. private _resetCopy;
  23401. private _meshBuilder;
  23402. private _posToShape;
  23403. private _uvsToShapeUV;
  23404. private _addParticle;
  23405. /**
  23406. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23407. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23408. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23409. * @param nb (positive integer) the number of particles to be created from this model
  23410. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23411. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23412. * @returns the number of shapes in the system
  23413. */
  23414. addShape(mesh: Mesh, nb: number, options?: {
  23415. positionFunction?: any;
  23416. vertexFunction?: any;
  23417. }): number;
  23418. private _rebuildParticle;
  23419. /**
  23420. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23421. * @returns the SPS.
  23422. */
  23423. rebuildMesh(): SolidParticleSystem;
  23424. /**
  23425. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23426. * This method calls `updateParticle()` for each particle of the SPS.
  23427. * For an animated SPS, it is usually called within the render loop.
  23428. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23429. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23430. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23431. * @returns the SPS.
  23432. */
  23433. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23434. /**
  23435. * Disposes the SPS.
  23436. */
  23437. dispose(): void;
  23438. /**
  23439. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23440. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23441. * @returns the SPS.
  23442. */
  23443. refreshVisibleSize(): SolidParticleSystem;
  23444. /**
  23445. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23446. * @param size the size (float) of the visibility box
  23447. * note : this doesn't lock the SPS mesh bounding box.
  23448. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23449. */
  23450. setVisibilityBox(size: number): void;
  23451. /**
  23452. * Gets whether the SPS as always visible or not
  23453. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23454. */
  23455. /**
  23456. * Sets the SPS as always visible or not
  23457. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23458. */
  23459. isAlwaysVisible: boolean;
  23460. /**
  23461. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23462. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23463. */
  23464. /**
  23465. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23466. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23467. */
  23468. isVisibilityBoxLocked: boolean;
  23469. /**
  23470. * Tells to `setParticles()` to compute the particle rotations or not.
  23471. * Default value : true. The SPS is faster when it's set to false.
  23472. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23473. */
  23474. /**
  23475. * Gets if `setParticles()` computes the particle rotations or not.
  23476. * Default value : true. The SPS is faster when it's set to false.
  23477. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23478. */
  23479. computeParticleRotation: boolean;
  23480. /**
  23481. * Tells to `setParticles()` to compute the particle colors or not.
  23482. * Default value : true. The SPS is faster when it's set to false.
  23483. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23484. */
  23485. /**
  23486. * Gets if `setParticles()` computes the particle colors or not.
  23487. * Default value : true. The SPS is faster when it's set to false.
  23488. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23489. */
  23490. computeParticleColor: boolean;
  23491. /**
  23492. * Gets if `setParticles()` computes the particle textures or not.
  23493. * Default value : true. The SPS is faster when it's set to false.
  23494. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23495. */
  23496. computeParticleTexture: boolean;
  23497. /**
  23498. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23499. * Default value : false. The SPS is faster when it's set to false.
  23500. * Note : the particle custom vertex positions aren't stored values.
  23501. */
  23502. /**
  23503. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23504. * Default value : false. The SPS is faster when it's set to false.
  23505. * Note : the particle custom vertex positions aren't stored values.
  23506. */
  23507. computeParticleVertex: boolean;
  23508. /**
  23509. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23510. */
  23511. /**
  23512. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23513. */
  23514. computeBoundingBox: boolean;
  23515. /**
  23516. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23517. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23518. * Default : `true`
  23519. */
  23520. /**
  23521. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23522. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23523. * Default : `true`
  23524. */
  23525. depthSortParticles: boolean;
  23526. /**
  23527. * This function does nothing. It may be overwritten to set all the particle first values.
  23528. * The SPS doesn't call this function, you may have to call it by your own.
  23529. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23530. */
  23531. initParticles(): void;
  23532. /**
  23533. * This function does nothing. It may be overwritten to recycle a particle.
  23534. * The SPS doesn't call this function, you may have to call it by your own.
  23535. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23536. * @param particle The particle to recycle
  23537. * @returns the recycled particle
  23538. */
  23539. recycleParticle(particle: SolidParticle): SolidParticle;
  23540. /**
  23541. * Updates a particle : this function should be overwritten by the user.
  23542. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23544. * @example : just set a particle position or velocity and recycle conditions
  23545. * @param particle The particle to update
  23546. * @returns the updated particle
  23547. */
  23548. updateParticle(particle: SolidParticle): SolidParticle;
  23549. /**
  23550. * Updates a vertex of a particle : it can be overwritten by the user.
  23551. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23552. * @param particle the current particle
  23553. * @param vertex the current index of the current particle
  23554. * @param pt the index of the current vertex in the particle shape
  23555. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23556. * @example : just set a vertex particle position
  23557. * @returns the updated vertex
  23558. */
  23559. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23560. /**
  23561. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23562. * This does nothing and may be overwritten by the user.
  23563. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23564. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23565. * @param update the boolean update value actually passed to setParticles()
  23566. */
  23567. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23568. /**
  23569. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23570. * This will be passed three parameters.
  23571. * This does nothing and may be overwritten by the user.
  23572. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23573. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23574. * @param update the boolean update value actually passed to setParticles()
  23575. */
  23576. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23577. }
  23578. }
  23579. declare module "babylonjs/Particles/solidParticle" {
  23580. import { Nullable } from "babylonjs/types";
  23581. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23582. import { Mesh } from "babylonjs/Meshes/mesh";
  23583. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23584. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23585. /**
  23586. * Represents one particle of a solid particle system.
  23587. */
  23588. export class SolidParticle {
  23589. /**
  23590. * particle global index
  23591. */
  23592. idx: number;
  23593. /**
  23594. * The color of the particle
  23595. */
  23596. color: Nullable<Color4>;
  23597. /**
  23598. * The world space position of the particle.
  23599. */
  23600. position: Vector3;
  23601. /**
  23602. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23603. */
  23604. rotation: Vector3;
  23605. /**
  23606. * The world space rotation quaternion of the particle.
  23607. */
  23608. rotationQuaternion: Nullable<Quaternion>;
  23609. /**
  23610. * The scaling of the particle.
  23611. */
  23612. scaling: Vector3;
  23613. /**
  23614. * The uvs of the particle.
  23615. */
  23616. uvs: Vector4;
  23617. /**
  23618. * The current speed of the particle.
  23619. */
  23620. velocity: Vector3;
  23621. /**
  23622. * The pivot point in the particle local space.
  23623. */
  23624. pivot: Vector3;
  23625. /**
  23626. * Must the particle be translated from its pivot point in its local space ?
  23627. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23628. * Default : false
  23629. */
  23630. translateFromPivot: boolean;
  23631. /**
  23632. * Is the particle active or not ?
  23633. */
  23634. alive: boolean;
  23635. /**
  23636. * Is the particle visible or not ?
  23637. */
  23638. isVisible: boolean;
  23639. /**
  23640. * Index of this particle in the global "positions" array (Internal use)
  23641. * @hidden
  23642. */
  23643. _pos: number;
  23644. /**
  23645. * @hidden Index of this particle in the global "indices" array (Internal use)
  23646. */
  23647. _ind: number;
  23648. /**
  23649. * @hidden ModelShape of this particle (Internal use)
  23650. */
  23651. _model: ModelShape;
  23652. /**
  23653. * ModelShape id of this particle
  23654. */
  23655. shapeId: number;
  23656. /**
  23657. * Index of the particle in its shape id (Internal use)
  23658. */
  23659. idxInShape: number;
  23660. /**
  23661. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23662. */
  23663. _modelBoundingInfo: BoundingInfo;
  23664. /**
  23665. * @hidden Particle BoundingInfo object (Internal use)
  23666. */
  23667. _boundingInfo: BoundingInfo;
  23668. /**
  23669. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23670. */
  23671. _sps: SolidParticleSystem;
  23672. /**
  23673. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23674. */
  23675. _stillInvisible: boolean;
  23676. /**
  23677. * @hidden Last computed particle rotation matrix
  23678. */
  23679. _rotationMatrix: number[];
  23680. /**
  23681. * Parent particle Id, if any.
  23682. * Default null.
  23683. */
  23684. parentId: Nullable<number>;
  23685. /**
  23686. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23687. * The possible values are :
  23688. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23689. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23690. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23691. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23692. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23693. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23694. * */
  23695. cullingStrategy: number;
  23696. /**
  23697. * @hidden Internal global position in the SPS.
  23698. */
  23699. _globalPosition: Vector3;
  23700. /**
  23701. * Creates a Solid Particle object.
  23702. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23703. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23704. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23705. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23706. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23707. * @param shapeId (integer) is the model shape identifier in the SPS.
  23708. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23709. * @param sps defines the sps it is associated to
  23710. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23711. */
  23712. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23713. /**
  23714. * Legacy support, changed scale to scaling
  23715. */
  23716. /**
  23717. * Legacy support, changed scale to scaling
  23718. */
  23719. scale: Vector3;
  23720. /**
  23721. * Legacy support, changed quaternion to rotationQuaternion
  23722. */
  23723. /**
  23724. * Legacy support, changed quaternion to rotationQuaternion
  23725. */
  23726. quaternion: Nullable<Quaternion>;
  23727. /**
  23728. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23729. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23730. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23731. * @returns true if it intersects
  23732. */
  23733. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23734. /**
  23735. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23736. * A particle is in the frustum if its bounding box intersects the frustum
  23737. * @param frustumPlanes defines the frustum to test
  23738. * @returns true if the particle is in the frustum planes
  23739. */
  23740. isInFrustum(frustumPlanes: Plane[]): boolean;
  23741. /**
  23742. * get the rotation matrix of the particle
  23743. * @hidden
  23744. */
  23745. getRotationMatrix(m: Matrix): void;
  23746. }
  23747. /**
  23748. * Represents the shape of the model used by one particle of a solid particle system.
  23749. * SPS internal tool, don't use it manually.
  23750. */
  23751. export class ModelShape {
  23752. /**
  23753. * The shape id
  23754. * @hidden
  23755. */
  23756. shapeID: number;
  23757. /**
  23758. * flat array of model positions (internal use)
  23759. * @hidden
  23760. */
  23761. _shape: Vector3[];
  23762. /**
  23763. * flat array of model UVs (internal use)
  23764. * @hidden
  23765. */
  23766. _shapeUV: number[];
  23767. /**
  23768. * length of the shape in the model indices array (internal use)
  23769. * @hidden
  23770. */
  23771. _indicesLength: number;
  23772. /**
  23773. * Custom position function (internal use)
  23774. * @hidden
  23775. */
  23776. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23777. /**
  23778. * Custom vertex function (internal use)
  23779. * @hidden
  23780. */
  23781. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23782. /**
  23783. * 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.
  23784. * SPS internal tool, don't use it manually.
  23785. * @hidden
  23786. */
  23787. 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>);
  23788. }
  23789. /**
  23790. * Represents a Depth Sorted Particle in the solid particle system.
  23791. */
  23792. export class DepthSortedParticle {
  23793. /**
  23794. * Index of the particle in the "indices" array
  23795. */
  23796. ind: number;
  23797. /**
  23798. * Length of the particle shape in the "indices" array
  23799. */
  23800. indicesLength: number;
  23801. /**
  23802. * Squared distance from the particle to the camera
  23803. */
  23804. sqDistance: number;
  23805. }
  23806. }
  23807. declare module "babylonjs/Meshes/abstractMesh" {
  23808. import { Observable } from "babylonjs/Misc/observable";
  23809. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23810. import { Camera } from "babylonjs/Cameras/camera";
  23811. import { Scene, IDisposable } from "babylonjs/scene";
  23812. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23813. import { Node } from "babylonjs/node";
  23814. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23815. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23817. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23818. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23819. import { Material } from "babylonjs/Materials/material";
  23820. import { Light } from "babylonjs/Lights/light";
  23821. import { Skeleton } from "babylonjs/Bones/skeleton";
  23822. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23823. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23824. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23825. import { Ray } from "babylonjs/Culling/ray";
  23826. import { Collider } from "babylonjs/Collisions/collider";
  23827. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23828. /**
  23829. * Class used to store all common mesh properties
  23830. */
  23831. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23832. /** No occlusion */
  23833. static OCCLUSION_TYPE_NONE: number;
  23834. /** Occlusion set to optimisitic */
  23835. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23836. /** Occlusion set to strict */
  23837. static OCCLUSION_TYPE_STRICT: number;
  23838. /** Use an accurante occlusion algorithm */
  23839. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23840. /** Use a conservative occlusion algorithm */
  23841. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23842. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23843. * Test order :
  23844. * Is the bounding sphere outside the frustum ?
  23845. * If not, are the bounding box vertices outside the frustum ?
  23846. * It not, then the cullable object is in the frustum.
  23847. */
  23848. static readonly CULLINGSTRATEGY_STANDARD: number;
  23849. /** Culling strategy : Bounding Sphere Only.
  23850. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23851. * It's also less accurate than the standard because some not visible objects can still be selected.
  23852. * Test : is the bounding sphere outside the frustum ?
  23853. * If not, then the cullable object is in the frustum.
  23854. */
  23855. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23856. /** Culling strategy : Optimistic Inclusion.
  23857. * This in an inclusion test first, then the standard exclusion test.
  23858. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23859. * 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.
  23860. * Anyway, it's as accurate as the standard strategy.
  23861. * Test :
  23862. * Is the cullable object bounding sphere center in the frustum ?
  23863. * If not, apply the default culling strategy.
  23864. */
  23865. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23866. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23867. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23868. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23869. * 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.
  23870. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23871. * Test :
  23872. * Is the cullable object bounding sphere center in the frustum ?
  23873. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23874. */
  23875. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23876. /**
  23877. * No billboard
  23878. */
  23879. static readonly BILLBOARDMODE_NONE: number;
  23880. /** Billboard on X axis */
  23881. static readonly BILLBOARDMODE_X: number;
  23882. /** Billboard on Y axis */
  23883. static readonly BILLBOARDMODE_Y: number;
  23884. /** Billboard on Z axis */
  23885. static readonly BILLBOARDMODE_Z: number;
  23886. /** Billboard on all axes */
  23887. static readonly BILLBOARDMODE_ALL: number;
  23888. private _facetData;
  23889. /**
  23890. * The culling strategy to use to check whether the mesh must be rendered or not.
  23891. * This value can be changed at any time and will be used on the next render mesh selection.
  23892. * The possible values are :
  23893. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23894. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23895. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23896. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23897. * Please read each static variable documentation to get details about the culling process.
  23898. * */
  23899. cullingStrategy: number;
  23900. /**
  23901. * Gets the number of facets in the mesh
  23902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23903. */
  23904. readonly facetNb: number;
  23905. /**
  23906. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23908. */
  23909. partitioningSubdivisions: number;
  23910. /**
  23911. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23912. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23914. */
  23915. partitioningBBoxRatio: number;
  23916. /**
  23917. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23918. * Works only for updatable meshes.
  23919. * Doesn't work with multi-materials
  23920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23921. */
  23922. mustDepthSortFacets: boolean;
  23923. /**
  23924. * The location (Vector3) where the facet depth sort must be computed from.
  23925. * By default, the active camera position.
  23926. * Used only when facet depth sort is enabled
  23927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23928. */
  23929. facetDepthSortFrom: Vector3;
  23930. /**
  23931. * gets a boolean indicating if facetData is enabled
  23932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23933. */
  23934. readonly isFacetDataEnabled: boolean;
  23935. /** @hidden */
  23936. _updateNonUniformScalingState(value: boolean): boolean;
  23937. /**
  23938. * An event triggered when this mesh collides with another one
  23939. */
  23940. onCollideObservable: Observable<AbstractMesh>;
  23941. private _onCollideObserver;
  23942. /** Set a function to call when this mesh collides with another one */
  23943. onCollide: () => void;
  23944. /**
  23945. * An event triggered when the collision's position changes
  23946. */
  23947. onCollisionPositionChangeObservable: Observable<Vector3>;
  23948. private _onCollisionPositionChangeObserver;
  23949. /** Set a function to call when the collision's position changes */
  23950. onCollisionPositionChange: () => void;
  23951. /**
  23952. * An event triggered when material is changed
  23953. */
  23954. onMaterialChangedObservable: Observable<AbstractMesh>;
  23955. /**
  23956. * Gets or sets the orientation for POV movement & rotation
  23957. */
  23958. definedFacingForward: boolean;
  23959. /** @hidden */
  23960. _occlusionQuery: Nullable<WebGLQuery>;
  23961. private _visibility;
  23962. /**
  23963. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23964. */
  23965. /**
  23966. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23967. */
  23968. visibility: number;
  23969. /** Gets or sets the alpha index used to sort transparent meshes
  23970. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23971. */
  23972. alphaIndex: number;
  23973. /**
  23974. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23975. */
  23976. isVisible: boolean;
  23977. /**
  23978. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23979. */
  23980. isPickable: boolean;
  23981. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23982. showSubMeshesBoundingBox: boolean;
  23983. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23984. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23985. */
  23986. isBlocker: boolean;
  23987. /**
  23988. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23989. */
  23990. enablePointerMoveEvents: boolean;
  23991. /**
  23992. * Specifies the rendering group id for this mesh (0 by default)
  23993. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23994. */
  23995. renderingGroupId: number;
  23996. private _material;
  23997. /** Gets or sets current material */
  23998. material: Nullable<Material>;
  23999. private _receiveShadows;
  24000. /**
  24001. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24002. * @see http://doc.babylonjs.com/babylon101/shadows
  24003. */
  24004. receiveShadows: boolean;
  24005. /** Defines color to use when rendering outline */
  24006. outlineColor: Color3;
  24007. /** Define width to use when rendering outline */
  24008. outlineWidth: number;
  24009. /** Defines color to use when rendering overlay */
  24010. overlayColor: Color3;
  24011. /** Defines alpha to use when rendering overlay */
  24012. overlayAlpha: number;
  24013. private _hasVertexAlpha;
  24014. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24015. hasVertexAlpha: boolean;
  24016. private _useVertexColors;
  24017. /** 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) */
  24018. useVertexColors: boolean;
  24019. private _computeBonesUsingShaders;
  24020. /**
  24021. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24022. */
  24023. computeBonesUsingShaders: boolean;
  24024. private _numBoneInfluencers;
  24025. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24026. numBoneInfluencers: number;
  24027. private _applyFog;
  24028. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24029. applyFog: boolean;
  24030. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24031. useOctreeForRenderingSelection: boolean;
  24032. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24033. useOctreeForPicking: boolean;
  24034. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24035. useOctreeForCollisions: boolean;
  24036. private _layerMask;
  24037. /**
  24038. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24039. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24040. */
  24041. layerMask: number;
  24042. /**
  24043. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24044. */
  24045. alwaysSelectAsActiveMesh: boolean;
  24046. /**
  24047. * Gets or sets the current action manager
  24048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24049. */
  24050. actionManager: Nullable<AbstractActionManager>;
  24051. private _checkCollisions;
  24052. private _collisionMask;
  24053. private _collisionGroup;
  24054. /**
  24055. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24057. */
  24058. ellipsoid: Vector3;
  24059. /**
  24060. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24062. */
  24063. ellipsoidOffset: Vector3;
  24064. private _collider;
  24065. private _oldPositionForCollisions;
  24066. private _diffPositionForCollisions;
  24067. /**
  24068. * Gets or sets a collision mask used to mask collisions (default is -1).
  24069. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24070. */
  24071. collisionMask: number;
  24072. /**
  24073. * Gets or sets the current collision group mask (-1 by default).
  24074. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24075. */
  24076. collisionGroup: number;
  24077. /**
  24078. * Defines edge width used when edgesRenderer is enabled
  24079. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24080. */
  24081. edgesWidth: number;
  24082. /**
  24083. * Defines edge color used when edgesRenderer is enabled
  24084. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24085. */
  24086. edgesColor: Color4;
  24087. /** @hidden */
  24088. _edgesRenderer: Nullable<IEdgesRenderer>;
  24089. /** @hidden */
  24090. _masterMesh: Nullable<AbstractMesh>;
  24091. /** @hidden */
  24092. _boundingInfo: Nullable<BoundingInfo>;
  24093. /** @hidden */
  24094. _renderId: number;
  24095. /**
  24096. * Gets or sets the list of subMeshes
  24097. * @see http://doc.babylonjs.com/how_to/multi_materials
  24098. */
  24099. subMeshes: SubMesh[];
  24100. /** @hidden */
  24101. _intersectionsInProgress: AbstractMesh[];
  24102. /** @hidden */
  24103. _unIndexed: boolean;
  24104. /** @hidden */
  24105. _lightSources: Light[];
  24106. /** @hidden */
  24107. readonly _positions: Nullable<Vector3[]>;
  24108. /** @hidden */
  24109. _waitingActions: any;
  24110. /** @hidden */
  24111. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24112. private _skeleton;
  24113. /** @hidden */
  24114. _bonesTransformMatrices: Nullable<Float32Array>;
  24115. /**
  24116. * Gets or sets a skeleton to apply skining transformations
  24117. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24118. */
  24119. skeleton: Nullable<Skeleton>;
  24120. /**
  24121. * An event triggered when the mesh is rebuilt.
  24122. */
  24123. onRebuildObservable: Observable<AbstractMesh>;
  24124. /**
  24125. * Creates a new AbstractMesh
  24126. * @param name defines the name of the mesh
  24127. * @param scene defines the hosting scene
  24128. */
  24129. constructor(name: string, scene?: Nullable<Scene>);
  24130. /**
  24131. * Returns the string "AbstractMesh"
  24132. * @returns "AbstractMesh"
  24133. */
  24134. getClassName(): string;
  24135. /**
  24136. * Gets a string representation of the current mesh
  24137. * @param fullDetails defines a boolean indicating if full details must be included
  24138. * @returns a string representation of the current mesh
  24139. */
  24140. toString(fullDetails?: boolean): string;
  24141. /** @hidden */
  24142. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24143. /** @hidden */
  24144. _rebuild(): void;
  24145. /** @hidden */
  24146. _resyncLightSources(): void;
  24147. /** @hidden */
  24148. _resyncLighSource(light: Light): void;
  24149. /** @hidden */
  24150. _unBindEffect(): void;
  24151. /** @hidden */
  24152. _removeLightSource(light: Light): void;
  24153. private _markSubMeshesAsDirty;
  24154. /** @hidden */
  24155. _markSubMeshesAsLightDirty(): void;
  24156. /** @hidden */
  24157. _markSubMeshesAsAttributesDirty(): void;
  24158. /** @hidden */
  24159. _markSubMeshesAsMiscDirty(): void;
  24160. /**
  24161. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24162. */
  24163. scaling: Vector3;
  24164. /**
  24165. * Returns true if the mesh is blocked. Implemented by child classes
  24166. */
  24167. readonly isBlocked: boolean;
  24168. /**
  24169. * Returns the mesh itself by default. Implemented by child classes
  24170. * @param camera defines the camera to use to pick the right LOD level
  24171. * @returns the currentAbstractMesh
  24172. */
  24173. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24174. /**
  24175. * Returns 0 by default. Implemented by child classes
  24176. * @returns an integer
  24177. */
  24178. getTotalVertices(): number;
  24179. /**
  24180. * Returns a positive integer : the total number of indices in this mesh geometry.
  24181. * @returns the numner of indices or zero if the mesh has no geometry.
  24182. */
  24183. getTotalIndices(): number;
  24184. /**
  24185. * Returns null by default. Implemented by child classes
  24186. * @returns null
  24187. */
  24188. getIndices(): Nullable<IndicesArray>;
  24189. /**
  24190. * Returns the array of the requested vertex data kind. Implemented by child classes
  24191. * @param kind defines the vertex data kind to use
  24192. * @returns null
  24193. */
  24194. getVerticesData(kind: string): Nullable<FloatArray>;
  24195. /**
  24196. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24197. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24198. * Note that a new underlying VertexBuffer object is created each call.
  24199. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24200. * @param kind defines vertex data kind:
  24201. * * VertexBuffer.PositionKind
  24202. * * VertexBuffer.UVKind
  24203. * * VertexBuffer.UV2Kind
  24204. * * VertexBuffer.UV3Kind
  24205. * * VertexBuffer.UV4Kind
  24206. * * VertexBuffer.UV5Kind
  24207. * * VertexBuffer.UV6Kind
  24208. * * VertexBuffer.ColorKind
  24209. * * VertexBuffer.MatricesIndicesKind
  24210. * * VertexBuffer.MatricesIndicesExtraKind
  24211. * * VertexBuffer.MatricesWeightsKind
  24212. * * VertexBuffer.MatricesWeightsExtraKind
  24213. * @param data defines the data source
  24214. * @param updatable defines if the data must be flagged as updatable (or static)
  24215. * @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
  24216. * @returns the current mesh
  24217. */
  24218. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24219. /**
  24220. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24221. * If the mesh has no geometry, it is simply returned as it is.
  24222. * @param kind defines vertex data kind:
  24223. * * VertexBuffer.PositionKind
  24224. * * VertexBuffer.UVKind
  24225. * * VertexBuffer.UV2Kind
  24226. * * VertexBuffer.UV3Kind
  24227. * * VertexBuffer.UV4Kind
  24228. * * VertexBuffer.UV5Kind
  24229. * * VertexBuffer.UV6Kind
  24230. * * VertexBuffer.ColorKind
  24231. * * VertexBuffer.MatricesIndicesKind
  24232. * * VertexBuffer.MatricesIndicesExtraKind
  24233. * * VertexBuffer.MatricesWeightsKind
  24234. * * VertexBuffer.MatricesWeightsExtraKind
  24235. * @param data defines the data source
  24236. * @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
  24237. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24238. * @returns the current mesh
  24239. */
  24240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24241. /**
  24242. * Sets the mesh indices,
  24243. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24244. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24245. * @param totalVertices Defines the total number of vertices
  24246. * @returns the current mesh
  24247. */
  24248. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24249. /**
  24250. * Gets a boolean indicating if specific vertex data is present
  24251. * @param kind defines the vertex data kind to use
  24252. * @returns true is data kind is present
  24253. */
  24254. isVerticesDataPresent(kind: string): boolean;
  24255. /**
  24256. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24257. * @returns a BoundingInfo
  24258. */
  24259. getBoundingInfo(): BoundingInfo;
  24260. /**
  24261. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24262. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24263. * @returns the current mesh
  24264. */
  24265. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24266. /**
  24267. * Overwrite the current bounding info
  24268. * @param boundingInfo defines the new bounding info
  24269. * @returns the current mesh
  24270. */
  24271. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24272. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24273. readonly useBones: boolean;
  24274. /** @hidden */
  24275. _preActivate(): void;
  24276. /** @hidden */
  24277. _preActivateForIntermediateRendering(renderId: number): void;
  24278. /** @hidden */
  24279. _activate(renderId: number): void;
  24280. /**
  24281. * Gets the current world matrix
  24282. * @returns a Matrix
  24283. */
  24284. getWorldMatrix(): Matrix;
  24285. /** @hidden */
  24286. _getWorldMatrixDeterminant(): number;
  24287. /**
  24288. * Perform relative position change from the point of view of behind the front of the mesh.
  24289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24290. * Supports definition of mesh facing forward or backward
  24291. * @param amountRight defines the distance on the right axis
  24292. * @param amountUp defines the distance on the up axis
  24293. * @param amountForward defines the distance on the forward axis
  24294. * @returns the current mesh
  24295. */
  24296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24297. /**
  24298. * Calculate relative position change from the point of view of behind the front of the mesh.
  24299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24300. * Supports definition of mesh facing forward or backward
  24301. * @param amountRight defines the distance on the right axis
  24302. * @param amountUp defines the distance on the up axis
  24303. * @param amountForward defines the distance on the forward axis
  24304. * @returns the new displacement vector
  24305. */
  24306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24307. /**
  24308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24309. * Supports definition of mesh facing forward or backward
  24310. * @param flipBack defines the flip
  24311. * @param twirlClockwise defines the twirl
  24312. * @param tiltRight defines the tilt
  24313. * @returns the current mesh
  24314. */
  24315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24316. /**
  24317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24318. * Supports definition of mesh facing forward or backward.
  24319. * @param flipBack defines the flip
  24320. * @param twirlClockwise defines the twirl
  24321. * @param tiltRight defines the tilt
  24322. * @returns the new rotation vector
  24323. */
  24324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24325. /**
  24326. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24327. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24328. * @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
  24329. * @returns the new bounding vectors
  24330. */
  24331. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24332. min: Vector3;
  24333. max: Vector3;
  24334. };
  24335. /**
  24336. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24337. * This means the mesh underlying bounding box and sphere are recomputed.
  24338. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24339. * @returns the current mesh
  24340. */
  24341. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24342. /** @hidden */
  24343. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24344. /** @hidden */
  24345. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24346. /** @hidden */
  24347. _updateBoundingInfo(): AbstractMesh;
  24348. /** @hidden */
  24349. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24350. /** @hidden */
  24351. protected _afterComputeWorldMatrix(): void;
  24352. /**
  24353. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24354. * A mesh is in the frustum if its bounding box intersects the frustum
  24355. * @param frustumPlanes defines the frustum to test
  24356. * @returns true if the mesh is in the frustum planes
  24357. */
  24358. isInFrustum(frustumPlanes: Plane[]): boolean;
  24359. /**
  24360. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24361. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24362. * @param frustumPlanes defines the frustum to test
  24363. * @returns true if the mesh is completely in the frustum planes
  24364. */
  24365. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24366. /**
  24367. * True if the mesh intersects another mesh or a SolidParticle object
  24368. * @param mesh defines a target mesh or SolidParticle to test
  24369. * @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)
  24370. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24371. * @returns true if there is an intersection
  24372. */
  24373. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24374. /**
  24375. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24376. * @param point defines the point to test
  24377. * @returns true if there is an intersection
  24378. */
  24379. intersectsPoint(point: Vector3): boolean;
  24380. /**
  24381. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24382. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24383. */
  24384. checkCollisions: boolean;
  24385. /**
  24386. * Gets Collider object used to compute collisions (not physics)
  24387. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24388. */
  24389. readonly collider: Collider;
  24390. /**
  24391. * Move the mesh using collision engine
  24392. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24393. * @param displacement defines the requested displacement vector
  24394. * @returns the current mesh
  24395. */
  24396. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24397. private _onCollisionPositionChange;
  24398. /** @hidden */
  24399. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24400. /** @hidden */
  24401. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24402. /** @hidden */
  24403. _checkCollision(collider: Collider): AbstractMesh;
  24404. /** @hidden */
  24405. _generatePointsArray(): boolean;
  24406. /**
  24407. * Checks if the passed Ray intersects with the mesh
  24408. * @param ray defines the ray to use
  24409. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24411. * @returns the picking info
  24412. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24413. */
  24414. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24415. /**
  24416. * Clones the current mesh
  24417. * @param name defines the mesh name
  24418. * @param newParent defines the new mesh parent
  24419. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24420. * @returns the new mesh
  24421. */
  24422. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24423. /**
  24424. * Disposes all the submeshes of the current meshnp
  24425. * @returns the current mesh
  24426. */
  24427. releaseSubMeshes(): AbstractMesh;
  24428. /**
  24429. * Releases resources associated with this abstract mesh.
  24430. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24431. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24432. */
  24433. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24434. /**
  24435. * Adds the passed mesh as a child to the current mesh
  24436. * @param mesh defines the child mesh
  24437. * @returns the current mesh
  24438. */
  24439. addChild(mesh: AbstractMesh): AbstractMesh;
  24440. /**
  24441. * Removes the passed mesh from the current mesh children list
  24442. * @param mesh defines the child mesh
  24443. * @returns the current mesh
  24444. */
  24445. removeChild(mesh: AbstractMesh): AbstractMesh;
  24446. /** @hidden */
  24447. private _initFacetData;
  24448. /**
  24449. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24450. * This method can be called within the render loop.
  24451. * 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
  24452. * @returns the current mesh
  24453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24454. */
  24455. updateFacetData(): AbstractMesh;
  24456. /**
  24457. * Returns the facetLocalNormals array.
  24458. * The normals are expressed in the mesh local spac
  24459. * @returns an array of Vector3
  24460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24461. */
  24462. getFacetLocalNormals(): Vector3[];
  24463. /**
  24464. * Returns the facetLocalPositions array.
  24465. * The facet positions are expressed in the mesh local space
  24466. * @returns an array of Vector3
  24467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24468. */
  24469. getFacetLocalPositions(): Vector3[];
  24470. /**
  24471. * Returns the facetLocalPartioning array
  24472. * @returns an array of array of numbers
  24473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24474. */
  24475. getFacetLocalPartitioning(): number[][];
  24476. /**
  24477. * Returns the i-th facet position in the world system.
  24478. * This method allocates a new Vector3 per call
  24479. * @param i defines the facet index
  24480. * @returns a new Vector3
  24481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24482. */
  24483. getFacetPosition(i: number): Vector3;
  24484. /**
  24485. * Sets the reference Vector3 with the i-th facet position in the world system
  24486. * @param i defines the facet index
  24487. * @param ref defines the target vector
  24488. * @returns the current mesh
  24489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24490. */
  24491. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24492. /**
  24493. * Returns the i-th facet normal in the world system.
  24494. * This method allocates a new Vector3 per call
  24495. * @param i defines the facet index
  24496. * @returns a new Vector3
  24497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24498. */
  24499. getFacetNormal(i: number): Vector3;
  24500. /**
  24501. * Sets the reference Vector3 with the i-th facet normal in the world system
  24502. * @param i defines the facet index
  24503. * @param ref defines the target vector
  24504. * @returns the current mesh
  24505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24506. */
  24507. getFacetNormalToRef(i: number, ref: Vector3): this;
  24508. /**
  24509. * 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)
  24510. * @param x defines x coordinate
  24511. * @param y defines y coordinate
  24512. * @param z defines z coordinate
  24513. * @returns the array of facet indexes
  24514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24515. */
  24516. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24517. /**
  24518. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24519. * @param projected sets as the (x,y,z) world projection on the facet
  24520. * @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
  24521. * @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
  24522. * @param x defines x coordinate
  24523. * @param y defines y coordinate
  24524. * @param z defines z coordinate
  24525. * @returns the face index if found (or null instead)
  24526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24527. */
  24528. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24529. /**
  24530. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24531. * @param projected sets as the (x,y,z) local projection on the facet
  24532. * @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
  24533. * @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
  24534. * @param x defines x coordinate
  24535. * @param y defines y coordinate
  24536. * @param z defines z coordinate
  24537. * @returns the face index if found (or null instead)
  24538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24539. */
  24540. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24541. /**
  24542. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24543. * @returns the parameters
  24544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24545. */
  24546. getFacetDataParameters(): any;
  24547. /**
  24548. * Disables the feature FacetData and frees the related memory
  24549. * @returns the current mesh
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24551. */
  24552. disableFacetData(): AbstractMesh;
  24553. /**
  24554. * Updates the AbstractMesh indices array
  24555. * @param indices defines the data source
  24556. * @returns the current mesh
  24557. */
  24558. updateIndices(indices: IndicesArray): AbstractMesh;
  24559. /**
  24560. * Creates new normals data for the mesh
  24561. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24562. * @returns the current mesh
  24563. */
  24564. createNormals(updatable: boolean): AbstractMesh;
  24565. /**
  24566. * Align the mesh with a normal
  24567. * @param normal defines the normal to use
  24568. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24569. * @returns the current mesh
  24570. */
  24571. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24572. /** @hidden */
  24573. _checkOcclusionQuery(): boolean;
  24574. }
  24575. }
  24576. declare module "babylonjs/Actions/actionEvent" {
  24577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24578. import { Nullable } from "babylonjs/types";
  24579. import { Sprite } from "babylonjs/Sprites/sprite";
  24580. import { Scene } from "babylonjs/scene";
  24581. import { Vector2 } from "babylonjs/Maths/math";
  24582. /**
  24583. * Interface used to define ActionEvent
  24584. */
  24585. export interface IActionEvent {
  24586. /** The mesh or sprite that triggered the action */
  24587. source: any;
  24588. /** The X mouse cursor position at the time of the event */
  24589. pointerX: number;
  24590. /** The Y mouse cursor position at the time of the event */
  24591. pointerY: number;
  24592. /** The mesh that is currently pointed at (can be null) */
  24593. meshUnderPointer: Nullable<AbstractMesh>;
  24594. /** the original (browser) event that triggered the ActionEvent */
  24595. sourceEvent?: any;
  24596. /** additional data for the event */
  24597. additionalData?: any;
  24598. }
  24599. /**
  24600. * ActionEvent is the event being sent when an action is triggered.
  24601. */
  24602. export class ActionEvent implements IActionEvent {
  24603. /** The mesh or sprite that triggered the action */
  24604. source: any;
  24605. /** The X mouse cursor position at the time of the event */
  24606. pointerX: number;
  24607. /** The Y mouse cursor position at the time of the event */
  24608. pointerY: number;
  24609. /** The mesh that is currently pointed at (can be null) */
  24610. meshUnderPointer: Nullable<AbstractMesh>;
  24611. /** the original (browser) event that triggered the ActionEvent */
  24612. sourceEvent?: any;
  24613. /** additional data for the event */
  24614. additionalData?: any;
  24615. /**
  24616. * Creates a new ActionEvent
  24617. * @param source The mesh or sprite that triggered the action
  24618. * @param pointerX The X mouse cursor position at the time of the event
  24619. * @param pointerY The Y mouse cursor position at the time of the event
  24620. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24621. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24622. * @param additionalData additional data for the event
  24623. */
  24624. constructor(
  24625. /** The mesh or sprite that triggered the action */
  24626. source: any,
  24627. /** The X mouse cursor position at the time of the event */
  24628. pointerX: number,
  24629. /** The Y mouse cursor position at the time of the event */
  24630. pointerY: number,
  24631. /** The mesh that is currently pointed at (can be null) */
  24632. meshUnderPointer: Nullable<AbstractMesh>,
  24633. /** the original (browser) event that triggered the ActionEvent */
  24634. sourceEvent?: any,
  24635. /** additional data for the event */
  24636. additionalData?: any);
  24637. /**
  24638. * Helper function to auto-create an ActionEvent from a source mesh.
  24639. * @param source The source mesh that triggered the event
  24640. * @param evt The original (browser) event
  24641. * @param additionalData additional data for the event
  24642. * @returns the new ActionEvent
  24643. */
  24644. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24645. /**
  24646. * Helper function to auto-create an ActionEvent from a source sprite
  24647. * @param source The source sprite that triggered the event
  24648. * @param scene Scene associated with the sprite
  24649. * @param evt The original (browser) event
  24650. * @param additionalData additional data for the event
  24651. * @returns the new ActionEvent
  24652. */
  24653. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24654. /**
  24655. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24656. * @param scene the scene where the event occurred
  24657. * @param evt The original (browser) event
  24658. * @returns the new ActionEvent
  24659. */
  24660. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24661. /**
  24662. * Helper function to auto-create an ActionEvent from a primitive
  24663. * @param prim defines the target primitive
  24664. * @param pointerPos defines the pointer position
  24665. * @param evt The original (browser) event
  24666. * @param additionalData additional data for the event
  24667. * @returns the new ActionEvent
  24668. */
  24669. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24670. }
  24671. }
  24672. declare module "babylonjs/Actions/abstractActionManager" {
  24673. import { IDisposable } from "babylonjs/scene";
  24674. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24675. import { IAction } from "babylonjs/Actions/action";
  24676. import { Nullable } from "babylonjs/types";
  24677. /**
  24678. * Abstract class used to decouple action Manager from scene and meshes.
  24679. * Do not instantiate.
  24680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24681. */
  24682. export abstract class AbstractActionManager implements IDisposable {
  24683. /** Gets the list of active triggers */
  24684. static Triggers: {
  24685. [key: string]: number;
  24686. };
  24687. /** Gets the cursor to use when hovering items */
  24688. hoverCursor: string;
  24689. /** Gets the list of actions */
  24690. actions: IAction[];
  24691. /**
  24692. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24693. */
  24694. isRecursive: boolean;
  24695. /**
  24696. * Releases all associated resources
  24697. */
  24698. abstract dispose(): void;
  24699. /**
  24700. * Does this action manager has pointer triggers
  24701. */
  24702. abstract readonly hasPointerTriggers: boolean;
  24703. /**
  24704. * Does this action manager has pick triggers
  24705. */
  24706. abstract readonly hasPickTriggers: boolean;
  24707. /**
  24708. * Process a specific trigger
  24709. * @param trigger defines the trigger to process
  24710. * @param evt defines the event details to be processed
  24711. */
  24712. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24713. /**
  24714. * Does this action manager handles actions of any of the given triggers
  24715. * @param triggers defines the triggers to be tested
  24716. * @return a boolean indicating whether one (or more) of the triggers is handled
  24717. */
  24718. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24719. /**
  24720. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24721. * speed.
  24722. * @param triggerA defines the trigger to be tested
  24723. * @param triggerB defines the trigger to be tested
  24724. * @return a boolean indicating whether one (or more) of the triggers is handled
  24725. */
  24726. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24727. /**
  24728. * Does this action manager handles actions of a given trigger
  24729. * @param trigger defines the trigger to be tested
  24730. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24731. * @return whether the trigger is handled
  24732. */
  24733. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24734. /**
  24735. * Serialize this manager to a JSON object
  24736. * @param name defines the property name to store this manager
  24737. * @returns a JSON representation of this manager
  24738. */
  24739. abstract serialize(name: string): any;
  24740. /**
  24741. * Registers an action to this action manager
  24742. * @param action defines the action to be registered
  24743. * @return the action amended (prepared) after registration
  24744. */
  24745. abstract registerAction(action: IAction): Nullable<IAction>;
  24746. /**
  24747. * Unregisters an action to this action manager
  24748. * @param action defines the action to be unregistered
  24749. * @return a boolean indicating whether the action has been unregistered
  24750. */
  24751. abstract unregisterAction(action: IAction): Boolean;
  24752. /**
  24753. * Does exist one action manager with at least one trigger
  24754. **/
  24755. static readonly HasTriggers: boolean;
  24756. /**
  24757. * Does exist one action manager with at least one pick trigger
  24758. **/
  24759. static readonly HasPickTriggers: boolean;
  24760. /**
  24761. * Does exist one action manager that handles actions of a given trigger
  24762. * @param trigger defines the trigger to be tested
  24763. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24764. **/
  24765. static HasSpecificTrigger(trigger: number): boolean;
  24766. }
  24767. }
  24768. declare module "babylonjs/node" {
  24769. import { Scene } from "babylonjs/scene";
  24770. import { Nullable } from "babylonjs/types";
  24771. import { Matrix } from "babylonjs/Maths/math";
  24772. import { Engine } from "babylonjs/Engines/engine";
  24773. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24774. import { Observable } from "babylonjs/Misc/observable";
  24775. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24776. import { Animatable } from "babylonjs/Animations/animatable";
  24777. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24778. import { Animation } from "babylonjs/Animations/animation";
  24779. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24781. /**
  24782. * Defines how a node can be built from a string name.
  24783. */
  24784. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24785. /**
  24786. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24787. */
  24788. export class Node implements IBehaviorAware<Node> {
  24789. /** @hidden */
  24790. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24791. private static _NodeConstructors;
  24792. /**
  24793. * Add a new node constructor
  24794. * @param type defines the type name of the node to construct
  24795. * @param constructorFunc defines the constructor function
  24796. */
  24797. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24798. /**
  24799. * Returns a node constructor based on type name
  24800. * @param type defines the type name
  24801. * @param name defines the new node name
  24802. * @param scene defines the hosting scene
  24803. * @param options defines optional options to transmit to constructors
  24804. * @returns the new constructor or null
  24805. */
  24806. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24807. /**
  24808. * Gets or sets the name of the node
  24809. */
  24810. name: string;
  24811. /**
  24812. * Gets or sets the id of the node
  24813. */
  24814. id: string;
  24815. /**
  24816. * Gets or sets the unique id of the node
  24817. */
  24818. uniqueId: number;
  24819. /**
  24820. * Gets or sets a string used to store user defined state for the node
  24821. */
  24822. state: string;
  24823. /**
  24824. * Gets or sets an object used to store user defined information for the node
  24825. */
  24826. metadata: any;
  24827. /**
  24828. * For internal use only. Please do not use.
  24829. */
  24830. reservedDataStore: any;
  24831. /**
  24832. * Gets or sets a boolean used to define if the node must be serialized
  24833. */
  24834. doNotSerialize: boolean;
  24835. /** @hidden */
  24836. _isDisposed: boolean;
  24837. /**
  24838. * Gets a list of Animations associated with the node
  24839. */
  24840. animations: import("babylonjs/Animations/animation").Animation[];
  24841. protected _ranges: {
  24842. [name: string]: Nullable<AnimationRange>;
  24843. };
  24844. /**
  24845. * Callback raised when the node is ready to be used
  24846. */
  24847. onReady: (node: Node) => void;
  24848. private _isEnabled;
  24849. private _isParentEnabled;
  24850. private _isReady;
  24851. /** @hidden */
  24852. _currentRenderId: number;
  24853. private _parentRenderId;
  24854. protected _childRenderId: number;
  24855. /** @hidden */
  24856. _waitingParentId: Nullable<string>;
  24857. /** @hidden */
  24858. _scene: Scene;
  24859. /** @hidden */
  24860. _cache: any;
  24861. private _parentNode;
  24862. private _children;
  24863. /** @hidden */
  24864. _worldMatrix: Matrix;
  24865. /** @hidden */
  24866. _worldMatrixDeterminant: number;
  24867. /** @hidden */
  24868. private _sceneRootNodesIndex;
  24869. /**
  24870. * Gets a boolean indicating if the node has been disposed
  24871. * @returns true if the node was disposed
  24872. */
  24873. isDisposed(): boolean;
  24874. /**
  24875. * Gets or sets the parent of the node
  24876. */
  24877. parent: Nullable<Node>;
  24878. private addToSceneRootNodes;
  24879. private removeFromSceneRootNodes;
  24880. private _animationPropertiesOverride;
  24881. /**
  24882. * Gets or sets the animation properties override
  24883. */
  24884. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24885. /**
  24886. * Gets a string idenfifying the name of the class
  24887. * @returns "Node" string
  24888. */
  24889. getClassName(): string;
  24890. /** @hidden */
  24891. readonly _isNode: boolean;
  24892. /**
  24893. * An event triggered when the mesh is disposed
  24894. */
  24895. onDisposeObservable: Observable<Node>;
  24896. private _onDisposeObserver;
  24897. /**
  24898. * Sets a callback that will be raised when the node will be disposed
  24899. */
  24900. onDispose: () => void;
  24901. /**
  24902. * Creates a new Node
  24903. * @param name the name and id to be given to this node
  24904. * @param scene the scene this node will be added to
  24905. * @param addToRootNodes the node will be added to scene.rootNodes
  24906. */
  24907. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24908. /**
  24909. * Gets the scene of the node
  24910. * @returns a scene
  24911. */
  24912. getScene(): Scene;
  24913. /**
  24914. * Gets the engine of the node
  24915. * @returns a Engine
  24916. */
  24917. getEngine(): Engine;
  24918. private _behaviors;
  24919. /**
  24920. * Attach a behavior to the node
  24921. * @see http://doc.babylonjs.com/features/behaviour
  24922. * @param behavior defines the behavior to attach
  24923. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24924. * @returns the current Node
  24925. */
  24926. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24927. /**
  24928. * Remove an attached behavior
  24929. * @see http://doc.babylonjs.com/features/behaviour
  24930. * @param behavior defines the behavior to attach
  24931. * @returns the current Node
  24932. */
  24933. removeBehavior(behavior: Behavior<Node>): Node;
  24934. /**
  24935. * Gets the list of attached behaviors
  24936. * @see http://doc.babylonjs.com/features/behaviour
  24937. */
  24938. readonly behaviors: Behavior<Node>[];
  24939. /**
  24940. * Gets an attached behavior by name
  24941. * @param name defines the name of the behavior to look for
  24942. * @see http://doc.babylonjs.com/features/behaviour
  24943. * @returns null if behavior was not found else the requested behavior
  24944. */
  24945. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24946. /**
  24947. * Returns the latest update of the World matrix
  24948. * @returns a Matrix
  24949. */
  24950. getWorldMatrix(): Matrix;
  24951. /** @hidden */
  24952. _getWorldMatrixDeterminant(): number;
  24953. /**
  24954. * Returns directly the latest state of the mesh World matrix.
  24955. * A Matrix is returned.
  24956. */
  24957. readonly worldMatrixFromCache: Matrix;
  24958. /** @hidden */
  24959. _initCache(): void;
  24960. /** @hidden */
  24961. updateCache(force?: boolean): void;
  24962. /** @hidden */
  24963. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24964. /** @hidden */
  24965. _updateCache(ignoreParentClass?: boolean): void;
  24966. /** @hidden */
  24967. _isSynchronized(): boolean;
  24968. /** @hidden */
  24969. _markSyncedWithParent(): void;
  24970. /** @hidden */
  24971. isSynchronizedWithParent(): boolean;
  24972. /** @hidden */
  24973. isSynchronized(): boolean;
  24974. /**
  24975. * Is this node ready to be used/rendered
  24976. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24977. * @return true if the node is ready
  24978. */
  24979. isReady(completeCheck?: boolean): boolean;
  24980. /**
  24981. * Is this node enabled?
  24982. * 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
  24983. * @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
  24984. * @return whether this node (and its parent) is enabled
  24985. */
  24986. isEnabled(checkAncestors?: boolean): boolean;
  24987. /** @hidden */
  24988. protected _syncParentEnabledState(): void;
  24989. /**
  24990. * Set the enabled state of this node
  24991. * @param value defines the new enabled state
  24992. */
  24993. setEnabled(value: boolean): void;
  24994. /**
  24995. * Is this node a descendant of the given node?
  24996. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24997. * @param ancestor defines the parent node to inspect
  24998. * @returns a boolean indicating if this node is a descendant of the given node
  24999. */
  25000. isDescendantOf(ancestor: Node): boolean;
  25001. /** @hidden */
  25002. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25003. /**
  25004. * Will return all nodes that have this node as ascendant
  25005. * @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
  25006. * @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
  25007. * @return all children nodes of all types
  25008. */
  25009. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25010. /**
  25011. * Get all child-meshes of this node
  25012. * @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)
  25013. * @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
  25014. * @returns an array of AbstractMesh
  25015. */
  25016. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25017. /**
  25018. * Get all direct children of this node
  25019. * @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
  25020. * @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)
  25021. * @returns an array of Node
  25022. */
  25023. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25024. /** @hidden */
  25025. _setReady(state: boolean): void;
  25026. /**
  25027. * Get an animation by name
  25028. * @param name defines the name of the animation to look for
  25029. * @returns null if not found else the requested animation
  25030. */
  25031. getAnimationByName(name: string): Nullable<Animation>;
  25032. /**
  25033. * Creates an animation range for this node
  25034. * @param name defines the name of the range
  25035. * @param from defines the starting key
  25036. * @param to defines the end key
  25037. */
  25038. createAnimationRange(name: string, from: number, to: number): void;
  25039. /**
  25040. * Delete a specific animation range
  25041. * @param name defines the name of the range to delete
  25042. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25043. */
  25044. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25045. /**
  25046. * Get an animation range by name
  25047. * @param name defines the name of the animation range to look for
  25048. * @returns null if not found else the requested animation range
  25049. */
  25050. getAnimationRange(name: string): Nullable<AnimationRange>;
  25051. /**
  25052. * Gets the list of all animation ranges defined on this node
  25053. * @returns an array
  25054. */
  25055. getAnimationRanges(): Nullable<AnimationRange>[];
  25056. /**
  25057. * Will start the animation sequence
  25058. * @param name defines the range frames for animation sequence
  25059. * @param loop defines if the animation should loop (false by default)
  25060. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25061. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25062. * @returns the object created for this animation. If range does not exist, it will return null
  25063. */
  25064. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25065. /**
  25066. * Serialize animation ranges into a JSON compatible object
  25067. * @returns serialization object
  25068. */
  25069. serializeAnimationRanges(): any;
  25070. /**
  25071. * Computes the world matrix of the node
  25072. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25073. * @returns the world matrix
  25074. */
  25075. computeWorldMatrix(force?: boolean): Matrix;
  25076. /**
  25077. * Releases resources associated with this node.
  25078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25080. */
  25081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25082. /**
  25083. * Parse animation range data from a serialization object and store them into a given node
  25084. * @param node defines where to store the animation ranges
  25085. * @param parsedNode defines the serialization object to read data from
  25086. * @param scene defines the hosting scene
  25087. */
  25088. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25089. }
  25090. }
  25091. declare module "babylonjs/Animations/animation" {
  25092. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25093. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25094. import { Nullable } from "babylonjs/types";
  25095. import { Scene } from "babylonjs/scene";
  25096. import { IAnimatable } from "babylonjs/Misc/tools";
  25097. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25098. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25099. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25100. import { Node } from "babylonjs/node";
  25101. import { Animatable } from "babylonjs/Animations/animatable";
  25102. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25103. /**
  25104. * Class used to store any kind of animation
  25105. */
  25106. export class Animation {
  25107. /**Name of the animation */
  25108. name: string;
  25109. /**Property to animate */
  25110. targetProperty: string;
  25111. /**The frames per second of the animation */
  25112. framePerSecond: number;
  25113. /**The data type of the animation */
  25114. dataType: number;
  25115. /**The loop mode of the animation */
  25116. loopMode?: number | undefined;
  25117. /**Specifies if blending should be enabled */
  25118. enableBlending?: boolean | undefined;
  25119. /**
  25120. * Use matrix interpolation instead of using direct key value when animating matrices
  25121. */
  25122. static AllowMatricesInterpolation: boolean;
  25123. /**
  25124. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25125. */
  25126. static AllowMatrixDecomposeForInterpolation: boolean;
  25127. /**
  25128. * Stores the key frames of the animation
  25129. */
  25130. private _keys;
  25131. /**
  25132. * Stores the easing function of the animation
  25133. */
  25134. private _easingFunction;
  25135. /**
  25136. * @hidden Internal use only
  25137. */
  25138. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25139. /**
  25140. * The set of event that will be linked to this animation
  25141. */
  25142. private _events;
  25143. /**
  25144. * Stores an array of target property paths
  25145. */
  25146. targetPropertyPath: string[];
  25147. /**
  25148. * Stores the blending speed of the animation
  25149. */
  25150. blendingSpeed: number;
  25151. /**
  25152. * Stores the animation ranges for the animation
  25153. */
  25154. private _ranges;
  25155. /**
  25156. * @hidden Internal use
  25157. */
  25158. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25159. /**
  25160. * Sets up an animation
  25161. * @param property The property to animate
  25162. * @param animationType The animation type to apply
  25163. * @param framePerSecond The frames per second of the animation
  25164. * @param easingFunction The easing function used in the animation
  25165. * @returns The created animation
  25166. */
  25167. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25168. /**
  25169. * Create and start an animation on a node
  25170. * @param name defines the name of the global animation that will be run on all nodes
  25171. * @param node defines the root node where the animation will take place
  25172. * @param targetProperty defines property to animate
  25173. * @param framePerSecond defines the number of frame per second yo use
  25174. * @param totalFrame defines the number of frames in total
  25175. * @param from defines the initial value
  25176. * @param to defines the final value
  25177. * @param loopMode defines which loop mode you want to use (off by default)
  25178. * @param easingFunction defines the easing function to use (linear by default)
  25179. * @param onAnimationEnd defines the callback to call when animation end
  25180. * @returns the animatable created for this animation
  25181. */
  25182. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25183. /**
  25184. * Create and start an animation on a node and its descendants
  25185. * @param name defines the name of the global animation that will be run on all nodes
  25186. * @param node defines the root node where the animation will take place
  25187. * @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
  25188. * @param targetProperty defines property to animate
  25189. * @param framePerSecond defines the number of frame per second to use
  25190. * @param totalFrame defines the number of frames in total
  25191. * @param from defines the initial value
  25192. * @param to defines the final value
  25193. * @param loopMode defines which loop mode you want to use (off by default)
  25194. * @param easingFunction defines the easing function to use (linear by default)
  25195. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25196. * @returns the list of animatables created for all nodes
  25197. * @example https://www.babylonjs-playground.com/#MH0VLI
  25198. */
  25199. 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[]>;
  25200. /**
  25201. * Creates a new animation, merges it with the existing animations and starts it
  25202. * @param name Name of the animation
  25203. * @param node Node which contains the scene that begins the animations
  25204. * @param targetProperty Specifies which property to animate
  25205. * @param framePerSecond The frames per second of the animation
  25206. * @param totalFrame The total number of frames
  25207. * @param from The frame at the beginning of the animation
  25208. * @param to The frame at the end of the animation
  25209. * @param loopMode Specifies the loop mode of the animation
  25210. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25211. * @param onAnimationEnd Callback to run once the animation is complete
  25212. * @returns Nullable animation
  25213. */
  25214. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25215. /**
  25216. * Transition property of an host to the target Value
  25217. * @param property The property to transition
  25218. * @param targetValue The target Value of the property
  25219. * @param host The object where the property to animate belongs
  25220. * @param scene Scene used to run the animation
  25221. * @param frameRate Framerate (in frame/s) to use
  25222. * @param transition The transition type we want to use
  25223. * @param duration The duration of the animation, in milliseconds
  25224. * @param onAnimationEnd Callback trigger at the end of the animation
  25225. * @returns Nullable animation
  25226. */
  25227. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25228. /**
  25229. * Return the array of runtime animations currently using this animation
  25230. */
  25231. readonly runtimeAnimations: RuntimeAnimation[];
  25232. /**
  25233. * Specifies if any of the runtime animations are currently running
  25234. */
  25235. readonly hasRunningRuntimeAnimations: boolean;
  25236. /**
  25237. * Initializes the animation
  25238. * @param name Name of the animation
  25239. * @param targetProperty Property to animate
  25240. * @param framePerSecond The frames per second of the animation
  25241. * @param dataType The data type of the animation
  25242. * @param loopMode The loop mode of the animation
  25243. * @param enableBlending Specifies if blending should be enabled
  25244. */
  25245. constructor(
  25246. /**Name of the animation */
  25247. name: string,
  25248. /**Property to animate */
  25249. targetProperty: string,
  25250. /**The frames per second of the animation */
  25251. framePerSecond: number,
  25252. /**The data type of the animation */
  25253. dataType: number,
  25254. /**The loop mode of the animation */
  25255. loopMode?: number | undefined,
  25256. /**Specifies if blending should be enabled */
  25257. enableBlending?: boolean | undefined);
  25258. /**
  25259. * Converts the animation to a string
  25260. * @param fullDetails support for multiple levels of logging within scene loading
  25261. * @returns String form of the animation
  25262. */
  25263. toString(fullDetails?: boolean): string;
  25264. /**
  25265. * Add an event to this animation
  25266. * @param event Event to add
  25267. */
  25268. addEvent(event: AnimationEvent): void;
  25269. /**
  25270. * Remove all events found at the given frame
  25271. * @param frame The frame to remove events from
  25272. */
  25273. removeEvents(frame: number): void;
  25274. /**
  25275. * Retrieves all the events from the animation
  25276. * @returns Events from the animation
  25277. */
  25278. getEvents(): AnimationEvent[];
  25279. /**
  25280. * Creates an animation range
  25281. * @param name Name of the animation range
  25282. * @param from Starting frame of the animation range
  25283. * @param to Ending frame of the animation
  25284. */
  25285. createRange(name: string, from: number, to: number): void;
  25286. /**
  25287. * Deletes an animation range by name
  25288. * @param name Name of the animation range to delete
  25289. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25290. */
  25291. deleteRange(name: string, deleteFrames?: boolean): void;
  25292. /**
  25293. * Gets the animation range by name, or null if not defined
  25294. * @param name Name of the animation range
  25295. * @returns Nullable animation range
  25296. */
  25297. getRange(name: string): Nullable<AnimationRange>;
  25298. /**
  25299. * Gets the key frames from the animation
  25300. * @returns The key frames of the animation
  25301. */
  25302. getKeys(): Array<IAnimationKey>;
  25303. /**
  25304. * Gets the highest frame rate of the animation
  25305. * @returns Highest frame rate of the animation
  25306. */
  25307. getHighestFrame(): number;
  25308. /**
  25309. * Gets the easing function of the animation
  25310. * @returns Easing function of the animation
  25311. */
  25312. getEasingFunction(): IEasingFunction;
  25313. /**
  25314. * Sets the easing function of the animation
  25315. * @param easingFunction A custom mathematical formula for animation
  25316. */
  25317. setEasingFunction(easingFunction: EasingFunction): void;
  25318. /**
  25319. * Interpolates a scalar linearly
  25320. * @param startValue Start value of the animation curve
  25321. * @param endValue End value of the animation curve
  25322. * @param gradient Scalar amount to interpolate
  25323. * @returns Interpolated scalar value
  25324. */
  25325. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25326. /**
  25327. * Interpolates a scalar cubically
  25328. * @param startValue Start value of the animation curve
  25329. * @param outTangent End tangent of the animation
  25330. * @param endValue End value of the animation curve
  25331. * @param inTangent Start tangent of the animation curve
  25332. * @param gradient Scalar amount to interpolate
  25333. * @returns Interpolated scalar value
  25334. */
  25335. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25336. /**
  25337. * Interpolates a quaternion using a spherical linear interpolation
  25338. * @param startValue Start value of the animation curve
  25339. * @param endValue End value of the animation curve
  25340. * @param gradient Scalar amount to interpolate
  25341. * @returns Interpolated quaternion value
  25342. */
  25343. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25344. /**
  25345. * Interpolates a quaternion cubically
  25346. * @param startValue Start value of the animation curve
  25347. * @param outTangent End tangent of the animation curve
  25348. * @param endValue End value of the animation curve
  25349. * @param inTangent Start tangent of the animation curve
  25350. * @param gradient Scalar amount to interpolate
  25351. * @returns Interpolated quaternion value
  25352. */
  25353. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25354. /**
  25355. * Interpolates a Vector3 linearl
  25356. * @param startValue Start value of the animation curve
  25357. * @param endValue End value of the animation curve
  25358. * @param gradient Scalar amount to interpolate
  25359. * @returns Interpolated scalar value
  25360. */
  25361. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25362. /**
  25363. * Interpolates a Vector3 cubically
  25364. * @param startValue Start value of the animation curve
  25365. * @param outTangent End tangent of the animation
  25366. * @param endValue End value of the animation curve
  25367. * @param inTangent Start tangent of the animation curve
  25368. * @param gradient Scalar amount to interpolate
  25369. * @returns InterpolatedVector3 value
  25370. */
  25371. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25372. /**
  25373. * Interpolates a Vector2 linearly
  25374. * @param startValue Start value of the animation curve
  25375. * @param endValue End value of the animation curve
  25376. * @param gradient Scalar amount to interpolate
  25377. * @returns Interpolated Vector2 value
  25378. */
  25379. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25380. /**
  25381. * Interpolates a Vector2 cubically
  25382. * @param startValue Start value of the animation curve
  25383. * @param outTangent End tangent of the animation
  25384. * @param endValue End value of the animation curve
  25385. * @param inTangent Start tangent of the animation curve
  25386. * @param gradient Scalar amount to interpolate
  25387. * @returns Interpolated Vector2 value
  25388. */
  25389. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25390. /**
  25391. * Interpolates a size linearly
  25392. * @param startValue Start value of the animation curve
  25393. * @param endValue End value of the animation curve
  25394. * @param gradient Scalar amount to interpolate
  25395. * @returns Interpolated Size value
  25396. */
  25397. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25398. /**
  25399. * Interpolates a Color3 linearly
  25400. * @param startValue Start value of the animation curve
  25401. * @param endValue End value of the animation curve
  25402. * @param gradient Scalar amount to interpolate
  25403. * @returns Interpolated Color3 value
  25404. */
  25405. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25406. /**
  25407. * @hidden Internal use only
  25408. */
  25409. _getKeyValue(value: any): any;
  25410. /**
  25411. * @hidden Internal use only
  25412. */
  25413. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25414. /**
  25415. * Defines the function to use to interpolate matrices
  25416. * @param startValue defines the start matrix
  25417. * @param endValue defines the end matrix
  25418. * @param gradient defines the gradient between both matrices
  25419. * @param result defines an optional target matrix where to store the interpolation
  25420. * @returns the interpolated matrix
  25421. */
  25422. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25423. /**
  25424. * Makes a copy of the animation
  25425. * @returns Cloned animation
  25426. */
  25427. clone(): Animation;
  25428. /**
  25429. * Sets the key frames of the animation
  25430. * @param values The animation key frames to set
  25431. */
  25432. setKeys(values: Array<IAnimationKey>): void;
  25433. /**
  25434. * Serializes the animation to an object
  25435. * @returns Serialized object
  25436. */
  25437. serialize(): any;
  25438. /**
  25439. * Float animation type
  25440. */
  25441. private static _ANIMATIONTYPE_FLOAT;
  25442. /**
  25443. * Vector3 animation type
  25444. */
  25445. private static _ANIMATIONTYPE_VECTOR3;
  25446. /**
  25447. * Quaternion animation type
  25448. */
  25449. private static _ANIMATIONTYPE_QUATERNION;
  25450. /**
  25451. * Matrix animation type
  25452. */
  25453. private static _ANIMATIONTYPE_MATRIX;
  25454. /**
  25455. * Color3 animation type
  25456. */
  25457. private static _ANIMATIONTYPE_COLOR3;
  25458. /**
  25459. * Vector2 animation type
  25460. */
  25461. private static _ANIMATIONTYPE_VECTOR2;
  25462. /**
  25463. * Size animation type
  25464. */
  25465. private static _ANIMATIONTYPE_SIZE;
  25466. /**
  25467. * Relative Loop Mode
  25468. */
  25469. private static _ANIMATIONLOOPMODE_RELATIVE;
  25470. /**
  25471. * Cycle Loop Mode
  25472. */
  25473. private static _ANIMATIONLOOPMODE_CYCLE;
  25474. /**
  25475. * Constant Loop Mode
  25476. */
  25477. private static _ANIMATIONLOOPMODE_CONSTANT;
  25478. /**
  25479. * Get the float animation type
  25480. */
  25481. static readonly ANIMATIONTYPE_FLOAT: number;
  25482. /**
  25483. * Get the Vector3 animation type
  25484. */
  25485. static readonly ANIMATIONTYPE_VECTOR3: number;
  25486. /**
  25487. * Get the Vector2 animation type
  25488. */
  25489. static readonly ANIMATIONTYPE_VECTOR2: number;
  25490. /**
  25491. * Get the Size animation type
  25492. */
  25493. static readonly ANIMATIONTYPE_SIZE: number;
  25494. /**
  25495. * Get the Quaternion animation type
  25496. */
  25497. static readonly ANIMATIONTYPE_QUATERNION: number;
  25498. /**
  25499. * Get the Matrix animation type
  25500. */
  25501. static readonly ANIMATIONTYPE_MATRIX: number;
  25502. /**
  25503. * Get the Color3 animation type
  25504. */
  25505. static readonly ANIMATIONTYPE_COLOR3: number;
  25506. /**
  25507. * Get the Relative Loop Mode
  25508. */
  25509. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25510. /**
  25511. * Get the Cycle Loop Mode
  25512. */
  25513. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25514. /**
  25515. * Get the Constant Loop Mode
  25516. */
  25517. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25518. /** @hidden */
  25519. static _UniversalLerp(left: any, right: any, amount: number): any;
  25520. /**
  25521. * Parses an animation object and creates an animation
  25522. * @param parsedAnimation Parsed animation object
  25523. * @returns Animation object
  25524. */
  25525. static Parse(parsedAnimation: any): Animation;
  25526. /**
  25527. * Appends the serialized animations from the source animations
  25528. * @param source Source containing the animations
  25529. * @param destination Target to store the animations
  25530. */
  25531. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25532. }
  25533. }
  25534. declare module "babylonjs/Materials/Textures/baseTexture" {
  25535. import { Observable } from "babylonjs/Misc/observable";
  25536. import { IAnimatable } from "babylonjs/Misc/tools";
  25537. import { Nullable } from "babylonjs/types";
  25538. import { Scene } from "babylonjs/scene";
  25539. import { Matrix, ISize } from "babylonjs/Maths/math";
  25540. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25542. /**
  25543. * Base class of all the textures in babylon.
  25544. * It groups all the common properties the materials, post process, lights... might need
  25545. * in order to make a correct use of the texture.
  25546. */
  25547. export class BaseTexture implements IAnimatable {
  25548. /**
  25549. * Default anisotropic filtering level for the application.
  25550. * It is set to 4 as a good tradeoff between perf and quality.
  25551. */
  25552. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25553. /**
  25554. * Gets or sets the unique id of the texture
  25555. */
  25556. uniqueId: number;
  25557. /**
  25558. * Define the name of the texture.
  25559. */
  25560. name: string;
  25561. /**
  25562. * Gets or sets an object used to store user defined information.
  25563. */
  25564. metadata: any;
  25565. /**
  25566. * For internal use only. Please do not use.
  25567. */
  25568. reservedDataStore: any;
  25569. private _hasAlpha;
  25570. /**
  25571. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25572. */
  25573. hasAlpha: boolean;
  25574. /**
  25575. * Defines if the alpha value should be determined via the rgb values.
  25576. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25577. */
  25578. getAlphaFromRGB: boolean;
  25579. /**
  25580. * Intensity or strength of the texture.
  25581. * It is commonly used by materials to fine tune the intensity of the texture
  25582. */
  25583. level: number;
  25584. /**
  25585. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25586. * This is part of the texture as textures usually maps to one uv set.
  25587. */
  25588. coordinatesIndex: number;
  25589. private _coordinatesMode;
  25590. /**
  25591. * How a texture is mapped.
  25592. *
  25593. * | Value | Type | Description |
  25594. * | ----- | ----------------------------------- | ----------- |
  25595. * | 0 | EXPLICIT_MODE | |
  25596. * | 1 | SPHERICAL_MODE | |
  25597. * | 2 | PLANAR_MODE | |
  25598. * | 3 | CUBIC_MODE | |
  25599. * | 4 | PROJECTION_MODE | |
  25600. * | 5 | SKYBOX_MODE | |
  25601. * | 6 | INVCUBIC_MODE | |
  25602. * | 7 | EQUIRECTANGULAR_MODE | |
  25603. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25604. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25605. */
  25606. coordinatesMode: number;
  25607. /**
  25608. * | Value | Type | Description |
  25609. * | ----- | ------------------ | ----------- |
  25610. * | 0 | CLAMP_ADDRESSMODE | |
  25611. * | 1 | WRAP_ADDRESSMODE | |
  25612. * | 2 | MIRROR_ADDRESSMODE | |
  25613. */
  25614. wrapU: number;
  25615. /**
  25616. * | Value | Type | Description |
  25617. * | ----- | ------------------ | ----------- |
  25618. * | 0 | CLAMP_ADDRESSMODE | |
  25619. * | 1 | WRAP_ADDRESSMODE | |
  25620. * | 2 | MIRROR_ADDRESSMODE | |
  25621. */
  25622. wrapV: number;
  25623. /**
  25624. * | Value | Type | Description |
  25625. * | ----- | ------------------ | ----------- |
  25626. * | 0 | CLAMP_ADDRESSMODE | |
  25627. * | 1 | WRAP_ADDRESSMODE | |
  25628. * | 2 | MIRROR_ADDRESSMODE | |
  25629. */
  25630. wrapR: number;
  25631. /**
  25632. * With compliant hardware and browser (supporting anisotropic filtering)
  25633. * this defines the level of anisotropic filtering in the texture.
  25634. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25635. */
  25636. anisotropicFilteringLevel: number;
  25637. /**
  25638. * Define if the texture is a cube texture or if false a 2d texture.
  25639. */
  25640. isCube: boolean;
  25641. /**
  25642. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25643. */
  25644. is3D: boolean;
  25645. /**
  25646. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25647. * HDR texture are usually stored in linear space.
  25648. * This only impacts the PBR and Background materials
  25649. */
  25650. gammaSpace: boolean;
  25651. /**
  25652. * Gets whether or not the texture contains RGBD data.
  25653. */
  25654. readonly isRGBD: boolean;
  25655. /**
  25656. * Is Z inverted in the texture (useful in a cube texture).
  25657. */
  25658. invertZ: boolean;
  25659. /**
  25660. * Are mip maps generated for this texture or not.
  25661. */
  25662. readonly noMipmap: boolean;
  25663. /**
  25664. * @hidden
  25665. */
  25666. lodLevelInAlpha: boolean;
  25667. /**
  25668. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25669. */
  25670. lodGenerationOffset: number;
  25671. /**
  25672. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25673. */
  25674. lodGenerationScale: number;
  25675. /**
  25676. * Define if the texture is a render target.
  25677. */
  25678. isRenderTarget: boolean;
  25679. /**
  25680. * Define the unique id of the texture in the scene.
  25681. */
  25682. readonly uid: string;
  25683. /**
  25684. * Return a string representation of the texture.
  25685. * @returns the texture as a string
  25686. */
  25687. toString(): string;
  25688. /**
  25689. * Get the class name of the texture.
  25690. * @returns "BaseTexture"
  25691. */
  25692. getClassName(): string;
  25693. /**
  25694. * Define the list of animation attached to the texture.
  25695. */
  25696. animations: import("babylonjs/Animations/animation").Animation[];
  25697. /**
  25698. * An event triggered when the texture is disposed.
  25699. */
  25700. onDisposeObservable: Observable<BaseTexture>;
  25701. private _onDisposeObserver;
  25702. /**
  25703. * Callback triggered when the texture has been disposed.
  25704. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25705. */
  25706. onDispose: () => void;
  25707. /**
  25708. * Define the current state of the loading sequence when in delayed load mode.
  25709. */
  25710. delayLoadState: number;
  25711. private _scene;
  25712. /** @hidden */
  25713. _texture: Nullable<InternalTexture>;
  25714. private _uid;
  25715. /**
  25716. * Define if the texture is preventinga material to render or not.
  25717. * If not and the texture is not ready, the engine will use a default black texture instead.
  25718. */
  25719. readonly isBlocking: boolean;
  25720. /**
  25721. * Instantiates a new BaseTexture.
  25722. * Base class of all the textures in babylon.
  25723. * It groups all the common properties the materials, post process, lights... might need
  25724. * in order to make a correct use of the texture.
  25725. * @param scene Define the scene the texture blongs to
  25726. */
  25727. constructor(scene: Nullable<Scene>);
  25728. /**
  25729. * Get the scene the texture belongs to.
  25730. * @returns the scene or null if undefined
  25731. */
  25732. getScene(): Nullable<Scene>;
  25733. /**
  25734. * Get the texture transform matrix used to offset tile the texture for istance.
  25735. * @returns the transformation matrix
  25736. */
  25737. getTextureMatrix(): Matrix;
  25738. /**
  25739. * Get the texture reflection matrix used to rotate/transform the reflection.
  25740. * @returns the reflection matrix
  25741. */
  25742. getReflectionTextureMatrix(): Matrix;
  25743. /**
  25744. * Get the underlying lower level texture from Babylon.
  25745. * @returns the insternal texture
  25746. */
  25747. getInternalTexture(): Nullable<InternalTexture>;
  25748. /**
  25749. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25750. * @returns true if ready or not blocking
  25751. */
  25752. isReadyOrNotBlocking(): boolean;
  25753. /**
  25754. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25755. * @returns true if fully ready
  25756. */
  25757. isReady(): boolean;
  25758. private _cachedSize;
  25759. /**
  25760. * Get the size of the texture.
  25761. * @returns the texture size.
  25762. */
  25763. getSize(): ISize;
  25764. /**
  25765. * Get the base size of the texture.
  25766. * It can be different from the size if the texture has been resized for POT for instance
  25767. * @returns the base size
  25768. */
  25769. getBaseSize(): ISize;
  25770. /**
  25771. * Update the sampling mode of the texture.
  25772. * Default is Trilinear mode.
  25773. *
  25774. * | Value | Type | Description |
  25775. * | ----- | ------------------ | ----------- |
  25776. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25777. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25778. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25779. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25780. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25781. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25782. * | 7 | NEAREST_LINEAR | |
  25783. * | 8 | NEAREST_NEAREST | |
  25784. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25785. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25786. * | 11 | LINEAR_LINEAR | |
  25787. * | 12 | LINEAR_NEAREST | |
  25788. *
  25789. * > _mag_: magnification filter (close to the viewer)
  25790. * > _min_: minification filter (far from the viewer)
  25791. * > _mip_: filter used between mip map levels
  25792. *@param samplingMode Define the new sampling mode of the texture
  25793. */
  25794. updateSamplingMode(samplingMode: number): void;
  25795. /**
  25796. * Scales the texture if is `canRescale()`
  25797. * @param ratio the resize factor we want to use to rescale
  25798. */
  25799. scale(ratio: number): void;
  25800. /**
  25801. * Get if the texture can rescale.
  25802. */
  25803. readonly canRescale: boolean;
  25804. /** @hidden */
  25805. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25806. /** @hidden */
  25807. _rebuild(): void;
  25808. /**
  25809. * Triggers the load sequence in delayed load mode.
  25810. */
  25811. delayLoad(): void;
  25812. /**
  25813. * Clones the texture.
  25814. * @returns the cloned texture
  25815. */
  25816. clone(): Nullable<BaseTexture>;
  25817. /**
  25818. * Get the texture underlying type (INT, FLOAT...)
  25819. */
  25820. readonly textureType: number;
  25821. /**
  25822. * Get the texture underlying format (RGB, RGBA...)
  25823. */
  25824. readonly textureFormat: number;
  25825. /**
  25826. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25827. * This will returns an RGBA array buffer containing either in values (0-255) or
  25828. * float values (0-1) depending of the underlying buffer type.
  25829. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25830. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25831. * @param buffer defines a user defined buffer to fill with data (can be null)
  25832. * @returns The Array buffer containing the pixels data.
  25833. */
  25834. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25835. /**
  25836. * Release and destroy the underlying lower level texture aka internalTexture.
  25837. */
  25838. releaseInternalTexture(): void;
  25839. /**
  25840. * Get the polynomial representation of the texture data.
  25841. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25842. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25843. */
  25844. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25845. /** @hidden */
  25846. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25847. /** @hidden */
  25848. readonly _lodTextureMid: Nullable<BaseTexture>;
  25849. /** @hidden */
  25850. readonly _lodTextureLow: Nullable<BaseTexture>;
  25851. /**
  25852. * Dispose the texture and release its associated resources.
  25853. */
  25854. dispose(): void;
  25855. /**
  25856. * Serialize the texture into a JSON representation that can be parsed later on.
  25857. * @returns the JSON representation of the texture
  25858. */
  25859. serialize(): any;
  25860. /**
  25861. * Helper function to be called back once a list of texture contains only ready textures.
  25862. * @param textures Define the list of textures to wait for
  25863. * @param callback Define the callback triggered once the entire list will be ready
  25864. */
  25865. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25866. }
  25867. }
  25868. declare module "babylonjs/Materials/uniformBuffer" {
  25869. import { Nullable, FloatArray } from "babylonjs/types";
  25870. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25871. import { Engine } from "babylonjs/Engines/engine";
  25872. import { Effect } from "babylonjs/Materials/effect";
  25873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25874. /**
  25875. * Uniform buffer objects.
  25876. *
  25877. * Handles blocks of uniform on the GPU.
  25878. *
  25879. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25880. *
  25881. * For more information, please refer to :
  25882. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25883. */
  25884. export class UniformBuffer {
  25885. private _engine;
  25886. private _buffer;
  25887. private _data;
  25888. private _bufferData;
  25889. private _dynamic?;
  25890. private _uniformLocations;
  25891. private _uniformSizes;
  25892. private _uniformLocationPointer;
  25893. private _needSync;
  25894. private _noUBO;
  25895. private _currentEffect;
  25896. private static _MAX_UNIFORM_SIZE;
  25897. private static _tempBuffer;
  25898. /**
  25899. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25900. * This is dynamic to allow compat with webgl 1 and 2.
  25901. * You will need to pass the name of the uniform as well as the value.
  25902. */
  25903. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25904. /**
  25905. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25906. * This is dynamic to allow compat with webgl 1 and 2.
  25907. * You will need to pass the name of the uniform as well as the value.
  25908. */
  25909. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25910. /**
  25911. * Lambda to Update a single float in a uniform buffer.
  25912. * This is dynamic to allow compat with webgl 1 and 2.
  25913. * You will need to pass the name of the uniform as well as the value.
  25914. */
  25915. updateFloat: (name: string, x: number) => void;
  25916. /**
  25917. * Lambda to Update a vec2 of float in a uniform buffer.
  25918. * This is dynamic to allow compat with webgl 1 and 2.
  25919. * You will need to pass the name of the uniform as well as the value.
  25920. */
  25921. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25922. /**
  25923. * Lambda to Update a vec3 of float in a uniform buffer.
  25924. * This is dynamic to allow compat with webgl 1 and 2.
  25925. * You will need to pass the name of the uniform as well as the value.
  25926. */
  25927. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25928. /**
  25929. * Lambda to Update a vec4 of float in a uniform buffer.
  25930. * This is dynamic to allow compat with webgl 1 and 2.
  25931. * You will need to pass the name of the uniform as well as the value.
  25932. */
  25933. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25934. /**
  25935. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25936. * This is dynamic to allow compat with webgl 1 and 2.
  25937. * You will need to pass the name of the uniform as well as the value.
  25938. */
  25939. updateMatrix: (name: string, mat: Matrix) => void;
  25940. /**
  25941. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25942. * This is dynamic to allow compat with webgl 1 and 2.
  25943. * You will need to pass the name of the uniform as well as the value.
  25944. */
  25945. updateVector3: (name: string, vector: Vector3) => void;
  25946. /**
  25947. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25948. * This is dynamic to allow compat with webgl 1 and 2.
  25949. * You will need to pass the name of the uniform as well as the value.
  25950. */
  25951. updateVector4: (name: string, vector: Vector4) => void;
  25952. /**
  25953. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25954. * This is dynamic to allow compat with webgl 1 and 2.
  25955. * You will need to pass the name of the uniform as well as the value.
  25956. */
  25957. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25958. /**
  25959. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25960. * This is dynamic to allow compat with webgl 1 and 2.
  25961. * You will need to pass the name of the uniform as well as the value.
  25962. */
  25963. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25964. /**
  25965. * Instantiates a new Uniform buffer objects.
  25966. *
  25967. * Handles blocks of uniform on the GPU.
  25968. *
  25969. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25970. *
  25971. * For more information, please refer to :
  25972. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25973. * @param engine Define the engine the buffer is associated with
  25974. * @param data Define the data contained in the buffer
  25975. * @param dynamic Define if the buffer is updatable
  25976. */
  25977. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25978. /**
  25979. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25980. * or just falling back on setUniformXXX calls.
  25981. */
  25982. readonly useUbo: boolean;
  25983. /**
  25984. * Indicates if the WebGL underlying uniform buffer is in sync
  25985. * with the javascript cache data.
  25986. */
  25987. readonly isSync: boolean;
  25988. /**
  25989. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25990. * Also, a dynamic UniformBuffer will disable cache verification and always
  25991. * update the underlying WebGL uniform buffer to the GPU.
  25992. * @returns if Dynamic, otherwise false
  25993. */
  25994. isDynamic(): boolean;
  25995. /**
  25996. * The data cache on JS side.
  25997. * @returns the underlying data as a float array
  25998. */
  25999. getData(): Float32Array;
  26000. /**
  26001. * The underlying WebGL Uniform buffer.
  26002. * @returns the webgl buffer
  26003. */
  26004. getBuffer(): Nullable<WebGLBuffer>;
  26005. /**
  26006. * std140 layout specifies how to align data within an UBO structure.
  26007. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26008. * for specs.
  26009. */
  26010. private _fillAlignment;
  26011. /**
  26012. * Adds an uniform in the buffer.
  26013. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26014. * for the layout to be correct !
  26015. * @param name Name of the uniform, as used in the uniform block in the shader.
  26016. * @param size Data size, or data directly.
  26017. */
  26018. addUniform(name: string, size: number | number[]): void;
  26019. /**
  26020. * Adds a Matrix 4x4 to the uniform buffer.
  26021. * @param name Name of the uniform, as used in the uniform block in the shader.
  26022. * @param mat A 4x4 matrix.
  26023. */
  26024. addMatrix(name: string, mat: Matrix): void;
  26025. /**
  26026. * Adds a vec2 to the uniform buffer.
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. * @param x Define the x component value of the vec2
  26029. * @param y Define the y component value of the vec2
  26030. */
  26031. addFloat2(name: string, x: number, y: number): void;
  26032. /**
  26033. * Adds a vec3 to the uniform buffer.
  26034. * @param name Name of the uniform, as used in the uniform block in the shader.
  26035. * @param x Define the x component value of the vec3
  26036. * @param y Define the y component value of the vec3
  26037. * @param z Define the z component value of the vec3
  26038. */
  26039. addFloat3(name: string, x: number, y: number, z: number): void;
  26040. /**
  26041. * Adds a vec3 to the uniform buffer.
  26042. * @param name Name of the uniform, as used in the uniform block in the shader.
  26043. * @param color Define the vec3 from a Color
  26044. */
  26045. addColor3(name: string, color: Color3): void;
  26046. /**
  26047. * Adds a vec4 to the uniform buffer.
  26048. * @param name Name of the uniform, as used in the uniform block in the shader.
  26049. * @param color Define the rgb components from a Color
  26050. * @param alpha Define the a component of the vec4
  26051. */
  26052. addColor4(name: string, color: Color3, alpha: number): void;
  26053. /**
  26054. * Adds a vec3 to the uniform buffer.
  26055. * @param name Name of the uniform, as used in the uniform block in the shader.
  26056. * @param vector Define the vec3 components from a Vector
  26057. */
  26058. addVector3(name: string, vector: Vector3): void;
  26059. /**
  26060. * Adds a Matrix 3x3 to the uniform buffer.
  26061. * @param name Name of the uniform, as used in the uniform block in the shader.
  26062. */
  26063. addMatrix3x3(name: string): void;
  26064. /**
  26065. * Adds a Matrix 2x2 to the uniform buffer.
  26066. * @param name Name of the uniform, as used in the uniform block in the shader.
  26067. */
  26068. addMatrix2x2(name: string): void;
  26069. /**
  26070. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26071. */
  26072. create(): void;
  26073. /** @hidden */
  26074. _rebuild(): void;
  26075. /**
  26076. * Updates the WebGL Uniform Buffer on the GPU.
  26077. * If the `dynamic` flag is set to true, no cache comparison is done.
  26078. * Otherwise, the buffer will be updated only if the cache differs.
  26079. */
  26080. update(): void;
  26081. /**
  26082. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26083. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26084. * @param data Define the flattened data
  26085. * @param size Define the size of the data.
  26086. */
  26087. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26088. private _updateMatrix3x3ForUniform;
  26089. private _updateMatrix3x3ForEffect;
  26090. private _updateMatrix2x2ForEffect;
  26091. private _updateMatrix2x2ForUniform;
  26092. private _updateFloatForEffect;
  26093. private _updateFloatForUniform;
  26094. private _updateFloat2ForEffect;
  26095. private _updateFloat2ForUniform;
  26096. private _updateFloat3ForEffect;
  26097. private _updateFloat3ForUniform;
  26098. private _updateFloat4ForEffect;
  26099. private _updateFloat4ForUniform;
  26100. private _updateMatrixForEffect;
  26101. private _updateMatrixForUniform;
  26102. private _updateVector3ForEffect;
  26103. private _updateVector3ForUniform;
  26104. private _updateVector4ForEffect;
  26105. private _updateVector4ForUniform;
  26106. private _updateColor3ForEffect;
  26107. private _updateColor3ForUniform;
  26108. private _updateColor4ForEffect;
  26109. private _updateColor4ForUniform;
  26110. /**
  26111. * Sets a sampler uniform on the effect.
  26112. * @param name Define the name of the sampler.
  26113. * @param texture Define the texture to set in the sampler
  26114. */
  26115. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26116. /**
  26117. * Directly updates the value of the uniform in the cache AND on the GPU.
  26118. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26119. * @param data Define the flattened data
  26120. */
  26121. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26122. /**
  26123. * Binds this uniform buffer to an effect.
  26124. * @param effect Define the effect to bind the buffer to
  26125. * @param name Name of the uniform block in the shader.
  26126. */
  26127. bindToEffect(effect: Effect, name: string): void;
  26128. /**
  26129. * Disposes the uniform buffer.
  26130. */
  26131. dispose(): void;
  26132. }
  26133. }
  26134. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26135. import { Nullable } from "babylonjs/types";
  26136. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26137. /**
  26138. * This represents the required contract to create a new type of texture loader.
  26139. */
  26140. export interface IInternalTextureLoader {
  26141. /**
  26142. * Defines wether the loader supports cascade loading the different faces.
  26143. */
  26144. supportCascades: boolean;
  26145. /**
  26146. * This returns if the loader support the current file information.
  26147. * @param extension defines the file extension of the file being loaded
  26148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26149. * @param fallback defines the fallback internal texture if any
  26150. * @param isBase64 defines whether the texture is encoded as a base64
  26151. * @param isBuffer defines whether the texture data are stored as a buffer
  26152. * @returns true if the loader can load the specified file
  26153. */
  26154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26155. /**
  26156. * Transform the url before loading if required.
  26157. * @param rootUrl the url of the texture
  26158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26159. * @returns the transformed texture
  26160. */
  26161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26162. /**
  26163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26164. * @param rootUrl the url of the texture
  26165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26166. * @returns the fallback texture
  26167. */
  26168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26169. /**
  26170. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26171. * @param data contains the texture data
  26172. * @param texture defines the BabylonJS internal texture
  26173. * @param createPolynomials will be true if polynomials have been requested
  26174. * @param onLoad defines the callback to trigger once the texture is ready
  26175. * @param onError defines the callback to trigger in case of error
  26176. */
  26177. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26178. /**
  26179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26180. * @param data contains the texture data
  26181. * @param texture defines the BabylonJS internal texture
  26182. * @param callback defines the method to call once ready to upload
  26183. */
  26184. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26185. }
  26186. }
  26187. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26188. import { Scene } from "babylonjs/scene";
  26189. import { Engine } from "babylonjs/Engines/engine";
  26190. import { Texture } from "babylonjs/Materials/Textures/texture";
  26191. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26192. /**
  26193. * Creation options of the multi render target texture.
  26194. */
  26195. export interface IMultiRenderTargetOptions {
  26196. /**
  26197. * Define if the texture needs to create mip maps after render.
  26198. */
  26199. generateMipMaps?: boolean;
  26200. /**
  26201. * Define the types of all the draw buffers we want to create
  26202. */
  26203. types?: number[];
  26204. /**
  26205. * Define the sampling modes of all the draw buffers we want to create
  26206. */
  26207. samplingModes?: number[];
  26208. /**
  26209. * Define if a depth buffer is required
  26210. */
  26211. generateDepthBuffer?: boolean;
  26212. /**
  26213. * Define if a stencil buffer is required
  26214. */
  26215. generateStencilBuffer?: boolean;
  26216. /**
  26217. * Define if a depth texture is required instead of a depth buffer
  26218. */
  26219. generateDepthTexture?: boolean;
  26220. /**
  26221. * Define the number of desired draw buffers
  26222. */
  26223. textureCount?: number;
  26224. /**
  26225. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26226. */
  26227. doNotChangeAspectRatio?: boolean;
  26228. /**
  26229. * Define the default type of the buffers we are creating
  26230. */
  26231. defaultType?: number;
  26232. }
  26233. /**
  26234. * A multi render target, like a render target provides the ability to render to a texture.
  26235. * Unlike the render target, it can render to several draw buffers in one draw.
  26236. * This is specially interesting in deferred rendering or for any effects requiring more than
  26237. * just one color from a single pass.
  26238. */
  26239. export class MultiRenderTarget extends RenderTargetTexture {
  26240. private _internalTextures;
  26241. private _textures;
  26242. private _multiRenderTargetOptions;
  26243. /**
  26244. * Get if draw buffers are currently supported by the used hardware and browser.
  26245. */
  26246. readonly isSupported: boolean;
  26247. /**
  26248. * Get the list of textures generated by the multi render target.
  26249. */
  26250. readonly textures: Texture[];
  26251. /**
  26252. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26253. */
  26254. readonly depthTexture: Texture;
  26255. /**
  26256. * Set the wrapping mode on U of all the textures we are rendering to.
  26257. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26258. */
  26259. wrapU: number;
  26260. /**
  26261. * Set the wrapping mode on V of all the textures we are rendering to.
  26262. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26263. */
  26264. wrapV: number;
  26265. /**
  26266. * Instantiate a new multi render target texture.
  26267. * A multi render target, like a render target provides the ability to render to a texture.
  26268. * Unlike the render target, it can render to several draw buffers in one draw.
  26269. * This is specially interesting in deferred rendering or for any effects requiring more than
  26270. * just one color from a single pass.
  26271. * @param name Define the name of the texture
  26272. * @param size Define the size of the buffers to render to
  26273. * @param count Define the number of target we are rendering into
  26274. * @param scene Define the scene the texture belongs to
  26275. * @param options Define the options used to create the multi render target
  26276. */
  26277. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26278. /** @hidden */
  26279. _rebuild(): void;
  26280. private _createInternalTextures;
  26281. private _createTextures;
  26282. /**
  26283. * Define the number of samples used if MSAA is enabled.
  26284. */
  26285. samples: number;
  26286. /**
  26287. * Resize all the textures in the multi render target.
  26288. * Be carrefull as it will recreate all the data in the new texture.
  26289. * @param size Define the new size
  26290. */
  26291. resize(size: any): void;
  26292. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26293. /**
  26294. * Dispose the render targets and their associated resources
  26295. */
  26296. dispose(): void;
  26297. /**
  26298. * Release all the underlying texture used as draw buffers.
  26299. */
  26300. releaseInternalTextures(): void;
  26301. }
  26302. }
  26303. declare module "babylonjs/Audio/analyser" {
  26304. import { Scene } from "babylonjs/scene";
  26305. /**
  26306. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26308. */
  26309. export class Analyser {
  26310. /**
  26311. * Gets or sets the smoothing
  26312. * @ignorenaming
  26313. */
  26314. SMOOTHING: number;
  26315. /**
  26316. * Gets or sets the FFT table size
  26317. * @ignorenaming
  26318. */
  26319. FFT_SIZE: number;
  26320. /**
  26321. * Gets or sets the bar graph amplitude
  26322. * @ignorenaming
  26323. */
  26324. BARGRAPHAMPLITUDE: number;
  26325. /**
  26326. * Gets or sets the position of the debug canvas
  26327. * @ignorenaming
  26328. */
  26329. DEBUGCANVASPOS: {
  26330. x: number;
  26331. y: number;
  26332. };
  26333. /**
  26334. * Gets or sets the debug canvas size
  26335. * @ignorenaming
  26336. */
  26337. DEBUGCANVASSIZE: {
  26338. width: number;
  26339. height: number;
  26340. };
  26341. private _byteFreqs;
  26342. private _byteTime;
  26343. private _floatFreqs;
  26344. private _webAudioAnalyser;
  26345. private _debugCanvas;
  26346. private _debugCanvasContext;
  26347. private _scene;
  26348. private _registerFunc;
  26349. private _audioEngine;
  26350. /**
  26351. * Creates a new analyser
  26352. * @param scene defines hosting scene
  26353. */
  26354. constructor(scene: Scene);
  26355. /**
  26356. * Get the number of data values you will have to play with for the visualization
  26357. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26358. * @returns a number
  26359. */
  26360. getFrequencyBinCount(): number;
  26361. /**
  26362. * Gets the current frequency data as a byte array
  26363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26364. * @returns a Uint8Array
  26365. */
  26366. getByteFrequencyData(): Uint8Array;
  26367. /**
  26368. * Gets the current waveform as a byte array
  26369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26370. * @returns a Uint8Array
  26371. */
  26372. getByteTimeDomainData(): Uint8Array;
  26373. /**
  26374. * Gets the current frequency data as a float array
  26375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26376. * @returns a Float32Array
  26377. */
  26378. getFloatFrequencyData(): Float32Array;
  26379. /**
  26380. * Renders the debug canvas
  26381. */
  26382. drawDebugCanvas(): void;
  26383. /**
  26384. * Stops rendering the debug canvas and removes it
  26385. */
  26386. stopDebugCanvas(): void;
  26387. /**
  26388. * Connects two audio nodes
  26389. * @param inputAudioNode defines first node to connect
  26390. * @param outputAudioNode defines second node to connect
  26391. */
  26392. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26393. /**
  26394. * Releases all associated resources
  26395. */
  26396. dispose(): void;
  26397. }
  26398. }
  26399. declare module "babylonjs/Audio/audioEngine" {
  26400. import { IDisposable } from "babylonjs/scene";
  26401. import { Analyser } from "babylonjs/Audio/analyser";
  26402. import { Nullable } from "babylonjs/types";
  26403. import { Observable } from "babylonjs/Misc/observable";
  26404. /**
  26405. * This represents an audio engine and it is responsible
  26406. * to play, synchronize and analyse sounds throughout the application.
  26407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26408. */
  26409. export interface IAudioEngine extends IDisposable {
  26410. /**
  26411. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26412. */
  26413. readonly canUseWebAudio: boolean;
  26414. /**
  26415. * Gets the current AudioContext if available.
  26416. */
  26417. readonly audioContext: Nullable<AudioContext>;
  26418. /**
  26419. * The master gain node defines the global audio volume of your audio engine.
  26420. */
  26421. readonly masterGain: GainNode;
  26422. /**
  26423. * Gets whether or not mp3 are supported by your browser.
  26424. */
  26425. readonly isMP3supported: boolean;
  26426. /**
  26427. * Gets whether or not ogg are supported by your browser.
  26428. */
  26429. readonly isOGGsupported: boolean;
  26430. /**
  26431. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26432. * @ignoreNaming
  26433. */
  26434. WarnedWebAudioUnsupported: boolean;
  26435. /**
  26436. * Defines if the audio engine relies on a custom unlocked button.
  26437. * In this case, the embedded button will not be displayed.
  26438. */
  26439. useCustomUnlockedButton: boolean;
  26440. /**
  26441. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26442. */
  26443. readonly unlocked: boolean;
  26444. /**
  26445. * Event raised when audio has been unlocked on the browser.
  26446. */
  26447. onAudioUnlockedObservable: Observable<AudioEngine>;
  26448. /**
  26449. * Event raised when audio has been locked on the browser.
  26450. */
  26451. onAudioLockedObservable: Observable<AudioEngine>;
  26452. /**
  26453. * Flags the audio engine in Locked state.
  26454. * This happens due to new browser policies preventing audio to autoplay.
  26455. */
  26456. lock(): void;
  26457. /**
  26458. * Unlocks the audio engine once a user action has been done on the dom.
  26459. * This is helpful to resume play once browser policies have been satisfied.
  26460. */
  26461. unlock(): void;
  26462. }
  26463. /**
  26464. * This represents the default audio engine used in babylon.
  26465. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26467. */
  26468. export class AudioEngine implements IAudioEngine {
  26469. private _audioContext;
  26470. private _audioContextInitialized;
  26471. private _muteButton;
  26472. private _hostElement;
  26473. /**
  26474. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26475. */
  26476. canUseWebAudio: boolean;
  26477. /**
  26478. * The master gain node defines the global audio volume of your audio engine.
  26479. */
  26480. masterGain: GainNode;
  26481. /**
  26482. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26483. * @ignoreNaming
  26484. */
  26485. WarnedWebAudioUnsupported: boolean;
  26486. /**
  26487. * Gets whether or not mp3 are supported by your browser.
  26488. */
  26489. isMP3supported: boolean;
  26490. /**
  26491. * Gets whether or not ogg are supported by your browser.
  26492. */
  26493. isOGGsupported: boolean;
  26494. /**
  26495. * Gets whether audio has been unlocked on the device.
  26496. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26497. * a user interaction has happened.
  26498. */
  26499. unlocked: boolean;
  26500. /**
  26501. * Defines if the audio engine relies on a custom unlocked button.
  26502. * In this case, the embedded button will not be displayed.
  26503. */
  26504. useCustomUnlockedButton: boolean;
  26505. /**
  26506. * Event raised when audio has been unlocked on the browser.
  26507. */
  26508. onAudioUnlockedObservable: Observable<AudioEngine>;
  26509. /**
  26510. * Event raised when audio has been locked on the browser.
  26511. */
  26512. onAudioLockedObservable: Observable<AudioEngine>;
  26513. /**
  26514. * Gets the current AudioContext if available.
  26515. */
  26516. readonly audioContext: Nullable<AudioContext>;
  26517. private _connectedAnalyser;
  26518. /**
  26519. * Instantiates a new audio engine.
  26520. *
  26521. * There should be only one per page as some browsers restrict the number
  26522. * of audio contexts you can create.
  26523. * @param hostElement defines the host element where to display the mute icon if necessary
  26524. */
  26525. constructor(hostElement?: Nullable<HTMLElement>);
  26526. /**
  26527. * Flags the audio engine in Locked state.
  26528. * This happens due to new browser policies preventing audio to autoplay.
  26529. */
  26530. lock(): void;
  26531. /**
  26532. * Unlocks the audio engine once a user action has been done on the dom.
  26533. * This is helpful to resume play once browser policies have been satisfied.
  26534. */
  26535. unlock(): void;
  26536. private _resumeAudioContext;
  26537. private _initializeAudioContext;
  26538. private _tryToRun;
  26539. private _triggerRunningState;
  26540. private _triggerSuspendedState;
  26541. private _displayMuteButton;
  26542. private _moveButtonToTopLeft;
  26543. private _onResize;
  26544. private _hideMuteButton;
  26545. /**
  26546. * Destroy and release the resources associated with the audio ccontext.
  26547. */
  26548. dispose(): void;
  26549. /**
  26550. * Gets the global volume sets on the master gain.
  26551. * @returns the global volume if set or -1 otherwise
  26552. */
  26553. getGlobalVolume(): number;
  26554. /**
  26555. * Sets the global volume of your experience (sets on the master gain).
  26556. * @param newVolume Defines the new global volume of the application
  26557. */
  26558. setGlobalVolume(newVolume: number): void;
  26559. /**
  26560. * Connect the audio engine to an audio analyser allowing some amazing
  26561. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26563. * @param analyser The analyser to connect to the engine
  26564. */
  26565. connectToAnalyser(analyser: Analyser): void;
  26566. }
  26567. }
  26568. declare module "babylonjs/Loading/loadingScreen" {
  26569. /**
  26570. * Interface used to present a loading screen while loading a scene
  26571. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26572. */
  26573. export interface ILoadingScreen {
  26574. /**
  26575. * Function called to display the loading screen
  26576. */
  26577. displayLoadingUI: () => void;
  26578. /**
  26579. * Function called to hide the loading screen
  26580. */
  26581. hideLoadingUI: () => void;
  26582. /**
  26583. * Gets or sets the color to use for the background
  26584. */
  26585. loadingUIBackgroundColor: string;
  26586. /**
  26587. * Gets or sets the text to display while loading
  26588. */
  26589. loadingUIText: string;
  26590. }
  26591. /**
  26592. * Class used for the default loading screen
  26593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26594. */
  26595. export class DefaultLoadingScreen implements ILoadingScreen {
  26596. private _renderingCanvas;
  26597. private _loadingText;
  26598. private _loadingDivBackgroundColor;
  26599. private _loadingDiv;
  26600. private _loadingTextDiv;
  26601. /**
  26602. * Creates a new default loading screen
  26603. * @param _renderingCanvas defines the canvas used to render the scene
  26604. * @param _loadingText defines the default text to display
  26605. * @param _loadingDivBackgroundColor defines the default background color
  26606. */
  26607. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26608. /**
  26609. * Function called to display the loading screen
  26610. */
  26611. displayLoadingUI(): void;
  26612. /**
  26613. * Function called to hide the loading screen
  26614. */
  26615. hideLoadingUI(): void;
  26616. /**
  26617. * Gets or sets the text to display while loading
  26618. */
  26619. loadingUIText: string;
  26620. /**
  26621. * Gets or sets the color to use for the background
  26622. */
  26623. loadingUIBackgroundColor: string;
  26624. private _resizeLoadingUI;
  26625. }
  26626. }
  26627. declare module "babylonjs/Materials/Textures/videoTexture" {
  26628. import { Observable } from "babylonjs/Misc/observable";
  26629. import { Nullable } from "babylonjs/types";
  26630. import { Scene } from "babylonjs/scene";
  26631. import { Texture } from "babylonjs/Materials/Textures/texture";
  26632. /**
  26633. * Settings for finer control over video usage
  26634. */
  26635. export interface VideoTextureSettings {
  26636. /**
  26637. * Applies `autoplay` to video, if specified
  26638. */
  26639. autoPlay?: boolean;
  26640. /**
  26641. * Applies `loop` to video, if specified
  26642. */
  26643. loop?: boolean;
  26644. /**
  26645. * Automatically updates internal texture from video at every frame in the render loop
  26646. */
  26647. autoUpdateTexture: boolean;
  26648. /**
  26649. * Image src displayed during the video loading or until the user interacts with the video.
  26650. */
  26651. poster?: string;
  26652. }
  26653. /**
  26654. * If you want to display a video in your scene, this is the special texture for that.
  26655. * This special texture works similar to other textures, with the exception of a few parameters.
  26656. * @see https://doc.babylonjs.com/how_to/video_texture
  26657. */
  26658. export class VideoTexture extends Texture {
  26659. /**
  26660. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26661. */
  26662. readonly autoUpdateTexture: boolean;
  26663. /**
  26664. * The video instance used by the texture internally
  26665. */
  26666. readonly video: HTMLVideoElement;
  26667. private _onUserActionRequestedObservable;
  26668. /**
  26669. * Event triggerd when a dom action is required by the user to play the video.
  26670. * This happens due to recent changes in browser policies preventing video to auto start.
  26671. */
  26672. readonly onUserActionRequestedObservable: Observable<Texture>;
  26673. private _generateMipMaps;
  26674. private _engine;
  26675. private _stillImageCaptured;
  26676. private _displayingPosterTexture;
  26677. private _settings;
  26678. private _createInternalTextureOnEvent;
  26679. /**
  26680. * Creates a video texture.
  26681. * If you want to display a video in your scene, this is the special texture for that.
  26682. * This special texture works similar to other textures, with the exception of a few parameters.
  26683. * @see https://doc.babylonjs.com/how_to/video_texture
  26684. * @param name optional name, will detect from video source, if not defined
  26685. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26686. * @param scene is obviously the current scene.
  26687. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26688. * @param invertY is false by default but can be used to invert video on Y axis
  26689. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26690. * @param settings allows finer control over video usage
  26691. */
  26692. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26693. private _getName;
  26694. private _getVideo;
  26695. private _createInternalTexture;
  26696. private reset;
  26697. /**
  26698. * @hidden Internal method to initiate `update`.
  26699. */
  26700. _rebuild(): void;
  26701. /**
  26702. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26703. */
  26704. update(): void;
  26705. /**
  26706. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26707. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26708. */
  26709. updateTexture(isVisible: boolean): void;
  26710. protected _updateInternalTexture: () => void;
  26711. /**
  26712. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26713. * @param url New url.
  26714. */
  26715. updateURL(url: string): void;
  26716. /**
  26717. * Dispose the texture and release its associated resources.
  26718. */
  26719. dispose(): void;
  26720. /**
  26721. * Creates a video texture straight from a stream.
  26722. * @param scene Define the scene the texture should be created in
  26723. * @param stream Define the stream the texture should be created from
  26724. * @returns The created video texture as a promise
  26725. */
  26726. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26727. /**
  26728. * Creates a video texture straight from your WebCam video feed.
  26729. * @param scene Define the scene the texture should be created in
  26730. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26731. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26732. * @returns The created video texture as a promise
  26733. */
  26734. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26735. minWidth: number;
  26736. maxWidth: number;
  26737. minHeight: number;
  26738. maxHeight: number;
  26739. deviceId: string;
  26740. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26741. /**
  26742. * Creates a video texture straight from your WebCam video feed.
  26743. * @param scene Define the scene the texture should be created in
  26744. * @param onReady Define a callback to triggered once the texture will be ready
  26745. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26746. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26747. */
  26748. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26749. minWidth: number;
  26750. maxWidth: number;
  26751. minHeight: number;
  26752. maxHeight: number;
  26753. deviceId: string;
  26754. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26755. }
  26756. }
  26757. declare module "babylonjs/Engines/engine" {
  26758. import { Observable } from "babylonjs/Misc/observable";
  26759. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26760. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26761. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26762. import { Camera } from "babylonjs/Cameras/camera";
  26763. import { Scene } from "babylonjs/scene";
  26764. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26765. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26766. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26767. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26768. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26769. import { Material } from "babylonjs/Materials/material";
  26770. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26771. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26773. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26774. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26775. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26776. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26777. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26778. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26779. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26780. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26781. /**
  26782. * Interface for attribute information associated with buffer instanciation
  26783. */
  26784. export class InstancingAttributeInfo {
  26785. /**
  26786. * Index/offset of the attribute in the vertex shader
  26787. */
  26788. index: number;
  26789. /**
  26790. * size of the attribute, 1, 2, 3 or 4
  26791. */
  26792. attributeSize: number;
  26793. /**
  26794. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26795. * default is FLOAT
  26796. */
  26797. attribyteType: number;
  26798. /**
  26799. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26800. */
  26801. normalized: boolean;
  26802. /**
  26803. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26804. */
  26805. offset: number;
  26806. /**
  26807. * Name of the GLSL attribute, for debugging purpose only
  26808. */
  26809. attributeName: string;
  26810. }
  26811. /**
  26812. * Define options used to create a depth texture
  26813. */
  26814. export class DepthTextureCreationOptions {
  26815. /** Specifies whether or not a stencil should be allocated in the texture */
  26816. generateStencil?: boolean;
  26817. /** Specifies whether or not bilinear filtering is enable on the texture */
  26818. bilinearFiltering?: boolean;
  26819. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26820. comparisonFunction?: number;
  26821. /** Specifies if the created texture is a cube texture */
  26822. isCube?: boolean;
  26823. }
  26824. /**
  26825. * Class used to describe the capabilities of the engine relatively to the current browser
  26826. */
  26827. export class EngineCapabilities {
  26828. /** Maximum textures units per fragment shader */
  26829. maxTexturesImageUnits: number;
  26830. /** Maximum texture units per vertex shader */
  26831. maxVertexTextureImageUnits: number;
  26832. /** Maximum textures units in the entire pipeline */
  26833. maxCombinedTexturesImageUnits: number;
  26834. /** Maximum texture size */
  26835. maxTextureSize: number;
  26836. /** Maximum cube texture size */
  26837. maxCubemapTextureSize: number;
  26838. /** Maximum render texture size */
  26839. maxRenderTextureSize: number;
  26840. /** Maximum number of vertex attributes */
  26841. maxVertexAttribs: number;
  26842. /** Maximum number of varyings */
  26843. maxVaryingVectors: number;
  26844. /** Maximum number of uniforms per vertex shader */
  26845. maxVertexUniformVectors: number;
  26846. /** Maximum number of uniforms per fragment shader */
  26847. maxFragmentUniformVectors: number;
  26848. /** Defines if standard derivates (dx/dy) are supported */
  26849. standardDerivatives: boolean;
  26850. /** Defines if s3tc texture compression is supported */
  26851. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26852. /** Defines if pvrtc texture compression is supported */
  26853. pvrtc: any;
  26854. /** Defines if etc1 texture compression is supported */
  26855. etc1: any;
  26856. /** Defines if etc2 texture compression is supported */
  26857. etc2: any;
  26858. /** Defines if astc texture compression is supported */
  26859. astc: any;
  26860. /** Defines if float textures are supported */
  26861. textureFloat: boolean;
  26862. /** Defines if vertex array objects are supported */
  26863. vertexArrayObject: boolean;
  26864. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26865. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26866. /** Gets the maximum level of anisotropy supported */
  26867. maxAnisotropy: number;
  26868. /** Defines if instancing is supported */
  26869. instancedArrays: boolean;
  26870. /** Defines if 32 bits indices are supported */
  26871. uintIndices: boolean;
  26872. /** Defines if high precision shaders are supported */
  26873. highPrecisionShaderSupported: boolean;
  26874. /** Defines if depth reading in the fragment shader is supported */
  26875. fragmentDepthSupported: boolean;
  26876. /** Defines if float texture linear filtering is supported*/
  26877. textureFloatLinearFiltering: boolean;
  26878. /** Defines if rendering to float textures is supported */
  26879. textureFloatRender: boolean;
  26880. /** Defines if half float textures are supported*/
  26881. textureHalfFloat: boolean;
  26882. /** Defines if half float texture linear filtering is supported*/
  26883. textureHalfFloatLinearFiltering: boolean;
  26884. /** Defines if rendering to half float textures is supported */
  26885. textureHalfFloatRender: boolean;
  26886. /** Defines if textureLOD shader command is supported */
  26887. textureLOD: boolean;
  26888. /** Defines if draw buffers extension is supported */
  26889. drawBuffersExtension: boolean;
  26890. /** Defines if depth textures are supported */
  26891. depthTextureExtension: boolean;
  26892. /** Defines if float color buffer are supported */
  26893. colorBufferFloat: boolean;
  26894. /** Gets disjoint timer query extension (null if not supported) */
  26895. timerQuery: EXT_disjoint_timer_query;
  26896. /** Defines if timestamp can be used with timer query */
  26897. canUseTimestampForTimerQuery: boolean;
  26898. /** Function used to let the system compiles shaders in background */
  26899. parallelShaderCompile: {
  26900. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26901. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26902. COMPLETION_STATUS_KHR: number;
  26903. };
  26904. }
  26905. /** Interface defining initialization parameters for Engine class */
  26906. export interface EngineOptions extends WebGLContextAttributes {
  26907. /**
  26908. * Defines if the engine should no exceed a specified device ratio
  26909. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26910. */
  26911. limitDeviceRatio?: number;
  26912. /**
  26913. * Defines if webvr should be enabled automatically
  26914. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26915. */
  26916. autoEnableWebVR?: boolean;
  26917. /**
  26918. * Defines if webgl2 should be turned off even if supported
  26919. * @see http://doc.babylonjs.com/features/webgl2
  26920. */
  26921. disableWebGL2Support?: boolean;
  26922. /**
  26923. * Defines if webaudio should be initialized as well
  26924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26925. */
  26926. audioEngine?: boolean;
  26927. /**
  26928. * Defines if animations should run using a deterministic lock step
  26929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26930. */
  26931. deterministicLockstep?: boolean;
  26932. /** Defines the maximum steps to use with deterministic lock step mode */
  26933. lockstepMaxSteps?: number;
  26934. /**
  26935. * Defines that engine should ignore context lost events
  26936. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26937. */
  26938. doNotHandleContextLost?: boolean;
  26939. /**
  26940. * Defines that engine should ignore modifying touch action attribute and style
  26941. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26942. */
  26943. doNotHandleTouchAction?: boolean;
  26944. }
  26945. /**
  26946. * Defines the interface used by display changed events
  26947. */
  26948. export interface IDisplayChangedEventArgs {
  26949. /** Gets the vrDisplay object (if any) */
  26950. vrDisplay: Nullable<any>;
  26951. /** Gets a boolean indicating if webVR is supported */
  26952. vrSupported: boolean;
  26953. }
  26954. /**
  26955. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26956. */
  26957. export class Engine {
  26958. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26959. static ExceptionList: ({
  26960. key: string;
  26961. capture: string;
  26962. captureConstraint: number;
  26963. targets: string[];
  26964. } | {
  26965. key: string;
  26966. capture: null;
  26967. captureConstraint: null;
  26968. targets: string[];
  26969. })[];
  26970. /** Gets the list of created engines */
  26971. static readonly Instances: Engine[];
  26972. /**
  26973. * Gets the latest created engine
  26974. */
  26975. static readonly LastCreatedEngine: Nullable<Engine>;
  26976. /**
  26977. * Gets the latest created scene
  26978. */
  26979. static readonly LastCreatedScene: Nullable<Scene>;
  26980. /**
  26981. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26982. * @param flag defines which part of the materials must be marked as dirty
  26983. * @param predicate defines a predicate used to filter which materials should be affected
  26984. */
  26985. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26986. /**
  26987. * Hidden
  26988. */
  26989. static _TextureLoaders: IInternalTextureLoader[];
  26990. /** Defines that alpha blending is disabled */
  26991. static readonly ALPHA_DISABLE: number;
  26992. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26993. static readonly ALPHA_ADD: number;
  26994. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26995. static readonly ALPHA_COMBINE: number;
  26996. /** Defines that alpha blending to DEST - SRC * DEST */
  26997. static readonly ALPHA_SUBTRACT: number;
  26998. /** Defines that alpha blending to SRC * DEST */
  26999. static readonly ALPHA_MULTIPLY: number;
  27000. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27001. static readonly ALPHA_MAXIMIZED: number;
  27002. /** Defines that alpha blending to SRC + DEST */
  27003. static readonly ALPHA_ONEONE: number;
  27004. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27005. static readonly ALPHA_PREMULTIPLIED: number;
  27006. /**
  27007. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27008. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27009. */
  27010. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27011. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27012. static readonly ALPHA_INTERPOLATE: number;
  27013. /**
  27014. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27015. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27016. */
  27017. static readonly ALPHA_SCREENMODE: number;
  27018. /** Defines that the ressource is not delayed*/
  27019. static readonly DELAYLOADSTATE_NONE: number;
  27020. /** Defines that the ressource was successfully delay loaded */
  27021. static readonly DELAYLOADSTATE_LOADED: number;
  27022. /** Defines that the ressource is currently delay loading */
  27023. static readonly DELAYLOADSTATE_LOADING: number;
  27024. /** Defines that the ressource is delayed and has not started loading */
  27025. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27026. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27027. static readonly NEVER: number;
  27028. /** 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 */
  27029. static readonly ALWAYS: number;
  27030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27031. static readonly LESS: number;
  27032. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27033. static readonly EQUAL: number;
  27034. /** 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 */
  27035. static readonly LEQUAL: number;
  27036. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27037. static readonly GREATER: number;
  27038. /** 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 */
  27039. static readonly GEQUAL: number;
  27040. /** 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 */
  27041. static readonly NOTEQUAL: number;
  27042. /** Passed to stencilOperation to specify that stencil value must be kept */
  27043. static readonly KEEP: number;
  27044. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27045. static readonly REPLACE: number;
  27046. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27047. static readonly INCR: number;
  27048. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27049. static readonly DECR: number;
  27050. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27051. static readonly INVERT: number;
  27052. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27053. static readonly INCR_WRAP: number;
  27054. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27055. static readonly DECR_WRAP: number;
  27056. /** Texture is not repeating outside of 0..1 UVs */
  27057. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27058. /** Texture is repeating outside of 0..1 UVs */
  27059. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27060. /** Texture is repeating and mirrored */
  27061. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27062. /** ALPHA */
  27063. static readonly TEXTUREFORMAT_ALPHA: number;
  27064. /** LUMINANCE */
  27065. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27066. /** LUMINANCE_ALPHA */
  27067. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27068. /** RGB */
  27069. static readonly TEXTUREFORMAT_RGB: number;
  27070. /** RGBA */
  27071. static readonly TEXTUREFORMAT_RGBA: number;
  27072. /** RED */
  27073. static readonly TEXTUREFORMAT_RED: number;
  27074. /** RED (2nd reference) */
  27075. static readonly TEXTUREFORMAT_R: number;
  27076. /** RG */
  27077. static readonly TEXTUREFORMAT_RG: number;
  27078. /** RED_INTEGER */
  27079. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27080. /** RED_INTEGER (2nd reference) */
  27081. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27082. /** RG_INTEGER */
  27083. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27084. /** RGB_INTEGER */
  27085. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27086. /** RGBA_INTEGER */
  27087. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27088. /** UNSIGNED_BYTE */
  27089. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27090. /** UNSIGNED_BYTE (2nd reference) */
  27091. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27092. /** FLOAT */
  27093. static readonly TEXTURETYPE_FLOAT: number;
  27094. /** HALF_FLOAT */
  27095. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27096. /** BYTE */
  27097. static readonly TEXTURETYPE_BYTE: number;
  27098. /** SHORT */
  27099. static readonly TEXTURETYPE_SHORT: number;
  27100. /** UNSIGNED_SHORT */
  27101. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27102. /** INT */
  27103. static readonly TEXTURETYPE_INT: number;
  27104. /** UNSIGNED_INT */
  27105. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27106. /** UNSIGNED_SHORT_4_4_4_4 */
  27107. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27108. /** UNSIGNED_SHORT_5_5_5_1 */
  27109. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27110. /** UNSIGNED_SHORT_5_6_5 */
  27111. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27112. /** UNSIGNED_INT_2_10_10_10_REV */
  27113. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27114. /** UNSIGNED_INT_24_8 */
  27115. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27116. /** UNSIGNED_INT_10F_11F_11F_REV */
  27117. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27118. /** UNSIGNED_INT_5_9_9_9_REV */
  27119. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27120. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27121. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27122. /** nearest is mag = nearest and min = nearest and mip = linear */
  27123. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27124. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27125. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27126. /** Trilinear is mag = linear and min = linear and mip = linear */
  27127. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27128. /** nearest is mag = nearest and min = nearest and mip = linear */
  27129. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27130. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27131. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27132. /** Trilinear is mag = linear and min = linear and mip = linear */
  27133. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27134. /** mag = nearest and min = nearest and mip = nearest */
  27135. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27136. /** mag = nearest and min = linear and mip = nearest */
  27137. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27138. /** mag = nearest and min = linear and mip = linear */
  27139. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27140. /** mag = nearest and min = linear and mip = none */
  27141. static readonly TEXTURE_NEAREST_LINEAR: number;
  27142. /** mag = nearest and min = nearest and mip = none */
  27143. static readonly TEXTURE_NEAREST_NEAREST: number;
  27144. /** mag = linear and min = nearest and mip = nearest */
  27145. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27146. /** mag = linear and min = nearest and mip = linear */
  27147. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27148. /** mag = linear and min = linear and mip = none */
  27149. static readonly TEXTURE_LINEAR_LINEAR: number;
  27150. /** mag = linear and min = nearest and mip = none */
  27151. static readonly TEXTURE_LINEAR_NEAREST: number;
  27152. /** Explicit coordinates mode */
  27153. static readonly TEXTURE_EXPLICIT_MODE: number;
  27154. /** Spherical coordinates mode */
  27155. static readonly TEXTURE_SPHERICAL_MODE: number;
  27156. /** Planar coordinates mode */
  27157. static readonly TEXTURE_PLANAR_MODE: number;
  27158. /** Cubic coordinates mode */
  27159. static readonly TEXTURE_CUBIC_MODE: number;
  27160. /** Projection coordinates mode */
  27161. static readonly TEXTURE_PROJECTION_MODE: number;
  27162. /** Skybox coordinates mode */
  27163. static readonly TEXTURE_SKYBOX_MODE: number;
  27164. /** Inverse Cubic coordinates mode */
  27165. static readonly TEXTURE_INVCUBIC_MODE: number;
  27166. /** Equirectangular coordinates mode */
  27167. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27168. /** Equirectangular Fixed coordinates mode */
  27169. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27170. /** Equirectangular Fixed Mirrored coordinates mode */
  27171. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27172. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27173. static readonly SCALEMODE_FLOOR: number;
  27174. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27175. static readonly SCALEMODE_NEAREST: number;
  27176. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27177. static readonly SCALEMODE_CEILING: number;
  27178. /**
  27179. * Returns the current version of the framework
  27180. */
  27181. static readonly Version: string;
  27182. /**
  27183. * Returns a string describing the current engine
  27184. */
  27185. readonly description: string;
  27186. /**
  27187. * Gets or sets the epsilon value used by collision engine
  27188. */
  27189. static CollisionsEpsilon: number;
  27190. /**
  27191. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27192. */
  27193. static ShadersRepository: string;
  27194. /**
  27195. * Method called to create the default loading screen.
  27196. * This can be overriden in your own app.
  27197. * @param canvas The rendering canvas element
  27198. * @returns The loading screen
  27199. */
  27200. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27201. /**
  27202. * Method called to create the default rescale post process on each engine.
  27203. */
  27204. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27205. /**
  27206. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27207. */
  27208. forcePOTTextures: boolean;
  27209. /**
  27210. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27211. */
  27212. isFullscreen: boolean;
  27213. /**
  27214. * Gets a boolean indicating if the pointer is currently locked
  27215. */
  27216. isPointerLock: boolean;
  27217. /**
  27218. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27219. */
  27220. cullBackFaces: boolean;
  27221. /**
  27222. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27223. */
  27224. renderEvenInBackground: boolean;
  27225. /**
  27226. * Gets or sets a boolean indicating that cache can be kept between frames
  27227. */
  27228. preventCacheWipeBetweenFrames: boolean;
  27229. /**
  27230. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27231. **/
  27232. enableOfflineSupport: boolean;
  27233. /**
  27234. * 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)
  27235. **/
  27236. disableManifestCheck: boolean;
  27237. /**
  27238. * Gets the list of created scenes
  27239. */
  27240. scenes: Scene[];
  27241. /**
  27242. * Event raised when a new scene is created
  27243. */
  27244. onNewSceneAddedObservable: Observable<Scene>;
  27245. /**
  27246. * Gets the list of created postprocesses
  27247. */
  27248. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27249. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27250. validateShaderPrograms: boolean;
  27251. /**
  27252. * Observable event triggered each time the rendering canvas is resized
  27253. */
  27254. onResizeObservable: Observable<Engine>;
  27255. /**
  27256. * Observable event triggered each time the canvas loses focus
  27257. */
  27258. onCanvasBlurObservable: Observable<Engine>;
  27259. /**
  27260. * Observable event triggered each time the canvas gains focus
  27261. */
  27262. onCanvasFocusObservable: Observable<Engine>;
  27263. /**
  27264. * Observable event triggered each time the canvas receives pointerout event
  27265. */
  27266. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27267. /**
  27268. * Observable event triggered before each texture is initialized
  27269. */
  27270. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27271. private _vrDisplay;
  27272. private _vrSupported;
  27273. private _oldSize;
  27274. private _oldHardwareScaleFactor;
  27275. private _vrExclusivePointerMode;
  27276. private _webVRInitPromise;
  27277. /**
  27278. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27279. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27280. */
  27281. readonly isInVRExclusivePointerMode: boolean;
  27282. /**
  27283. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27284. */
  27285. disableUniformBuffers: boolean;
  27286. /** @hidden */
  27287. _uniformBuffers: UniformBuffer[];
  27288. /**
  27289. * Gets a boolean indicating that the engine supports uniform buffers
  27290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27291. */
  27292. readonly supportsUniformBuffers: boolean;
  27293. /**
  27294. * Observable raised when the engine begins a new frame
  27295. */
  27296. onBeginFrameObservable: Observable<Engine>;
  27297. /**
  27298. * If set, will be used to request the next animation frame for the render loop
  27299. */
  27300. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27301. /**
  27302. * Observable raised when the engine ends the current frame
  27303. */
  27304. onEndFrameObservable: Observable<Engine>;
  27305. /**
  27306. * Observable raised when the engine is about to compile a shader
  27307. */
  27308. onBeforeShaderCompilationObservable: Observable<Engine>;
  27309. /**
  27310. * Observable raised when the engine has jsut compiled a shader
  27311. */
  27312. onAfterShaderCompilationObservable: Observable<Engine>;
  27313. /** @hidden */
  27314. _gl: WebGLRenderingContext;
  27315. private _renderingCanvas;
  27316. private _windowIsBackground;
  27317. private _webGLVersion;
  27318. /**
  27319. * Gets a boolean indicating that only power of 2 textures are supported
  27320. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27321. */
  27322. readonly needPOTTextures: boolean;
  27323. /** @hidden */
  27324. _badOS: boolean;
  27325. /** @hidden */
  27326. _badDesktopOS: boolean;
  27327. /**
  27328. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27329. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27330. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27331. */
  27332. disableTextureBindingOptimization: boolean;
  27333. /**
  27334. * Gets the audio engine
  27335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27336. * @ignorenaming
  27337. */
  27338. static audioEngine: IAudioEngine;
  27339. /**
  27340. * Default AudioEngine factory responsible of creating the Audio Engine.
  27341. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27342. */
  27343. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27344. /**
  27345. * Default offline support factory responsible of creating a tool used to store data locally.
  27346. * By default, this will create a Database object if the workload has been embedded.
  27347. */
  27348. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27349. private _onFocus;
  27350. private _onBlur;
  27351. private _onCanvasPointerOut;
  27352. private _onCanvasBlur;
  27353. private _onCanvasFocus;
  27354. private _onFullscreenChange;
  27355. private _onPointerLockChange;
  27356. private _onVRDisplayPointerRestricted;
  27357. private _onVRDisplayPointerUnrestricted;
  27358. private _onVrDisplayConnect;
  27359. private _onVrDisplayDisconnect;
  27360. private _onVrDisplayPresentChange;
  27361. /**
  27362. * Observable signaled when VR display mode changes
  27363. */
  27364. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27365. /**
  27366. * Observable signaled when VR request present is complete
  27367. */
  27368. onVRRequestPresentComplete: Observable<boolean>;
  27369. /**
  27370. * Observable signaled when VR request present starts
  27371. */
  27372. onVRRequestPresentStart: Observable<Engine>;
  27373. private _hardwareScalingLevel;
  27374. /** @hidden */
  27375. protected _caps: EngineCapabilities;
  27376. private _pointerLockRequested;
  27377. private _isStencilEnable;
  27378. private _colorWrite;
  27379. private _loadingScreen;
  27380. /** @hidden */
  27381. _drawCalls: PerfCounter;
  27382. /** @hidden */
  27383. _textureCollisions: PerfCounter;
  27384. private _glVersion;
  27385. private _glRenderer;
  27386. private _glVendor;
  27387. private _videoTextureSupported;
  27388. private _renderingQueueLaunched;
  27389. private _activeRenderLoops;
  27390. private _deterministicLockstep;
  27391. private _lockstepMaxSteps;
  27392. /**
  27393. * Observable signaled when a context lost event is raised
  27394. */
  27395. onContextLostObservable: Observable<Engine>;
  27396. /**
  27397. * Observable signaled when a context restored event is raised
  27398. */
  27399. onContextRestoredObservable: Observable<Engine>;
  27400. private _onContextLost;
  27401. private _onContextRestored;
  27402. private _contextWasLost;
  27403. private _doNotHandleContextLost;
  27404. /**
  27405. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27407. */
  27408. doNotHandleContextLost: boolean;
  27409. private _performanceMonitor;
  27410. private _fps;
  27411. private _deltaTime;
  27412. /**
  27413. * Turn this value on if you want to pause FPS computation when in background
  27414. */
  27415. disablePerformanceMonitorInBackground: boolean;
  27416. /**
  27417. * Gets the performance monitor attached to this engine
  27418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27419. */
  27420. readonly performanceMonitor: PerformanceMonitor;
  27421. /** @hidden */
  27422. protected _depthCullingState: _DepthCullingState;
  27423. /** @hidden */
  27424. protected _stencilState: _StencilState;
  27425. /** @hidden */
  27426. protected _alphaState: _AlphaState;
  27427. /** @hidden */
  27428. protected _alphaMode: number;
  27429. protected _internalTexturesCache: InternalTexture[];
  27430. /** @hidden */
  27431. protected _activeChannel: number;
  27432. private _currentTextureChannel;
  27433. /** @hidden */
  27434. protected _boundTexturesCache: {
  27435. [key: string]: Nullable<InternalTexture>;
  27436. };
  27437. /** @hidden */
  27438. protected _currentEffect: Nullable<Effect>;
  27439. /** @hidden */
  27440. protected _currentProgram: Nullable<WebGLProgram>;
  27441. private _compiledEffects;
  27442. private _vertexAttribArraysEnabled;
  27443. /** @hidden */
  27444. protected _cachedViewport: Nullable<Viewport>;
  27445. private _cachedVertexArrayObject;
  27446. /** @hidden */
  27447. protected _cachedVertexBuffers: any;
  27448. /** @hidden */
  27449. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27450. /** @hidden */
  27451. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27452. /** @hidden */
  27453. protected _currentRenderTarget: Nullable<InternalTexture>;
  27454. private _uintIndicesCurrentlySet;
  27455. private _currentBoundBuffer;
  27456. /** @hidden */
  27457. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27458. private _currentBufferPointers;
  27459. private _currentInstanceLocations;
  27460. private _currentInstanceBuffers;
  27461. private _textureUnits;
  27462. private _firstBoundInternalTextureTracker;
  27463. private _lastBoundInternalTextureTracker;
  27464. private _workingCanvas;
  27465. private _workingContext;
  27466. private _rescalePostProcess;
  27467. private _dummyFramebuffer;
  27468. private _externalData;
  27469. private _bindedRenderFunction;
  27470. private _vaoRecordInProgress;
  27471. private _mustWipeVertexAttributes;
  27472. private _emptyTexture;
  27473. private _emptyCubeTexture;
  27474. private _emptyTexture3D;
  27475. /** @hidden */
  27476. _frameHandler: number;
  27477. private _nextFreeTextureSlots;
  27478. private _maxSimultaneousTextures;
  27479. private _activeRequests;
  27480. private _texturesSupported;
  27481. private _textureFormatInUse;
  27482. /**
  27483. * Gets the list of texture formats supported
  27484. */
  27485. readonly texturesSupported: Array<string>;
  27486. /**
  27487. * Gets the list of texture formats in use
  27488. */
  27489. readonly textureFormatInUse: Nullable<string>;
  27490. /**
  27491. * Gets the current viewport
  27492. */
  27493. readonly currentViewport: Nullable<Viewport>;
  27494. /**
  27495. * Gets the default empty texture
  27496. */
  27497. readonly emptyTexture: InternalTexture;
  27498. /**
  27499. * Gets the default empty 3D texture
  27500. */
  27501. readonly emptyTexture3D: InternalTexture;
  27502. /**
  27503. * Gets the default empty cube texture
  27504. */
  27505. readonly emptyCubeTexture: InternalTexture;
  27506. /**
  27507. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27508. */
  27509. readonly premultipliedAlpha: boolean;
  27510. /**
  27511. * Creates a new engine
  27512. * @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
  27513. * @param antialias defines enable antialiasing (default: false)
  27514. * @param options defines further options to be sent to the getContext() function
  27515. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27516. */
  27517. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27518. private _disableTouchAction;
  27519. private _rebuildInternalTextures;
  27520. private _rebuildEffects;
  27521. /**
  27522. * Gets a boolean indicating if all created effects are ready
  27523. * @returns true if all effects are ready
  27524. */
  27525. areAllEffectsReady(): boolean;
  27526. private _rebuildBuffers;
  27527. private _initGLContext;
  27528. /**
  27529. * Gets version of the current webGL context
  27530. */
  27531. readonly webGLVersion: number;
  27532. /**
  27533. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27534. */
  27535. readonly isStencilEnable: boolean;
  27536. private _prepareWorkingCanvas;
  27537. /**
  27538. * Reset the texture cache to empty state
  27539. */
  27540. resetTextureCache(): void;
  27541. /**
  27542. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27544. * @returns true if engine is in deterministic lock step mode
  27545. */
  27546. isDeterministicLockStep(): boolean;
  27547. /**
  27548. * Gets the max steps when engine is running in deterministic lock step
  27549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27550. * @returns the max steps
  27551. */
  27552. getLockstepMaxSteps(): number;
  27553. /**
  27554. * Gets an object containing information about the current webGL context
  27555. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27556. */
  27557. getGlInfo(): {
  27558. vendor: string;
  27559. renderer: string;
  27560. version: string;
  27561. };
  27562. /**
  27563. * Gets current aspect ratio
  27564. * @param camera defines the camera to use to get the aspect ratio
  27565. * @param useScreen defines if screen size must be used (or the current render target if any)
  27566. * @returns a number defining the aspect ratio
  27567. */
  27568. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27569. /**
  27570. * Gets current screen aspect ratio
  27571. * @returns a number defining the aspect ratio
  27572. */
  27573. getScreenAspectRatio(): number;
  27574. /**
  27575. * Gets the current render width
  27576. * @param useScreen defines if screen size must be used (or the current render target if any)
  27577. * @returns a number defining the current render width
  27578. */
  27579. getRenderWidth(useScreen?: boolean): number;
  27580. /**
  27581. * Gets the current render height
  27582. * @param useScreen defines if screen size must be used (or the current render target if any)
  27583. * @returns a number defining the current render height
  27584. */
  27585. getRenderHeight(useScreen?: boolean): number;
  27586. /**
  27587. * Gets the HTML canvas attached with the current webGL context
  27588. * @returns a HTML canvas
  27589. */
  27590. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27591. /**
  27592. * Gets the client rect of the HTML canvas attached with the current webGL context
  27593. * @returns a client rectanglee
  27594. */
  27595. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27596. /**
  27597. * Defines the hardware scaling level.
  27598. * By default the hardware scaling level is computed from the window device ratio.
  27599. * 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.
  27600. * @param level defines the level to use
  27601. */
  27602. setHardwareScalingLevel(level: number): void;
  27603. /**
  27604. * Gets the current hardware scaling level.
  27605. * By default the hardware scaling level is computed from the window device ratio.
  27606. * 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.
  27607. * @returns a number indicating the current hardware scaling level
  27608. */
  27609. getHardwareScalingLevel(): number;
  27610. /**
  27611. * Gets the list of loaded textures
  27612. * @returns an array containing all loaded textures
  27613. */
  27614. getLoadedTexturesCache(): InternalTexture[];
  27615. /**
  27616. * Gets the object containing all engine capabilities
  27617. * @returns the EngineCapabilities object
  27618. */
  27619. getCaps(): EngineCapabilities;
  27620. /**
  27621. * Gets the current depth function
  27622. * @returns a number defining the depth function
  27623. */
  27624. getDepthFunction(): Nullable<number>;
  27625. /**
  27626. * Sets the current depth function
  27627. * @param depthFunc defines the function to use
  27628. */
  27629. setDepthFunction(depthFunc: number): void;
  27630. /**
  27631. * Sets the current depth function to GREATER
  27632. */
  27633. setDepthFunctionToGreater(): void;
  27634. /**
  27635. * Sets the current depth function to GEQUAL
  27636. */
  27637. setDepthFunctionToGreaterOrEqual(): void;
  27638. /**
  27639. * Sets the current depth function to LESS
  27640. */
  27641. setDepthFunctionToLess(): void;
  27642. /**
  27643. * Sets the current depth function to LEQUAL
  27644. */
  27645. setDepthFunctionToLessOrEqual(): void;
  27646. /**
  27647. * Gets a boolean indicating if stencil buffer is enabled
  27648. * @returns the current stencil buffer state
  27649. */
  27650. getStencilBuffer(): boolean;
  27651. /**
  27652. * Enable or disable the stencil buffer
  27653. * @param enable defines if the stencil buffer must be enabled or disabled
  27654. */
  27655. setStencilBuffer(enable: boolean): void;
  27656. /**
  27657. * Gets the current stencil mask
  27658. * @returns a number defining the new stencil mask to use
  27659. */
  27660. getStencilMask(): number;
  27661. /**
  27662. * Sets the current stencil mask
  27663. * @param mask defines the new stencil mask to use
  27664. */
  27665. setStencilMask(mask: number): void;
  27666. /**
  27667. * Gets the current stencil function
  27668. * @returns a number defining the stencil function to use
  27669. */
  27670. getStencilFunction(): number;
  27671. /**
  27672. * Gets the current stencil reference value
  27673. * @returns a number defining the stencil reference value to use
  27674. */
  27675. getStencilFunctionReference(): number;
  27676. /**
  27677. * Gets the current stencil mask
  27678. * @returns a number defining the stencil mask to use
  27679. */
  27680. getStencilFunctionMask(): number;
  27681. /**
  27682. * Sets the current stencil function
  27683. * @param stencilFunc defines the new stencil function to use
  27684. */
  27685. setStencilFunction(stencilFunc: number): void;
  27686. /**
  27687. * Sets the current stencil reference
  27688. * @param reference defines the new stencil reference to use
  27689. */
  27690. setStencilFunctionReference(reference: number): void;
  27691. /**
  27692. * Sets the current stencil mask
  27693. * @param mask defines the new stencil mask to use
  27694. */
  27695. setStencilFunctionMask(mask: number): void;
  27696. /**
  27697. * Gets the current stencil operation when stencil fails
  27698. * @returns a number defining stencil operation to use when stencil fails
  27699. */
  27700. getStencilOperationFail(): number;
  27701. /**
  27702. * Gets the current stencil operation when depth fails
  27703. * @returns a number defining stencil operation to use when depth fails
  27704. */
  27705. getStencilOperationDepthFail(): number;
  27706. /**
  27707. * Gets the current stencil operation when stencil passes
  27708. * @returns a number defining stencil operation to use when stencil passes
  27709. */
  27710. getStencilOperationPass(): number;
  27711. /**
  27712. * Sets the stencil operation to use when stencil fails
  27713. * @param operation defines the stencil operation to use when stencil fails
  27714. */
  27715. setStencilOperationFail(operation: number): void;
  27716. /**
  27717. * Sets the stencil operation to use when depth fails
  27718. * @param operation defines the stencil operation to use when depth fails
  27719. */
  27720. setStencilOperationDepthFail(operation: number): void;
  27721. /**
  27722. * Sets the stencil operation to use when stencil passes
  27723. * @param operation defines the stencil operation to use when stencil passes
  27724. */
  27725. setStencilOperationPass(operation: number): void;
  27726. /**
  27727. * Sets a boolean indicating if the dithering state is enabled or disabled
  27728. * @param value defines the dithering state
  27729. */
  27730. setDitheringState(value: boolean): void;
  27731. /**
  27732. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27733. * @param value defines the rasterizer state
  27734. */
  27735. setRasterizerState(value: boolean): void;
  27736. /**
  27737. * stop executing a render loop function and remove it from the execution array
  27738. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27739. */
  27740. stopRenderLoop(renderFunction?: () => void): void;
  27741. /** @hidden */
  27742. _renderLoop(): void;
  27743. /**
  27744. * Register and execute a render loop. The engine can have more than one render function
  27745. * @param renderFunction defines the function to continuously execute
  27746. */
  27747. runRenderLoop(renderFunction: () => void): void;
  27748. /**
  27749. * Toggle full screen mode
  27750. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27751. */
  27752. switchFullscreen(requestPointerLock: boolean): void;
  27753. /**
  27754. * Enters full screen mode
  27755. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27756. */
  27757. enterFullscreen(requestPointerLock: boolean): void;
  27758. /**
  27759. * Exits full screen mode
  27760. */
  27761. exitFullscreen(): void;
  27762. /**
  27763. * Clear the current render buffer or the current render target (if any is set up)
  27764. * @param color defines the color to use
  27765. * @param backBuffer defines if the back buffer must be cleared
  27766. * @param depth defines if the depth buffer must be cleared
  27767. * @param stencil defines if the stencil buffer must be cleared
  27768. */
  27769. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27770. /**
  27771. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27772. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27773. * @param y defines the y-coordinate of the corner of the clear rectangle
  27774. * @param width defines the width of the clear rectangle
  27775. * @param height defines the height of the clear rectangle
  27776. * @param clearColor defines the clear color
  27777. */
  27778. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27779. /**
  27780. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27781. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27782. * @param y defines the y-coordinate of the corner of the clear rectangle
  27783. * @param width defines the width of the clear rectangle
  27784. * @param height defines the height of the clear rectangle
  27785. */
  27786. enableScissor(x: number, y: number, width: number, height: number): void;
  27787. /**
  27788. * Disable previously set scissor test rectangle
  27789. */
  27790. disableScissor(): void;
  27791. private _viewportCached;
  27792. /** @hidden */
  27793. _viewport(x: number, y: number, width: number, height: number): void;
  27794. /**
  27795. * Set the WebGL's viewport
  27796. * @param viewport defines the viewport element to be used
  27797. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27798. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27799. */
  27800. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27801. /**
  27802. * Directly set the WebGL Viewport
  27803. * @param x defines the x coordinate of the viewport (in screen space)
  27804. * @param y defines the y coordinate of the viewport (in screen space)
  27805. * @param width defines the width of the viewport (in screen space)
  27806. * @param height defines the height of the viewport (in screen space)
  27807. * @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
  27808. */
  27809. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27810. /**
  27811. * Begin a new frame
  27812. */
  27813. beginFrame(): void;
  27814. /**
  27815. * Enf the current frame
  27816. */
  27817. endFrame(): void;
  27818. /**
  27819. * Resize the view according to the canvas' size
  27820. */
  27821. resize(): void;
  27822. /**
  27823. * Force a specific size of the canvas
  27824. * @param width defines the new canvas' width
  27825. * @param height defines the new canvas' height
  27826. */
  27827. setSize(width: number, height: number): void;
  27828. /**
  27829. * Gets a boolean indicating if a webVR device was detected
  27830. * @returns true if a webVR device was detected
  27831. */
  27832. isVRDevicePresent(): boolean;
  27833. /**
  27834. * Gets the current webVR device
  27835. * @returns the current webVR device (or null)
  27836. */
  27837. getVRDevice(): any;
  27838. /**
  27839. * Initializes a webVR display and starts listening to display change events
  27840. * The onVRDisplayChangedObservable will be notified upon these changes
  27841. * @returns The onVRDisplayChangedObservable
  27842. */
  27843. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27844. /**
  27845. * Initializes a webVR display and starts listening to display change events
  27846. * The onVRDisplayChangedObservable will be notified upon these changes
  27847. * @returns A promise containing a VRDisplay and if vr is supported
  27848. */
  27849. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27850. /**
  27851. * Call this function to switch to webVR mode
  27852. * Will do nothing if webVR is not supported or if there is no webVR device
  27853. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27854. */
  27855. enableVR(): void;
  27856. /**
  27857. * Call this function to leave webVR mode
  27858. * Will do nothing if webVR is not supported or if there is no webVR device
  27859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27860. */
  27861. disableVR(): void;
  27862. private _onVRFullScreenTriggered;
  27863. private _getVRDisplaysAsync;
  27864. /**
  27865. * Binds the frame buffer to the specified texture.
  27866. * @param texture The texture to render to or null for the default canvas
  27867. * @param faceIndex The face of the texture to render to in case of cube texture
  27868. * @param requiredWidth The width of the target to render to
  27869. * @param requiredHeight The height of the target to render to
  27870. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27871. * @param depthStencilTexture The depth stencil texture to use to render
  27872. * @param lodLevel defines le lod level to bind to the frame buffer
  27873. */
  27874. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27875. private bindUnboundFramebuffer;
  27876. /**
  27877. * Unbind the current render target texture from the webGL context
  27878. * @param texture defines the render target texture to unbind
  27879. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27880. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27881. */
  27882. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27883. /**
  27884. * Unbind a list of render target textures from the webGL context
  27885. * This is used only when drawBuffer extension or webGL2 are active
  27886. * @param textures defines the render target textures to unbind
  27887. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27888. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27889. */
  27890. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27891. /**
  27892. * Force the mipmap generation for the given render target texture
  27893. * @param texture defines the render target texture to use
  27894. */
  27895. generateMipMapsForCubemap(texture: InternalTexture): void;
  27896. /**
  27897. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27898. */
  27899. flushFramebuffer(): void;
  27900. /**
  27901. * Unbind the current render target and bind the default framebuffer
  27902. */
  27903. restoreDefaultFramebuffer(): void;
  27904. /**
  27905. * Create an uniform buffer
  27906. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27907. * @param elements defines the content of the uniform buffer
  27908. * @returns the webGL uniform buffer
  27909. */
  27910. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27911. /**
  27912. * Create a dynamic uniform buffer
  27913. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27914. * @param elements defines the content of the uniform buffer
  27915. * @returns the webGL uniform buffer
  27916. */
  27917. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27918. /**
  27919. * Update an existing uniform buffer
  27920. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27921. * @param uniformBuffer defines the target uniform buffer
  27922. * @param elements defines the content to update
  27923. * @param offset defines the offset in the uniform buffer where update should start
  27924. * @param count defines the size of the data to update
  27925. */
  27926. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27927. private _resetVertexBufferBinding;
  27928. /**
  27929. * Creates a vertex buffer
  27930. * @param data the data for the vertex buffer
  27931. * @returns the new WebGL static buffer
  27932. */
  27933. createVertexBuffer(data: DataArray): WebGLBuffer;
  27934. /**
  27935. * Creates a dynamic vertex buffer
  27936. * @param data the data for the dynamic vertex buffer
  27937. * @returns the new WebGL dynamic buffer
  27938. */
  27939. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27940. /**
  27941. * Update a dynamic index buffer
  27942. * @param indexBuffer defines the target index buffer
  27943. * @param indices defines the data to update
  27944. * @param offset defines the offset in the target index buffer where update should start
  27945. */
  27946. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27947. /**
  27948. * Updates a dynamic vertex buffer.
  27949. * @param vertexBuffer the vertex buffer to update
  27950. * @param data the data used to update the vertex buffer
  27951. * @param byteOffset the byte offset of the data
  27952. * @param byteLength the byte length of the data
  27953. */
  27954. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27955. private _resetIndexBufferBinding;
  27956. /**
  27957. * Creates a new index buffer
  27958. * @param indices defines the content of the index buffer
  27959. * @param updatable defines if the index buffer must be updatable
  27960. * @returns a new webGL buffer
  27961. */
  27962. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27963. /**
  27964. * Bind a webGL buffer to the webGL context
  27965. * @param buffer defines the buffer to bind
  27966. */
  27967. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27968. /**
  27969. * Bind an uniform buffer to the current webGL context
  27970. * @param buffer defines the buffer to bind
  27971. */
  27972. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27973. /**
  27974. * Bind a buffer to the current webGL context at a given location
  27975. * @param buffer defines the buffer to bind
  27976. * @param location defines the index where to bind the buffer
  27977. */
  27978. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27979. /**
  27980. * Bind a specific block at a given index in a specific shader program
  27981. * @param shaderProgram defines the shader program
  27982. * @param blockName defines the block name
  27983. * @param index defines the index where to bind the block
  27984. */
  27985. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27986. private bindIndexBuffer;
  27987. private bindBuffer;
  27988. /**
  27989. * update the bound buffer with the given data
  27990. * @param data defines the data to update
  27991. */
  27992. updateArrayBuffer(data: Float32Array): void;
  27993. private _vertexAttribPointer;
  27994. private _bindIndexBufferWithCache;
  27995. private _bindVertexBuffersAttributes;
  27996. /**
  27997. * Records a vertex array object
  27998. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27999. * @param vertexBuffers defines the list of vertex buffers to store
  28000. * @param indexBuffer defines the index buffer to store
  28001. * @param effect defines the effect to store
  28002. * @returns the new vertex array object
  28003. */
  28004. recordVertexArrayObject(vertexBuffers: {
  28005. [key: string]: VertexBuffer;
  28006. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28007. /**
  28008. * Bind a specific vertex array object
  28009. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28010. * @param vertexArrayObject defines the vertex array object to bind
  28011. * @param indexBuffer defines the index buffer to bind
  28012. */
  28013. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28014. /**
  28015. * Bind webGl buffers directly to the webGL context
  28016. * @param vertexBuffer defines the vertex buffer to bind
  28017. * @param indexBuffer defines the index buffer to bind
  28018. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28019. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28020. * @param effect defines the effect associated with the vertex buffer
  28021. */
  28022. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28023. private _unbindVertexArrayObject;
  28024. /**
  28025. * Bind a list of vertex buffers to the webGL context
  28026. * @param vertexBuffers defines the list of vertex buffers to bind
  28027. * @param indexBuffer defines the index buffer to bind
  28028. * @param effect defines the effect associated with the vertex buffers
  28029. */
  28030. bindBuffers(vertexBuffers: {
  28031. [key: string]: Nullable<VertexBuffer>;
  28032. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28033. /**
  28034. * Unbind all instance attributes
  28035. */
  28036. unbindInstanceAttributes(): void;
  28037. /**
  28038. * Release and free the memory of a vertex array object
  28039. * @param vao defines the vertex array object to delete
  28040. */
  28041. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28042. /** @hidden */
  28043. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28044. /**
  28045. * Creates a webGL buffer to use with instanciation
  28046. * @param capacity defines the size of the buffer
  28047. * @returns the webGL buffer
  28048. */
  28049. createInstancesBuffer(capacity: number): WebGLBuffer;
  28050. /**
  28051. * Delete a webGL buffer used with instanciation
  28052. * @param buffer defines the webGL buffer to delete
  28053. */
  28054. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28055. /**
  28056. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28057. * @param instancesBuffer defines the webGL buffer to update and bind
  28058. * @param data defines the data to store in the buffer
  28059. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28060. */
  28061. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28062. /**
  28063. * Apply all cached states (depth, culling, stencil and alpha)
  28064. */
  28065. applyStates(): void;
  28066. /**
  28067. * Send a draw order
  28068. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28069. * @param indexStart defines the starting index
  28070. * @param indexCount defines the number of index to draw
  28071. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28072. */
  28073. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28074. /**
  28075. * Draw a list of points
  28076. * @param verticesStart defines the index of first vertex to draw
  28077. * @param verticesCount defines the count of vertices to draw
  28078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28079. */
  28080. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28081. /**
  28082. * Draw a list of unindexed primitives
  28083. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28084. * @param verticesStart defines the index of first vertex to draw
  28085. * @param verticesCount defines the count of vertices to draw
  28086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28087. */
  28088. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28089. /**
  28090. * Draw a list of indexed primitives
  28091. * @param fillMode defines the primitive to use
  28092. * @param indexStart defines the starting index
  28093. * @param indexCount defines the number of index to draw
  28094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28095. */
  28096. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28097. /**
  28098. * Draw a list of unindexed primitives
  28099. * @param fillMode defines the primitive to use
  28100. * @param verticesStart defines the index of first vertex to draw
  28101. * @param verticesCount defines the count of vertices to draw
  28102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28103. */
  28104. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28105. private _drawMode;
  28106. /** @hidden */
  28107. _releaseEffect(effect: Effect): void;
  28108. /** @hidden */
  28109. _deleteProgram(program: WebGLProgram): void;
  28110. /**
  28111. * Create a new effect (used to store vertex/fragment shaders)
  28112. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28113. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28114. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28115. * @param samplers defines an array of string used to represent textures
  28116. * @param defines defines the string containing the defines to use to compile the shaders
  28117. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28118. * @param onCompiled defines a function to call when the effect creation is successful
  28119. * @param onError defines a function to call when the effect creation has failed
  28120. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28121. * @returns the new Effect
  28122. */
  28123. 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;
  28124. private _compileShader;
  28125. private _compileRawShader;
  28126. /**
  28127. * Directly creates a webGL program
  28128. * @param vertexCode defines the vertex shader code to use
  28129. * @param fragmentCode defines the fragment shader code to use
  28130. * @param context defines the webGL context to use (if not set, the current one will be used)
  28131. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28132. * @returns the new webGL program
  28133. */
  28134. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28135. /**
  28136. * Creates a webGL program
  28137. * @param vertexCode defines the vertex shader code to use
  28138. * @param fragmentCode defines the fragment shader code to use
  28139. * @param defines defines the string containing the defines to use to compile the shaders
  28140. * @param context defines the webGL context to use (if not set, the current one will be used)
  28141. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28142. * @returns the new webGL program
  28143. */
  28144. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28145. private _createShaderProgram;
  28146. private _finalizeProgram;
  28147. /** @hidden */
  28148. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28149. /** @hidden */
  28150. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28151. /**
  28152. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28153. * @param shaderProgram defines the webGL program to use
  28154. * @param uniformsNames defines the list of uniform names
  28155. * @returns an array of webGL uniform locations
  28156. */
  28157. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28158. /**
  28159. * Gets the lsit of active attributes for a given webGL program
  28160. * @param shaderProgram defines the webGL program to use
  28161. * @param attributesNames defines the list of attribute names to get
  28162. * @returns an array of indices indicating the offset of each attribute
  28163. */
  28164. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28165. /**
  28166. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28167. * @param effect defines the effect to activate
  28168. */
  28169. enableEffect(effect: Nullable<Effect>): void;
  28170. /**
  28171. * Set the value of an uniform to an array of int32
  28172. * @param uniform defines the webGL uniform location where to store the value
  28173. * @param array defines the array of int32 to store
  28174. */
  28175. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28176. /**
  28177. * Set the value of an uniform to an array of int32 (stored as vec2)
  28178. * @param uniform defines the webGL uniform location where to store the value
  28179. * @param array defines the array of int32 to store
  28180. */
  28181. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28182. /**
  28183. * Set the value of an uniform to an array of int32 (stored as vec3)
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param array defines the array of int32 to store
  28186. */
  28187. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28188. /**
  28189. * Set the value of an uniform to an array of int32 (stored as vec4)
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param array defines the array of int32 to store
  28192. */
  28193. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28194. /**
  28195. * Set the value of an uniform to an array of float32
  28196. * @param uniform defines the webGL uniform location where to store the value
  28197. * @param array defines the array of float32 to store
  28198. */
  28199. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28200. /**
  28201. * Set the value of an uniform to an array of float32 (stored as vec2)
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param array defines the array of float32 to store
  28204. */
  28205. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28206. /**
  28207. * Set the value of an uniform to an array of float32 (stored as vec3)
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param array defines the array of float32 to store
  28210. */
  28211. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28212. /**
  28213. * Set the value of an uniform to an array of float32 (stored as vec4)
  28214. * @param uniform defines the webGL uniform location where to store the value
  28215. * @param array defines the array of float32 to store
  28216. */
  28217. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28218. /**
  28219. * Set the value of an uniform to an array of number
  28220. * @param uniform defines the webGL uniform location where to store the value
  28221. * @param array defines the array of number to store
  28222. */
  28223. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28224. /**
  28225. * Set the value of an uniform to an array of number (stored as vec2)
  28226. * @param uniform defines the webGL uniform location where to store the value
  28227. * @param array defines the array of number to store
  28228. */
  28229. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28230. /**
  28231. * Set the value of an uniform to an array of number (stored as vec3)
  28232. * @param uniform defines the webGL uniform location where to store the value
  28233. * @param array defines the array of number to store
  28234. */
  28235. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28236. /**
  28237. * Set the value of an uniform to an array of number (stored as vec4)
  28238. * @param uniform defines the webGL uniform location where to store the value
  28239. * @param array defines the array of number to store
  28240. */
  28241. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28242. /**
  28243. * Set the value of an uniform to an array of float32 (stored as matrices)
  28244. * @param uniform defines the webGL uniform location where to store the value
  28245. * @param matrices defines the array of float32 to store
  28246. */
  28247. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28248. /**
  28249. * Set the value of an uniform to a matrix
  28250. * @param uniform defines the webGL uniform location where to store the value
  28251. * @param matrix defines the matrix to store
  28252. */
  28253. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28254. /**
  28255. * Set the value of an uniform to a matrix (3x3)
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28258. */
  28259. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28260. /**
  28261. * Set the value of an uniform to a matrix (2x2)
  28262. * @param uniform defines the webGL uniform location where to store the value
  28263. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28264. */
  28265. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28266. /**
  28267. * Set the value of an uniform to a number (int)
  28268. * @param uniform defines the webGL uniform location where to store the value
  28269. * @param value defines the int number to store
  28270. */
  28271. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28272. /**
  28273. * Set the value of an uniform to a number (float)
  28274. * @param uniform defines the webGL uniform location where to store the value
  28275. * @param value defines the float number to store
  28276. */
  28277. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28278. /**
  28279. * Set the value of an uniform to a vec2
  28280. * @param uniform defines the webGL uniform location where to store the value
  28281. * @param x defines the 1st component of the value
  28282. * @param y defines the 2nd component of the value
  28283. */
  28284. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28285. /**
  28286. * Set the value of an uniform to a vec3
  28287. * @param uniform defines the webGL uniform location where to store the value
  28288. * @param x defines the 1st component of the value
  28289. * @param y defines the 2nd component of the value
  28290. * @param z defines the 3rd component of the value
  28291. */
  28292. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28293. /**
  28294. * Set the value of an uniform to a boolean
  28295. * @param uniform defines the webGL uniform location where to store the value
  28296. * @param bool defines the boolean to store
  28297. */
  28298. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28299. /**
  28300. * Set the value of an uniform to a vec4
  28301. * @param uniform defines the webGL uniform location where to store the value
  28302. * @param x defines the 1st component of the value
  28303. * @param y defines the 2nd component of the value
  28304. * @param z defines the 3rd component of the value
  28305. * @param w defines the 4th component of the value
  28306. */
  28307. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28308. /**
  28309. * Set the value of an uniform to a Color3
  28310. * @param uniform defines the webGL uniform location where to store the value
  28311. * @param color3 defines the color to store
  28312. */
  28313. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28314. /**
  28315. * Set the value of an uniform to a Color3 and an alpha value
  28316. * @param uniform defines the webGL uniform location where to store the value
  28317. * @param color3 defines the color to store
  28318. * @param alpha defines the alpha component to store
  28319. */
  28320. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28321. /**
  28322. * Sets a Color4 on a uniform variable
  28323. * @param uniform defines the uniform location
  28324. * @param color4 defines the value to be set
  28325. */
  28326. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28327. /**
  28328. * Set various states to the webGL context
  28329. * @param culling defines backface culling state
  28330. * @param zOffset defines the value to apply to zOffset (0 by default)
  28331. * @param force defines if states must be applied even if cache is up to date
  28332. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28333. */
  28334. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28335. /**
  28336. * Set the z offset to apply to current rendering
  28337. * @param value defines the offset to apply
  28338. */
  28339. setZOffset(value: number): void;
  28340. /**
  28341. * Gets the current value of the zOffset
  28342. * @returns the current zOffset state
  28343. */
  28344. getZOffset(): number;
  28345. /**
  28346. * Enable or disable depth buffering
  28347. * @param enable defines the state to set
  28348. */
  28349. setDepthBuffer(enable: boolean): void;
  28350. /**
  28351. * Gets a boolean indicating if depth writing is enabled
  28352. * @returns the current depth writing state
  28353. */
  28354. getDepthWrite(): boolean;
  28355. /**
  28356. * Enable or disable depth writing
  28357. * @param enable defines the state to set
  28358. */
  28359. setDepthWrite(enable: boolean): void;
  28360. /**
  28361. * Enable or disable color writing
  28362. * @param enable defines the state to set
  28363. */
  28364. setColorWrite(enable: boolean): void;
  28365. /**
  28366. * Gets a boolean indicating if color writing is enabled
  28367. * @returns the current color writing state
  28368. */
  28369. getColorWrite(): boolean;
  28370. /**
  28371. * Sets alpha constants used by some alpha blending modes
  28372. * @param r defines the red component
  28373. * @param g defines the green component
  28374. * @param b defines the blue component
  28375. * @param a defines the alpha component
  28376. */
  28377. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28378. /**
  28379. * Sets the current alpha mode
  28380. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28381. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28382. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28383. */
  28384. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28385. /**
  28386. * Gets the current alpha mode
  28387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28388. * @returns the current alpha mode
  28389. */
  28390. getAlphaMode(): number;
  28391. /**
  28392. * Clears the list of texture accessible through engine.
  28393. * This can help preventing texture load conflict due to name collision.
  28394. */
  28395. clearInternalTexturesCache(): void;
  28396. /**
  28397. * Force the entire cache to be cleared
  28398. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28399. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28400. */
  28401. wipeCaches(bruteForce?: boolean): void;
  28402. /**
  28403. * Set the compressed texture format to use, based on the formats you have, and the formats
  28404. * supported by the hardware / browser.
  28405. *
  28406. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28407. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28408. * to API arguments needed to compressed textures. This puts the burden on the container
  28409. * generator to house the arcane code for determining these for current & future formats.
  28410. *
  28411. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28412. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28413. *
  28414. * Note: The result of this call is not taken into account when a texture is base64.
  28415. *
  28416. * @param formatsAvailable defines the list of those format families you have created
  28417. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28418. *
  28419. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28420. * @returns The extension selected.
  28421. */
  28422. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28423. private _getSamplingParameters;
  28424. private _partialLoadImg;
  28425. private _cascadeLoadImgs;
  28426. /** @hidden */
  28427. _createTexture(): WebGLTexture;
  28428. /**
  28429. * Usually called from Texture.ts.
  28430. * Passed information to create a WebGLTexture
  28431. * @param urlArg defines a value which contains one of the following:
  28432. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28433. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28434. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28436. * @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)
  28437. * @param scene needed for loading to the correct scene
  28438. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28439. * @param onLoad optional callback to be called upon successful completion
  28440. * @param onError optional callback to be called upon failure
  28441. * @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
  28442. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28443. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28444. * @param forcedExtension defines the extension to use to pick the right loader
  28445. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28446. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28447. */
  28448. 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;
  28449. private _rescaleTexture;
  28450. /**
  28451. * Update a raw texture
  28452. * @param texture defines the texture to update
  28453. * @param data defines the data to store in the texture
  28454. * @param format defines the format of the data
  28455. * @param invertY defines if data must be stored with Y axis inverted
  28456. * @param compression defines the compression used (null by default)
  28457. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28458. */
  28459. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28460. /**
  28461. * Creates a raw texture
  28462. * @param data defines the data to store in the texture
  28463. * @param width defines the width of the texture
  28464. * @param height defines the height of the texture
  28465. * @param format defines the format of the data
  28466. * @param generateMipMaps defines if the engine should generate the mip levels
  28467. * @param invertY defines if data must be stored with Y axis inverted
  28468. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28469. * @param compression defines the compression used (null by default)
  28470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28471. * @returns the raw texture inside an InternalTexture
  28472. */
  28473. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28474. private _unpackFlipYCached;
  28475. /**
  28476. * In case you are sharing the context with other applications, it might
  28477. * be interested to not cache the unpack flip y state to ensure a consistent
  28478. * value would be set.
  28479. */
  28480. enableUnpackFlipYCached: boolean;
  28481. /** @hidden */
  28482. _unpackFlipY(value: boolean): void;
  28483. /** @hidden */
  28484. _getUnpackAlignement(): number;
  28485. /**
  28486. * Creates a dynamic texture
  28487. * @param width defines the width of the texture
  28488. * @param height defines the height of the texture
  28489. * @param generateMipMaps defines if the engine should generate the mip levels
  28490. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28491. * @returns the dynamic texture inside an InternalTexture
  28492. */
  28493. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28494. /**
  28495. * Update the sampling mode of a given texture
  28496. * @param samplingMode defines the required sampling mode
  28497. * @param texture defines the texture to update
  28498. */
  28499. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28500. /**
  28501. * Update the content of a dynamic texture
  28502. * @param texture defines the texture to update
  28503. * @param canvas defines the canvas containing the source
  28504. * @param invertY defines if data must be stored with Y axis inverted
  28505. * @param premulAlpha defines if alpha is stored as premultiplied
  28506. * @param format defines the format of the data
  28507. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28508. */
  28509. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28510. /**
  28511. * Update a video texture
  28512. * @param texture defines the texture to update
  28513. * @param video defines the video element to use
  28514. * @param invertY defines if data must be stored with Y axis inverted
  28515. */
  28516. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28517. /**
  28518. * Updates a depth texture Comparison Mode and Function.
  28519. * If the comparison Function is equal to 0, the mode will be set to none.
  28520. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28521. * @param texture The texture to set the comparison function for
  28522. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28523. */
  28524. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28525. private _setupDepthStencilTexture;
  28526. /**
  28527. * Creates a depth stencil texture.
  28528. * This is only available in WebGL 2 or with the depth texture extension available.
  28529. * @param size The size of face edge in the texture.
  28530. * @param options The options defining the texture.
  28531. * @returns The texture
  28532. */
  28533. createDepthStencilTexture(size: number | {
  28534. width: number;
  28535. height: number;
  28536. }, options: DepthTextureCreationOptions): InternalTexture;
  28537. /**
  28538. * Creates a depth stencil texture.
  28539. * This is only available in WebGL 2 or with the depth texture extension available.
  28540. * @param size The size of face edge in the texture.
  28541. * @param options The options defining the texture.
  28542. * @returns The texture
  28543. */
  28544. private _createDepthStencilTexture;
  28545. /**
  28546. * Creates a depth stencil cube texture.
  28547. * This is only available in WebGL 2.
  28548. * @param size The size of face edge in the cube texture.
  28549. * @param options The options defining the cube texture.
  28550. * @returns The cube texture
  28551. */
  28552. private _createDepthStencilCubeTexture;
  28553. /**
  28554. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28555. * @param renderTarget The render target to set the frame buffer for
  28556. */
  28557. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28558. /**
  28559. * Creates a new render target texture
  28560. * @param size defines the size of the texture
  28561. * @param options defines the options used to create the texture
  28562. * @returns a new render target texture stored in an InternalTexture
  28563. */
  28564. createRenderTargetTexture(size: number | {
  28565. width: number;
  28566. height: number;
  28567. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28568. /**
  28569. * Create a multi render target texture
  28570. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28571. * @param size defines the size of the texture
  28572. * @param options defines the creation options
  28573. * @returns the cube texture as an InternalTexture
  28574. */
  28575. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28576. private _setupFramebufferDepthAttachments;
  28577. /**
  28578. * Updates the sample count of a render target texture
  28579. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28580. * @param texture defines the texture to update
  28581. * @param samples defines the sample count to set
  28582. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28583. */
  28584. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28585. /**
  28586. * Update the sample count for a given multiple render target texture
  28587. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28588. * @param textures defines the textures to update
  28589. * @param samples defines the sample count to set
  28590. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28591. */
  28592. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28593. /** @hidden */
  28594. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28595. /** @hidden */
  28596. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28597. /** @hidden */
  28598. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28599. /** @hidden */
  28600. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28601. /**
  28602. * Creates a new render target cube texture
  28603. * @param size defines the size of the texture
  28604. * @param options defines the options used to create the texture
  28605. * @returns a new render target cube texture stored in an InternalTexture
  28606. */
  28607. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28608. /**
  28609. * Creates a cube texture
  28610. * @param rootUrl defines the url where the files to load is located
  28611. * @param scene defines the current scene
  28612. * @param files defines the list of files to load (1 per face)
  28613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28614. * @param onLoad defines an optional callback raised when the texture is loaded
  28615. * @param onError defines an optional callback raised if there is an issue to load the texture
  28616. * @param format defines the format of the data
  28617. * @param forcedExtension defines the extension to use to pick the right loader
  28618. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28619. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28620. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28621. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28622. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28623. * @returns the cube texture as an InternalTexture
  28624. */
  28625. 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;
  28626. /**
  28627. * @hidden
  28628. */
  28629. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28630. /**
  28631. * Update a raw cube texture
  28632. * @param texture defines the texture to udpdate
  28633. * @param data defines the data to store
  28634. * @param format defines the data format
  28635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28636. * @param invertY defines if data must be stored with Y axis inverted
  28637. * @param compression defines the compression used (null by default)
  28638. * @param level defines which level of the texture to update
  28639. */
  28640. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28641. /**
  28642. * Creates a new raw cube texture
  28643. * @param data defines the array of data to use to create each face
  28644. * @param size defines the size of the textures
  28645. * @param format defines the format of the data
  28646. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28647. * @param generateMipMaps defines if the engine should generate the mip levels
  28648. * @param invertY defines if data must be stored with Y axis inverted
  28649. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28650. * @param compression defines the compression used (null by default)
  28651. * @returns the cube texture as an InternalTexture
  28652. */
  28653. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28654. /**
  28655. * Creates a new raw cube texture from a specified url
  28656. * @param url defines the url where the data is located
  28657. * @param scene defines the current scene
  28658. * @param size defines the size of the textures
  28659. * @param format defines the format of the data
  28660. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28661. * @param noMipmap defines if the engine should avoid generating the mip levels
  28662. * @param callback defines a callback used to extract texture data from loaded data
  28663. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28664. * @param onLoad defines a callback called when texture is loaded
  28665. * @param onError defines a callback called if there is an error
  28666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28667. * @param invertY defines if data must be stored with Y axis inverted
  28668. * @returns the cube texture as an InternalTexture
  28669. */
  28670. 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;
  28671. /**
  28672. * Update a raw 3D texture
  28673. * @param texture defines the texture to update
  28674. * @param data defines the data to store
  28675. * @param format defines the data format
  28676. * @param invertY defines if data must be stored with Y axis inverted
  28677. * @param compression defines the used compression (can be null)
  28678. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28679. */
  28680. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28681. /**
  28682. * Creates a new raw 3D texture
  28683. * @param data defines the data used to create the texture
  28684. * @param width defines the width of the texture
  28685. * @param height defines the height of the texture
  28686. * @param depth defines the depth of the texture
  28687. * @param format defines the format of the texture
  28688. * @param generateMipMaps defines if the engine must generate mip levels
  28689. * @param invertY defines if data must be stored with Y axis inverted
  28690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28691. * @param compression defines the compressed used (can be null)
  28692. * @param textureType defines the compressed used (can be null)
  28693. * @returns a new raw 3D texture (stored in an InternalTexture)
  28694. */
  28695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28696. private _prepareWebGLTextureContinuation;
  28697. private _prepareWebGLTexture;
  28698. private _convertRGBtoRGBATextureData;
  28699. /** @hidden */
  28700. _releaseFramebufferObjects(texture: InternalTexture): void;
  28701. /** @hidden */
  28702. _releaseTexture(texture: InternalTexture): void;
  28703. private setProgram;
  28704. private _boundUniforms;
  28705. /**
  28706. * Binds an effect to the webGL context
  28707. * @param effect defines the effect to bind
  28708. */
  28709. bindSamplers(effect: Effect): void;
  28710. private _moveBoundTextureOnTop;
  28711. private _getCorrectTextureChannel;
  28712. private _linkTrackers;
  28713. private _removeDesignatedSlot;
  28714. private _activateCurrentTexture;
  28715. /** @hidden */
  28716. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28717. /** @hidden */
  28718. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28719. /**
  28720. * Sets a texture to the webGL context from a postprocess
  28721. * @param channel defines the channel to use
  28722. * @param postProcess defines the source postprocess
  28723. */
  28724. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28725. /**
  28726. * Binds the output of the passed in post process to the texture channel specified
  28727. * @param channel The channel the texture should be bound to
  28728. * @param postProcess The post process which's output should be bound
  28729. */
  28730. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28731. /**
  28732. * Unbind all textures from the webGL context
  28733. */
  28734. unbindAllTextures(): void;
  28735. /**
  28736. * Sets a texture to the according uniform.
  28737. * @param channel The texture channel
  28738. * @param uniform The uniform to set
  28739. * @param texture The texture to apply
  28740. */
  28741. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28742. /**
  28743. * Sets a depth stencil texture from a render target to the according uniform.
  28744. * @param channel The texture channel
  28745. * @param uniform The uniform to set
  28746. * @param texture The render target texture containing the depth stencil texture to apply
  28747. */
  28748. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28749. private _bindSamplerUniformToChannel;
  28750. private _getTextureWrapMode;
  28751. private _setTexture;
  28752. /**
  28753. * Sets an array of texture to the webGL context
  28754. * @param channel defines the channel where the texture array must be set
  28755. * @param uniform defines the associated uniform location
  28756. * @param textures defines the array of textures to bind
  28757. */
  28758. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28759. /** @hidden */
  28760. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28761. private _setTextureParameterFloat;
  28762. private _setTextureParameterInteger;
  28763. /**
  28764. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28765. * @param x defines the x coordinate of the rectangle where pixels must be read
  28766. * @param y defines the y coordinate of the rectangle where pixels must be read
  28767. * @param width defines the width of the rectangle where pixels must be read
  28768. * @param height defines the height of the rectangle where pixels must be read
  28769. * @returns a Uint8Array containing RGBA colors
  28770. */
  28771. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28772. /**
  28773. * Add an externaly attached data from its key.
  28774. * This method call will fail and return false, if such key already exists.
  28775. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28776. * @param key the unique key that identifies the data
  28777. * @param data the data object to associate to the key for this Engine instance
  28778. * @return true if no such key were already present and the data was added successfully, false otherwise
  28779. */
  28780. addExternalData<T>(key: string, data: T): boolean;
  28781. /**
  28782. * Get an externaly attached data from its key
  28783. * @param key the unique key that identifies the data
  28784. * @return the associated data, if present (can be null), or undefined if not present
  28785. */
  28786. getExternalData<T>(key: string): T;
  28787. /**
  28788. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28789. * @param key the unique key that identifies the data
  28790. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28791. * @return the associated data, can be null if the factory returned null.
  28792. */
  28793. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28794. /**
  28795. * Remove an externaly attached data from the Engine instance
  28796. * @param key the unique key that identifies the data
  28797. * @return true if the data was successfully removed, false if it doesn't exist
  28798. */
  28799. removeExternalData(key: string): boolean;
  28800. /**
  28801. * Unbind all vertex attributes from the webGL context
  28802. */
  28803. unbindAllAttributes(): void;
  28804. /**
  28805. * 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
  28806. */
  28807. releaseEffects(): void;
  28808. /**
  28809. * Dispose and release all associated resources
  28810. */
  28811. dispose(): void;
  28812. /**
  28813. * Display the loading screen
  28814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28815. */
  28816. displayLoadingUI(): void;
  28817. /**
  28818. * Hide the loading screen
  28819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28820. */
  28821. hideLoadingUI(): void;
  28822. /**
  28823. * Gets the current loading screen object
  28824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28825. */
  28826. /**
  28827. * Sets the current loading screen object
  28828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28829. */
  28830. loadingScreen: ILoadingScreen;
  28831. /**
  28832. * Sets the current loading screen text
  28833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28834. */
  28835. loadingUIText: string;
  28836. /**
  28837. * Sets the current loading screen background color
  28838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28839. */
  28840. loadingUIBackgroundColor: string;
  28841. /**
  28842. * Attach a new callback raised when context lost event is fired
  28843. * @param callback defines the callback to call
  28844. */
  28845. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28846. /**
  28847. * Attach a new callback raised when context restored event is fired
  28848. * @param callback defines the callback to call
  28849. */
  28850. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28851. /**
  28852. * Gets the source code of the vertex shader associated with a specific webGL program
  28853. * @param program defines the program to use
  28854. * @returns a string containing the source code of the vertex shader associated with the program
  28855. */
  28856. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28857. /**
  28858. * Gets the source code of the fragment shader associated with a specific webGL program
  28859. * @param program defines the program to use
  28860. * @returns a string containing the source code of the fragment shader associated with the program
  28861. */
  28862. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28863. /**
  28864. * Get the current error code of the webGL context
  28865. * @returns the error code
  28866. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28867. */
  28868. getError(): number;
  28869. /**
  28870. * Gets the current framerate
  28871. * @returns a number representing the framerate
  28872. */
  28873. getFps(): number;
  28874. /**
  28875. * Gets the time spent between current and previous frame
  28876. * @returns a number representing the delta time in ms
  28877. */
  28878. getDeltaTime(): number;
  28879. private _measureFps;
  28880. /** @hidden */
  28881. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28882. private _canRenderToFloatFramebuffer;
  28883. private _canRenderToHalfFloatFramebuffer;
  28884. private _canRenderToFramebuffer;
  28885. /** @hidden */
  28886. _getWebGLTextureType(type: number): number;
  28887. private _getInternalFormat;
  28888. /** @hidden */
  28889. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28890. /** @hidden */
  28891. _getRGBAMultiSampleBufferFormat(type: number): number;
  28892. /** @hidden */
  28893. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28894. /** @hidden */
  28895. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28896. private _partialLoadFile;
  28897. private _cascadeLoadFiles;
  28898. /**
  28899. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28900. * @returns true if the engine can be created
  28901. * @ignorenaming
  28902. */
  28903. static isSupported(): boolean;
  28904. }
  28905. }
  28906. declare module "babylonjs/Materials/effect" {
  28907. import { Observable } from "babylonjs/Misc/observable";
  28908. import { Nullable } from "babylonjs/types";
  28909. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28910. import { Engine } from "babylonjs/Engines/engine";
  28911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28913. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28914. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28916. /**
  28917. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28918. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28919. */
  28920. export class EffectFallbacks {
  28921. private _defines;
  28922. private _currentRank;
  28923. private _maxRank;
  28924. private _mesh;
  28925. /**
  28926. * Removes the fallback from the bound mesh.
  28927. */
  28928. unBindMesh(): void;
  28929. /**
  28930. * Adds a fallback on the specified property.
  28931. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28932. * @param define The name of the define in the shader
  28933. */
  28934. addFallback(rank: number, define: string): void;
  28935. /**
  28936. * Sets the mesh to use CPU skinning when needing to fallback.
  28937. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28938. * @param mesh The mesh to use the fallbacks.
  28939. */
  28940. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28941. /**
  28942. * Checks to see if more fallbacks are still availible.
  28943. */
  28944. readonly isMoreFallbacks: boolean;
  28945. /**
  28946. * Removes the defines that shoould be removed when falling back.
  28947. * @param currentDefines defines the current define statements for the shader.
  28948. * @param effect defines the current effect we try to compile
  28949. * @returns The resulting defines with defines of the current rank removed.
  28950. */
  28951. reduce(currentDefines: string, effect: Effect): string;
  28952. }
  28953. /**
  28954. * Options to be used when creating an effect.
  28955. */
  28956. export class EffectCreationOptions {
  28957. /**
  28958. * Atrributes that will be used in the shader.
  28959. */
  28960. attributes: string[];
  28961. /**
  28962. * Uniform varible names that will be set in the shader.
  28963. */
  28964. uniformsNames: string[];
  28965. /**
  28966. * Uniform buffer varible names that will be set in the shader.
  28967. */
  28968. uniformBuffersNames: string[];
  28969. /**
  28970. * Sampler texture variable names that will be set in the shader.
  28971. */
  28972. samplers: string[];
  28973. /**
  28974. * Define statements that will be set in the shader.
  28975. */
  28976. defines: any;
  28977. /**
  28978. * Possible fallbacks for this effect to improve performance when needed.
  28979. */
  28980. fallbacks: Nullable<EffectFallbacks>;
  28981. /**
  28982. * Callback that will be called when the shader is compiled.
  28983. */
  28984. onCompiled: Nullable<(effect: Effect) => void>;
  28985. /**
  28986. * Callback that will be called if an error occurs during shader compilation.
  28987. */
  28988. onError: Nullable<(effect: Effect, errors: string) => void>;
  28989. /**
  28990. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28991. */
  28992. indexParameters: any;
  28993. /**
  28994. * Max number of lights that can be used in the shader.
  28995. */
  28996. maxSimultaneousLights: number;
  28997. /**
  28998. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28999. */
  29000. transformFeedbackVaryings: Nullable<string[]>;
  29001. }
  29002. /**
  29003. * Effect containing vertex and fragment shader that can be executed on an object.
  29004. */
  29005. export class Effect {
  29006. /**
  29007. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29008. */
  29009. static ShadersRepository: string;
  29010. /**
  29011. * Name of the effect.
  29012. */
  29013. name: any;
  29014. /**
  29015. * String container all the define statements that should be set on the shader.
  29016. */
  29017. defines: string;
  29018. /**
  29019. * Callback that will be called when the shader is compiled.
  29020. */
  29021. onCompiled: Nullable<(effect: Effect) => void>;
  29022. /**
  29023. * Callback that will be called if an error occurs during shader compilation.
  29024. */
  29025. onError: Nullable<(effect: Effect, errors: string) => void>;
  29026. /**
  29027. * Callback that will be called when effect is bound.
  29028. */
  29029. onBind: Nullable<(effect: Effect) => void>;
  29030. /**
  29031. * Unique ID of the effect.
  29032. */
  29033. uniqueId: number;
  29034. /**
  29035. * Observable that will be called when the shader is compiled.
  29036. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29037. */
  29038. onCompileObservable: Observable<Effect>;
  29039. /**
  29040. * Observable that will be called if an error occurs during shader compilation.
  29041. */
  29042. onErrorObservable: Observable<Effect>;
  29043. /** @hidden */
  29044. _onBindObservable: Nullable<Observable<Effect>>;
  29045. /**
  29046. * Observable that will be called when effect is bound.
  29047. */
  29048. readonly onBindObservable: Observable<Effect>;
  29049. /** @hidden */
  29050. _bonesComputationForcedToCPU: boolean;
  29051. private static _uniqueIdSeed;
  29052. private _engine;
  29053. private _uniformBuffersNames;
  29054. private _uniformsNames;
  29055. private _samplers;
  29056. private _isReady;
  29057. private _compilationError;
  29058. private _attributesNames;
  29059. private _attributes;
  29060. private _uniforms;
  29061. /**
  29062. * Key for the effect.
  29063. * @hidden
  29064. */
  29065. _key: string;
  29066. private _indexParameters;
  29067. private _fallbacks;
  29068. private _vertexSourceCode;
  29069. private _fragmentSourceCode;
  29070. private _vertexSourceCodeOverride;
  29071. private _fragmentSourceCodeOverride;
  29072. private _transformFeedbackVaryings;
  29073. /**
  29074. * Compiled shader to webGL program.
  29075. * @hidden
  29076. */
  29077. _program: WebGLProgram;
  29078. private _valueCache;
  29079. private static _baseCache;
  29080. /**
  29081. * Instantiates an effect.
  29082. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29083. * @param baseName Name of the effect.
  29084. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29085. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29086. * @param samplers List of sampler variables that will be passed to the shader.
  29087. * @param engine Engine to be used to render the effect
  29088. * @param defines Define statements to be added to the shader.
  29089. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29090. * @param onCompiled Callback that will be called when the shader is compiled.
  29091. * @param onError Callback that will be called if an error occurs during shader compilation.
  29092. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29093. */
  29094. 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);
  29095. /**
  29096. * Unique key for this effect
  29097. */
  29098. readonly key: string;
  29099. /**
  29100. * If the effect has been compiled and prepared.
  29101. * @returns if the effect is compiled and prepared.
  29102. */
  29103. isReady(): boolean;
  29104. /**
  29105. * The engine the effect was initialized with.
  29106. * @returns the engine.
  29107. */
  29108. getEngine(): Engine;
  29109. /**
  29110. * The compiled webGL program for the effect
  29111. * @returns the webGL program.
  29112. */
  29113. getProgram(): WebGLProgram;
  29114. /**
  29115. * The set of names of attribute variables for the shader.
  29116. * @returns An array of attribute names.
  29117. */
  29118. getAttributesNames(): string[];
  29119. /**
  29120. * Returns the attribute at the given index.
  29121. * @param index The index of the attribute.
  29122. * @returns The location of the attribute.
  29123. */
  29124. getAttributeLocation(index: number): number;
  29125. /**
  29126. * Returns the attribute based on the name of the variable.
  29127. * @param name of the attribute to look up.
  29128. * @returns the attribute location.
  29129. */
  29130. getAttributeLocationByName(name: string): number;
  29131. /**
  29132. * The number of attributes.
  29133. * @returns the numnber of attributes.
  29134. */
  29135. getAttributesCount(): number;
  29136. /**
  29137. * Gets the index of a uniform variable.
  29138. * @param uniformName of the uniform to look up.
  29139. * @returns the index.
  29140. */
  29141. getUniformIndex(uniformName: string): number;
  29142. /**
  29143. * Returns the attribute based on the name of the variable.
  29144. * @param uniformName of the uniform to look up.
  29145. * @returns the location of the uniform.
  29146. */
  29147. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29148. /**
  29149. * Returns an array of sampler variable names
  29150. * @returns The array of sampler variable neames.
  29151. */
  29152. getSamplers(): string[];
  29153. /**
  29154. * The error from the last compilation.
  29155. * @returns the error string.
  29156. */
  29157. getCompilationError(): string;
  29158. /**
  29159. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29160. * @param func The callback to be used.
  29161. */
  29162. executeWhenCompiled(func: (effect: Effect) => void): void;
  29163. private _checkIsReady;
  29164. /** @hidden */
  29165. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29166. /** @hidden */
  29167. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29168. /** @hidden */
  29169. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29170. private _processShaderConversion;
  29171. private _processIncludes;
  29172. private _processPrecision;
  29173. /**
  29174. * Recompiles the webGL program
  29175. * @param vertexSourceCode The source code for the vertex shader.
  29176. * @param fragmentSourceCode The source code for the fragment shader.
  29177. * @param onCompiled Callback called when completed.
  29178. * @param onError Callback called on error.
  29179. * @hidden
  29180. */
  29181. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29182. /**
  29183. * Gets the uniform locations of the the specified variable names
  29184. * @param names THe names of the variables to lookup.
  29185. * @returns Array of locations in the same order as variable names.
  29186. */
  29187. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29188. /**
  29189. * Prepares the effect
  29190. * @hidden
  29191. */
  29192. _prepareEffect(): void;
  29193. /**
  29194. * Checks if the effect is supported. (Must be called after compilation)
  29195. */
  29196. readonly isSupported: boolean;
  29197. /**
  29198. * Binds a texture to the engine to be used as output of the shader.
  29199. * @param channel Name of the output variable.
  29200. * @param texture Texture to bind.
  29201. * @hidden
  29202. */
  29203. _bindTexture(channel: string, texture: InternalTexture): void;
  29204. /**
  29205. * Sets a texture on the engine to be used in the shader.
  29206. * @param channel Name of the sampler variable.
  29207. * @param texture Texture to set.
  29208. */
  29209. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29210. /**
  29211. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29212. * @param channel Name of the sampler variable.
  29213. * @param texture Texture to set.
  29214. */
  29215. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29216. /**
  29217. * Sets an array of textures on the engine to be used in the shader.
  29218. * @param channel Name of the variable.
  29219. * @param textures Textures to set.
  29220. */
  29221. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29222. /**
  29223. * 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)
  29224. * @param channel Name of the sampler variable.
  29225. * @param postProcess Post process to get the input texture from.
  29226. */
  29227. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29228. /**
  29229. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29230. * 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)
  29231. * @param channel Name of the sampler variable.
  29232. * @param postProcess Post process to get the output texture from.
  29233. */
  29234. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29235. /** @hidden */
  29236. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29237. /** @hidden */
  29238. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29239. /** @hidden */
  29240. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29241. /** @hidden */
  29242. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29243. /**
  29244. * Binds a buffer to a uniform.
  29245. * @param buffer Buffer to bind.
  29246. * @param name Name of the uniform variable to bind to.
  29247. */
  29248. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29249. /**
  29250. * Binds block to a uniform.
  29251. * @param blockName Name of the block to bind.
  29252. * @param index Index to bind.
  29253. */
  29254. bindUniformBlock(blockName: string, index: number): void;
  29255. /**
  29256. * Sets an interger value on a uniform variable.
  29257. * @param uniformName Name of the variable.
  29258. * @param value Value to be set.
  29259. * @returns this effect.
  29260. */
  29261. setInt(uniformName: string, value: number): Effect;
  29262. /**
  29263. * Sets an int array on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param array array to be set.
  29266. * @returns this effect.
  29267. */
  29268. setIntArray(uniformName: string, array: Int32Array): Effect;
  29269. /**
  29270. * 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)
  29271. * @param uniformName Name of the variable.
  29272. * @param array array to be set.
  29273. * @returns this effect.
  29274. */
  29275. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29276. /**
  29277. * 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)
  29278. * @param uniformName Name of the variable.
  29279. * @param array array to be set.
  29280. * @returns this effect.
  29281. */
  29282. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29283. /**
  29284. * 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)
  29285. * @param uniformName Name of the variable.
  29286. * @param array array to be set.
  29287. * @returns this effect.
  29288. */
  29289. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29290. /**
  29291. * Sets an float array on a uniform variable.
  29292. * @param uniformName Name of the variable.
  29293. * @param array array to be set.
  29294. * @returns this effect.
  29295. */
  29296. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29297. /**
  29298. * 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)
  29299. * @param uniformName Name of the variable.
  29300. * @param array array to be set.
  29301. * @returns this effect.
  29302. */
  29303. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29304. /**
  29305. * 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)
  29306. * @param uniformName Name of the variable.
  29307. * @param array array to be set.
  29308. * @returns this effect.
  29309. */
  29310. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29311. /**
  29312. * 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)
  29313. * @param uniformName Name of the variable.
  29314. * @param array array to be set.
  29315. * @returns this effect.
  29316. */
  29317. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29318. /**
  29319. * Sets an array on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param array array to be set.
  29322. * @returns this effect.
  29323. */
  29324. setArray(uniformName: string, array: number[]): Effect;
  29325. /**
  29326. * 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)
  29327. * @param uniformName Name of the variable.
  29328. * @param array array to be set.
  29329. * @returns this effect.
  29330. */
  29331. setArray2(uniformName: string, array: number[]): Effect;
  29332. /**
  29333. * 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)
  29334. * @param uniformName Name of the variable.
  29335. * @param array array to be set.
  29336. * @returns this effect.
  29337. */
  29338. setArray3(uniformName: string, array: number[]): Effect;
  29339. /**
  29340. * 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)
  29341. * @param uniformName Name of the variable.
  29342. * @param array array to be set.
  29343. * @returns this effect.
  29344. */
  29345. setArray4(uniformName: string, array: number[]): Effect;
  29346. /**
  29347. * Sets matrices on a uniform variable.
  29348. * @param uniformName Name of the variable.
  29349. * @param matrices matrices to be set.
  29350. * @returns this effect.
  29351. */
  29352. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29353. /**
  29354. * Sets matrix on a uniform variable.
  29355. * @param uniformName Name of the variable.
  29356. * @param matrix matrix to be set.
  29357. * @returns this effect.
  29358. */
  29359. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29360. /**
  29361. * 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)
  29362. * @param uniformName Name of the variable.
  29363. * @param matrix matrix to be set.
  29364. * @returns this effect.
  29365. */
  29366. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29367. /**
  29368. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29369. * @param uniformName Name of the variable.
  29370. * @param matrix matrix to be set.
  29371. * @returns this effect.
  29372. */
  29373. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29374. /**
  29375. * Sets a float on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param value value to be set.
  29378. * @returns this effect.
  29379. */
  29380. setFloat(uniformName: string, value: number): Effect;
  29381. /**
  29382. * Sets a boolean on a uniform variable.
  29383. * @param uniformName Name of the variable.
  29384. * @param bool value to be set.
  29385. * @returns this effect.
  29386. */
  29387. setBool(uniformName: string, bool: boolean): Effect;
  29388. /**
  29389. * Sets a Vector2 on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param vector2 vector2 to be set.
  29392. * @returns this effect.
  29393. */
  29394. setVector2(uniformName: string, vector2: Vector2): Effect;
  29395. /**
  29396. * Sets a float2 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param x First float in float2.
  29399. * @param y Second float in float2.
  29400. * @returns this effect.
  29401. */
  29402. setFloat2(uniformName: string, x: number, y: number): Effect;
  29403. /**
  29404. * Sets a Vector3 on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param vector3 Value to be set.
  29407. * @returns this effect.
  29408. */
  29409. setVector3(uniformName: string, vector3: Vector3): Effect;
  29410. /**
  29411. * Sets a float3 on a uniform variable.
  29412. * @param uniformName Name of the variable.
  29413. * @param x First float in float3.
  29414. * @param y Second float in float3.
  29415. * @param z Third float in float3.
  29416. * @returns this effect.
  29417. */
  29418. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29419. /**
  29420. * Sets a Vector4 on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param vector4 Value to be set.
  29423. * @returns this effect.
  29424. */
  29425. setVector4(uniformName: string, vector4: Vector4): Effect;
  29426. /**
  29427. * Sets a float4 on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param x First float in float4.
  29430. * @param y Second float in float4.
  29431. * @param z Third float in float4.
  29432. * @param w Fourth float in float4.
  29433. * @returns this effect.
  29434. */
  29435. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29436. /**
  29437. * Sets a Color3 on a uniform variable.
  29438. * @param uniformName Name of the variable.
  29439. * @param color3 Value to be set.
  29440. * @returns this effect.
  29441. */
  29442. setColor3(uniformName: string, color3: Color3): Effect;
  29443. /**
  29444. * Sets a Color4 on a uniform variable.
  29445. * @param uniformName Name of the variable.
  29446. * @param color3 Value to be set.
  29447. * @param alpha Alpha value to be set.
  29448. * @returns this effect.
  29449. */
  29450. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29451. /**
  29452. * Sets a Color4 on a uniform variable
  29453. * @param uniformName defines the name of the variable
  29454. * @param color4 defines the value to be set
  29455. * @returns this effect.
  29456. */
  29457. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29458. /**
  29459. * This function will add a new shader to the shader store
  29460. * @param name the name of the shader
  29461. * @param pixelShader optional pixel shader content
  29462. * @param vertexShader optional vertex shader content
  29463. */
  29464. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29465. /**
  29466. * Store of each shader (The can be looked up using effect.key)
  29467. */
  29468. static ShadersStore: {
  29469. [key: string]: string;
  29470. };
  29471. /**
  29472. * Store of each included file for a shader (The can be looked up using effect.key)
  29473. */
  29474. static IncludesShadersStore: {
  29475. [key: string]: string;
  29476. };
  29477. /**
  29478. * Resets the cache of effects.
  29479. */
  29480. static ResetCache(): void;
  29481. }
  29482. }
  29483. declare module "babylonjs/Materials/colorCurves" {
  29484. import { Effect } from "babylonjs/Materials/effect";
  29485. /**
  29486. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29487. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29488. * 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;
  29489. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29490. */
  29491. export class ColorCurves {
  29492. private _dirty;
  29493. private _tempColor;
  29494. private _globalCurve;
  29495. private _highlightsCurve;
  29496. private _midtonesCurve;
  29497. private _shadowsCurve;
  29498. private _positiveCurve;
  29499. private _negativeCurve;
  29500. private _globalHue;
  29501. private _globalDensity;
  29502. private _globalSaturation;
  29503. private _globalExposure;
  29504. /**
  29505. * Gets the global Hue value.
  29506. * 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).
  29507. */
  29508. /**
  29509. * Sets the global Hue value.
  29510. * 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).
  29511. */
  29512. globalHue: number;
  29513. /**
  29514. * Gets the global Density value.
  29515. * 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.
  29516. * Values less than zero provide a filter of opposite hue.
  29517. */
  29518. /**
  29519. * Sets the global Density value.
  29520. * 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.
  29521. * Values less than zero provide a filter of opposite hue.
  29522. */
  29523. globalDensity: number;
  29524. /**
  29525. * Gets the global Saturation value.
  29526. * 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.
  29527. */
  29528. /**
  29529. * Sets the global Saturation value.
  29530. * 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.
  29531. */
  29532. globalSaturation: number;
  29533. /**
  29534. * Gets the global Exposure value.
  29535. * 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.
  29536. */
  29537. /**
  29538. * Sets the global Exposure value.
  29539. * 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.
  29540. */
  29541. globalExposure: number;
  29542. private _highlightsHue;
  29543. private _highlightsDensity;
  29544. private _highlightsSaturation;
  29545. private _highlightsExposure;
  29546. /**
  29547. * Gets the highlights Hue value.
  29548. * 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).
  29549. */
  29550. /**
  29551. * Sets the highlights Hue value.
  29552. * 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).
  29553. */
  29554. highlightsHue: number;
  29555. /**
  29556. * Gets the highlights Density value.
  29557. * 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.
  29558. * Values less than zero provide a filter of opposite hue.
  29559. */
  29560. /**
  29561. * Sets the highlights Density value.
  29562. * 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.
  29563. * Values less than zero provide a filter of opposite hue.
  29564. */
  29565. highlightsDensity: number;
  29566. /**
  29567. * Gets the highlights Saturation value.
  29568. * 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.
  29569. */
  29570. /**
  29571. * Sets the highlights Saturation value.
  29572. * 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.
  29573. */
  29574. highlightsSaturation: number;
  29575. /**
  29576. * Gets the highlights Exposure value.
  29577. * 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.
  29578. */
  29579. /**
  29580. * Sets the highlights Exposure value.
  29581. * 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.
  29582. */
  29583. highlightsExposure: number;
  29584. private _midtonesHue;
  29585. private _midtonesDensity;
  29586. private _midtonesSaturation;
  29587. private _midtonesExposure;
  29588. /**
  29589. * Gets the midtones Hue value.
  29590. * 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).
  29591. */
  29592. /**
  29593. * Sets the midtones Hue value.
  29594. * 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).
  29595. */
  29596. midtonesHue: number;
  29597. /**
  29598. * Gets the midtones Density value.
  29599. * 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.
  29600. * Values less than zero provide a filter of opposite hue.
  29601. */
  29602. /**
  29603. * Sets the midtones Density value.
  29604. * 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.
  29605. * Values less than zero provide a filter of opposite hue.
  29606. */
  29607. midtonesDensity: number;
  29608. /**
  29609. * Gets the midtones Saturation value.
  29610. * 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.
  29611. */
  29612. /**
  29613. * Sets the midtones Saturation value.
  29614. * 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.
  29615. */
  29616. midtonesSaturation: number;
  29617. /**
  29618. * Gets the midtones Exposure value.
  29619. * 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.
  29620. */
  29621. /**
  29622. * Sets the midtones Exposure value.
  29623. * 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.
  29624. */
  29625. midtonesExposure: number;
  29626. private _shadowsHue;
  29627. private _shadowsDensity;
  29628. private _shadowsSaturation;
  29629. private _shadowsExposure;
  29630. /**
  29631. * Gets the shadows Hue value.
  29632. * 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).
  29633. */
  29634. /**
  29635. * Sets the shadows Hue value.
  29636. * 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).
  29637. */
  29638. shadowsHue: number;
  29639. /**
  29640. * Gets the shadows Density value.
  29641. * 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.
  29642. * Values less than zero provide a filter of opposite hue.
  29643. */
  29644. /**
  29645. * Sets the shadows Density value.
  29646. * 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.
  29647. * Values less than zero provide a filter of opposite hue.
  29648. */
  29649. shadowsDensity: number;
  29650. /**
  29651. * Gets the shadows Saturation value.
  29652. * 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.
  29653. */
  29654. /**
  29655. * Sets the shadows Saturation value.
  29656. * 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.
  29657. */
  29658. shadowsSaturation: number;
  29659. /**
  29660. * Gets the shadows Exposure value.
  29661. * 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.
  29662. */
  29663. /**
  29664. * Sets the shadows Exposure value.
  29665. * 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.
  29666. */
  29667. shadowsExposure: number;
  29668. /**
  29669. * Returns the class name
  29670. * @returns The class name
  29671. */
  29672. getClassName(): string;
  29673. /**
  29674. * Binds the color curves to the shader.
  29675. * @param colorCurves The color curve to bind
  29676. * @param effect The effect to bind to
  29677. * @param positiveUniform The positive uniform shader parameter
  29678. * @param neutralUniform The neutral uniform shader parameter
  29679. * @param negativeUniform The negative uniform shader parameter
  29680. */
  29681. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29682. /**
  29683. * Prepare the list of uniforms associated with the ColorCurves effects.
  29684. * @param uniformsList The list of uniforms used in the effect
  29685. */
  29686. static PrepareUniforms(uniformsList: string[]): void;
  29687. /**
  29688. * Returns color grading data based on a hue, density, saturation and exposure value.
  29689. * @param filterHue The hue of the color filter.
  29690. * @param filterDensity The density of the color filter.
  29691. * @param saturation The saturation.
  29692. * @param exposure The exposure.
  29693. * @param result The result data container.
  29694. */
  29695. private getColorGradingDataToRef;
  29696. /**
  29697. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29698. * @param value The input slider value in range [-100,100].
  29699. * @returns Adjusted value.
  29700. */
  29701. private static applyColorGradingSliderNonlinear;
  29702. /**
  29703. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29704. * @param hue The hue (H) input.
  29705. * @param saturation The saturation (S) input.
  29706. * @param brightness The brightness (B) input.
  29707. * @result An RGBA color represented as Vector4.
  29708. */
  29709. private static fromHSBToRef;
  29710. /**
  29711. * Returns a value clamped between min and max
  29712. * @param value The value to clamp
  29713. * @param min The minimum of value
  29714. * @param max The maximum of value
  29715. * @returns The clamped value.
  29716. */
  29717. private static clamp;
  29718. /**
  29719. * Clones the current color curve instance.
  29720. * @return The cloned curves
  29721. */
  29722. clone(): ColorCurves;
  29723. /**
  29724. * Serializes the current color curve instance to a json representation.
  29725. * @return a JSON representation
  29726. */
  29727. serialize(): any;
  29728. /**
  29729. * Parses the color curve from a json representation.
  29730. * @param source the JSON source to parse
  29731. * @return The parsed curves
  29732. */
  29733. static Parse(source: any): ColorCurves;
  29734. }
  29735. }
  29736. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29737. import { Observable } from "babylonjs/Misc/observable";
  29738. import { Nullable } from "babylonjs/types";
  29739. import { Color4 } from "babylonjs/Maths/math";
  29740. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29741. import { Effect } from "babylonjs/Materials/effect";
  29742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29743. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29744. /**
  29745. * Interface to follow in your material defines to integrate easily the
  29746. * Image proccessing functions.
  29747. * @hidden
  29748. */
  29749. export interface IImageProcessingConfigurationDefines {
  29750. IMAGEPROCESSING: boolean;
  29751. VIGNETTE: boolean;
  29752. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29753. VIGNETTEBLENDMODEOPAQUE: boolean;
  29754. TONEMAPPING: boolean;
  29755. TONEMAPPING_ACES: boolean;
  29756. CONTRAST: boolean;
  29757. EXPOSURE: boolean;
  29758. COLORCURVES: boolean;
  29759. COLORGRADING: boolean;
  29760. COLORGRADING3D: boolean;
  29761. SAMPLER3DGREENDEPTH: boolean;
  29762. SAMPLER3DBGRMAP: boolean;
  29763. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29764. }
  29765. /**
  29766. * @hidden
  29767. */
  29768. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29769. IMAGEPROCESSING: boolean;
  29770. VIGNETTE: boolean;
  29771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29772. VIGNETTEBLENDMODEOPAQUE: boolean;
  29773. TONEMAPPING: boolean;
  29774. TONEMAPPING_ACES: boolean;
  29775. CONTRAST: boolean;
  29776. COLORCURVES: boolean;
  29777. COLORGRADING: boolean;
  29778. COLORGRADING3D: boolean;
  29779. SAMPLER3DGREENDEPTH: boolean;
  29780. SAMPLER3DBGRMAP: boolean;
  29781. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29782. EXPOSURE: boolean;
  29783. constructor();
  29784. }
  29785. /**
  29786. * This groups together the common properties used for image processing either in direct forward pass
  29787. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29788. * or not.
  29789. */
  29790. export class ImageProcessingConfiguration {
  29791. /**
  29792. * Default tone mapping applied in BabylonJS.
  29793. */
  29794. static readonly TONEMAPPING_STANDARD: number;
  29795. /**
  29796. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29797. * to other engines rendering to increase portability.
  29798. */
  29799. static readonly TONEMAPPING_ACES: number;
  29800. /**
  29801. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29802. */
  29803. colorCurves: Nullable<ColorCurves>;
  29804. private _colorCurvesEnabled;
  29805. /**
  29806. * Gets wether the color curves effect is enabled.
  29807. */
  29808. /**
  29809. * Sets wether the color curves effect is enabled.
  29810. */
  29811. colorCurvesEnabled: boolean;
  29812. private _colorGradingTexture;
  29813. /**
  29814. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29815. */
  29816. /**
  29817. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29818. */
  29819. colorGradingTexture: Nullable<BaseTexture>;
  29820. private _colorGradingEnabled;
  29821. /**
  29822. * Gets wether the color grading effect is enabled.
  29823. */
  29824. /**
  29825. * Sets wether the color grading effect is enabled.
  29826. */
  29827. colorGradingEnabled: boolean;
  29828. private _colorGradingWithGreenDepth;
  29829. /**
  29830. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29831. */
  29832. /**
  29833. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29834. */
  29835. colorGradingWithGreenDepth: boolean;
  29836. private _colorGradingBGR;
  29837. /**
  29838. * Gets wether the color grading texture contains BGR values.
  29839. */
  29840. /**
  29841. * Sets wether the color grading texture contains BGR values.
  29842. */
  29843. colorGradingBGR: boolean;
  29844. /** @hidden */
  29845. _exposure: number;
  29846. /**
  29847. * Gets the Exposure used in the effect.
  29848. */
  29849. /**
  29850. * Sets the Exposure used in the effect.
  29851. */
  29852. exposure: number;
  29853. private _toneMappingEnabled;
  29854. /**
  29855. * Gets wether the tone mapping effect is enabled.
  29856. */
  29857. /**
  29858. * Sets wether the tone mapping effect is enabled.
  29859. */
  29860. toneMappingEnabled: boolean;
  29861. private _toneMappingType;
  29862. /**
  29863. * Gets the type of tone mapping effect.
  29864. */
  29865. /**
  29866. * Sets the type of tone mapping effect used in BabylonJS.
  29867. */
  29868. toneMappingType: number;
  29869. protected _contrast: number;
  29870. /**
  29871. * Gets the contrast used in the effect.
  29872. */
  29873. /**
  29874. * Sets the contrast used in the effect.
  29875. */
  29876. contrast: number;
  29877. /**
  29878. * Vignette stretch size.
  29879. */
  29880. vignetteStretch: number;
  29881. /**
  29882. * Vignette centre X Offset.
  29883. */
  29884. vignetteCentreX: number;
  29885. /**
  29886. * Vignette centre Y Offset.
  29887. */
  29888. vignetteCentreY: number;
  29889. /**
  29890. * Vignette weight or intensity of the vignette effect.
  29891. */
  29892. vignetteWeight: number;
  29893. /**
  29894. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29895. * if vignetteEnabled is set to true.
  29896. */
  29897. vignetteColor: Color4;
  29898. /**
  29899. * Camera field of view used by the Vignette effect.
  29900. */
  29901. vignetteCameraFov: number;
  29902. private _vignetteBlendMode;
  29903. /**
  29904. * Gets the vignette blend mode allowing different kind of effect.
  29905. */
  29906. /**
  29907. * Sets the vignette blend mode allowing different kind of effect.
  29908. */
  29909. vignetteBlendMode: number;
  29910. private _vignetteEnabled;
  29911. /**
  29912. * Gets wether the vignette effect is enabled.
  29913. */
  29914. /**
  29915. * Sets wether the vignette effect is enabled.
  29916. */
  29917. vignetteEnabled: boolean;
  29918. private _applyByPostProcess;
  29919. /**
  29920. * Gets wether the image processing is applied through a post process or not.
  29921. */
  29922. /**
  29923. * Sets wether the image processing is applied through a post process or not.
  29924. */
  29925. applyByPostProcess: boolean;
  29926. private _isEnabled;
  29927. /**
  29928. * Gets wether the image processing is enabled or not.
  29929. */
  29930. /**
  29931. * Sets wether the image processing is enabled or not.
  29932. */
  29933. isEnabled: boolean;
  29934. /**
  29935. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29936. */
  29937. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29938. /**
  29939. * Method called each time the image processing information changes requires to recompile the effect.
  29940. */
  29941. protected _updateParameters(): void;
  29942. /**
  29943. * Gets the current class name.
  29944. * @return "ImageProcessingConfiguration"
  29945. */
  29946. getClassName(): string;
  29947. /**
  29948. * Prepare the list of uniforms associated with the Image Processing effects.
  29949. * @param uniforms The list of uniforms used in the effect
  29950. * @param defines the list of defines currently in use
  29951. */
  29952. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29953. /**
  29954. * Prepare the list of samplers associated with the Image Processing effects.
  29955. * @param samplersList The list of uniforms used in the effect
  29956. * @param defines the list of defines currently in use
  29957. */
  29958. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29959. /**
  29960. * Prepare the list of defines associated to the shader.
  29961. * @param defines the list of defines to complete
  29962. * @param forPostProcess Define if we are currently in post process mode or not
  29963. */
  29964. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29965. /**
  29966. * Returns true if all the image processing information are ready.
  29967. * @returns True if ready, otherwise, false
  29968. */
  29969. isReady(): boolean;
  29970. /**
  29971. * Binds the image processing to the shader.
  29972. * @param effect The effect to bind to
  29973. * @param aspectRatio Define the current aspect ratio of the effect
  29974. */
  29975. bind(effect: Effect, aspectRatio?: number): void;
  29976. /**
  29977. * Clones the current image processing instance.
  29978. * @return The cloned image processing
  29979. */
  29980. clone(): ImageProcessingConfiguration;
  29981. /**
  29982. * Serializes the current image processing instance to a json representation.
  29983. * @return a JSON representation
  29984. */
  29985. serialize(): any;
  29986. /**
  29987. * Parses the image processing from a json representation.
  29988. * @param source the JSON source to parse
  29989. * @return The parsed image processing
  29990. */
  29991. static Parse(source: any): ImageProcessingConfiguration;
  29992. private static _VIGNETTEMODE_MULTIPLY;
  29993. private static _VIGNETTEMODE_OPAQUE;
  29994. /**
  29995. * Used to apply the vignette as a mix with the pixel color.
  29996. */
  29997. static readonly VIGNETTEMODE_MULTIPLY: number;
  29998. /**
  29999. * Used to apply the vignette as a replacement of the pixel color.
  30000. */
  30001. static readonly VIGNETTEMODE_OPAQUE: number;
  30002. }
  30003. }
  30004. declare module "babylonjs/Materials/fresnelParameters" {
  30005. import { Color3 } from "babylonjs/Maths/math";
  30006. /**
  30007. * This represents all the required information to add a fresnel effect on a material:
  30008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30009. */
  30010. export class FresnelParameters {
  30011. private _isEnabled;
  30012. /**
  30013. * Define if the fresnel effect is enable or not.
  30014. */
  30015. isEnabled: boolean;
  30016. /**
  30017. * Define the color used on edges (grazing angle)
  30018. */
  30019. leftColor: Color3;
  30020. /**
  30021. * Define the color used on center
  30022. */
  30023. rightColor: Color3;
  30024. /**
  30025. * Define bias applied to computed fresnel term
  30026. */
  30027. bias: number;
  30028. /**
  30029. * Defined the power exponent applied to fresnel term
  30030. */
  30031. power: number;
  30032. /**
  30033. * Clones the current fresnel and its valuues
  30034. * @returns a clone fresnel configuration
  30035. */
  30036. clone(): FresnelParameters;
  30037. /**
  30038. * Serializes the current fresnel parameters to a JSON representation.
  30039. * @return the JSON serialization
  30040. */
  30041. serialize(): any;
  30042. /**
  30043. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30044. * @param parsedFresnelParameters Define the JSON representation
  30045. * @returns the parsed parameters
  30046. */
  30047. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30048. }
  30049. }
  30050. declare module "babylonjs/Misc/decorators" {
  30051. import { Nullable } from "babylonjs/types";
  30052. import { Scene } from "babylonjs/scene";
  30053. import { IAnimatable } from "babylonjs/Misc/tools";
  30054. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30055. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30056. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30057. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30059. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30060. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30061. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30062. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30063. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30064. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30065. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30066. /**
  30067. * Decorator used to define property that can be serialized as reference to a camera
  30068. * @param sourceName defines the name of the property to decorate
  30069. */
  30070. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30071. /**
  30072. * Class used to help serialization objects
  30073. */
  30074. export class SerializationHelper {
  30075. /** hidden */
  30076. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30077. /** hidden */
  30078. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30079. /** hidden */
  30080. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30081. /** hidden */
  30082. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30083. /**
  30084. * Appends the serialized animations from the source animations
  30085. * @param source Source containing the animations
  30086. * @param destination Target to store the animations
  30087. */
  30088. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30089. /**
  30090. * Static function used to serialized a specific entity
  30091. * @param entity defines the entity to serialize
  30092. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30093. * @returns a JSON compatible object representing the serialization of the entity
  30094. */
  30095. static Serialize<T>(entity: T, serializationObject?: any): any;
  30096. /**
  30097. * Creates a new entity from a serialization data object
  30098. * @param creationFunction defines a function used to instanciated the new entity
  30099. * @param source defines the source serialization data
  30100. * @param scene defines the hosting scene
  30101. * @param rootUrl defines the root url for resources
  30102. * @returns a new entity
  30103. */
  30104. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30105. /**
  30106. * Clones an object
  30107. * @param creationFunction defines the function used to instanciate the new object
  30108. * @param source defines the source object
  30109. * @returns the cloned object
  30110. */
  30111. static Clone<T>(creationFunction: () => T, source: T): T;
  30112. /**
  30113. * Instanciates a new object based on a source one (some data will be shared between both object)
  30114. * @param creationFunction defines the function used to instanciate the new object
  30115. * @param source defines the source object
  30116. * @returns the new object
  30117. */
  30118. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30119. }
  30120. }
  30121. declare module "babylonjs/Cameras/camera" {
  30122. import { SmartArray } from "babylonjs/Misc/smartArray";
  30123. import { Observable } from "babylonjs/Misc/observable";
  30124. import { Nullable } from "babylonjs/types";
  30125. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30126. import { Scene } from "babylonjs/scene";
  30127. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30128. import { Node } from "babylonjs/node";
  30129. import { Mesh } from "babylonjs/Meshes/mesh";
  30130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30131. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30134. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30135. import { Ray } from "babylonjs/Culling/ray";
  30136. /**
  30137. * This is the base class of all the camera used in the application.
  30138. * @see http://doc.babylonjs.com/features/cameras
  30139. */
  30140. export class Camera extends Node {
  30141. /** @hidden */
  30142. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30143. /**
  30144. * This is the default projection mode used by the cameras.
  30145. * It helps recreating a feeling of perspective and better appreciate depth.
  30146. * This is the best way to simulate real life cameras.
  30147. */
  30148. static readonly PERSPECTIVE_CAMERA: number;
  30149. /**
  30150. * This helps creating camera with an orthographic mode.
  30151. * 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.
  30152. */
  30153. static readonly ORTHOGRAPHIC_CAMERA: number;
  30154. /**
  30155. * This is the default FOV mode for perspective cameras.
  30156. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30157. */
  30158. static readonly FOVMODE_VERTICAL_FIXED: number;
  30159. /**
  30160. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30161. */
  30162. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30163. /**
  30164. * This specifies ther is no need for a camera rig.
  30165. * Basically only one eye is rendered corresponding to the camera.
  30166. */
  30167. static readonly RIG_MODE_NONE: number;
  30168. /**
  30169. * Simulates a camera Rig with one blue eye and one red eye.
  30170. * This can be use with 3d blue and red glasses.
  30171. */
  30172. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30173. /**
  30174. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30175. */
  30176. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30177. /**
  30178. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30179. */
  30180. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30181. /**
  30182. * Defines that both eyes of the camera will be rendered over under each other.
  30183. */
  30184. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30185. /**
  30186. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30187. */
  30188. static readonly RIG_MODE_VR: number;
  30189. /**
  30190. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30191. */
  30192. static readonly RIG_MODE_WEBVR: number;
  30193. /**
  30194. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30195. */
  30196. static readonly RIG_MODE_CUSTOM: number;
  30197. /**
  30198. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30199. */
  30200. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30201. /**
  30202. * @hidden
  30203. * Might be removed once multiview will be a thing
  30204. */
  30205. static UseAlternateWebVRRendering: boolean;
  30206. /**
  30207. * Define the input manager associated with the camera.
  30208. */
  30209. inputs: CameraInputsManager<Camera>;
  30210. /** @hidden */
  30211. _position: Vector3;
  30212. /**
  30213. * Define the current local position of the camera in the scene
  30214. */
  30215. position: Vector3;
  30216. /**
  30217. * The vector the camera should consider as up.
  30218. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30219. */
  30220. upVector: Vector3;
  30221. /**
  30222. * Define the current limit on the left side for an orthographic camera
  30223. * In scene unit
  30224. */
  30225. orthoLeft: Nullable<number>;
  30226. /**
  30227. * Define the current limit on the right side for an orthographic camera
  30228. * In scene unit
  30229. */
  30230. orthoRight: Nullable<number>;
  30231. /**
  30232. * Define the current limit on the bottom side for an orthographic camera
  30233. * In scene unit
  30234. */
  30235. orthoBottom: Nullable<number>;
  30236. /**
  30237. * Define the current limit on the top side for an orthographic camera
  30238. * In scene unit
  30239. */
  30240. orthoTop: Nullable<number>;
  30241. /**
  30242. * Field Of View is set in Radians. (default is 0.8)
  30243. */
  30244. fov: number;
  30245. /**
  30246. * Define the minimum distance the camera can see from.
  30247. * This is important to note that the depth buffer are not infinite and the closer it starts
  30248. * the more your scene might encounter depth fighting issue.
  30249. */
  30250. minZ: number;
  30251. /**
  30252. * Define the maximum distance the camera can see to.
  30253. * This is important to note that the depth buffer are not infinite and the further it end
  30254. * the more your scene might encounter depth fighting issue.
  30255. */
  30256. maxZ: number;
  30257. /**
  30258. * Define the default inertia of the camera.
  30259. * This helps giving a smooth feeling to the camera movement.
  30260. */
  30261. inertia: number;
  30262. /**
  30263. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30264. */
  30265. mode: number;
  30266. /**
  30267. * Define wether the camera is intermediate.
  30268. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30269. */
  30270. isIntermediate: boolean;
  30271. /**
  30272. * Define the viewport of the camera.
  30273. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30274. */
  30275. viewport: Viewport;
  30276. /**
  30277. * Restricts the camera to viewing objects with the same layerMask.
  30278. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30279. */
  30280. layerMask: number;
  30281. /**
  30282. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30283. */
  30284. fovMode: number;
  30285. /**
  30286. * Rig mode of the camera.
  30287. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30288. * This is normally controlled byt the camera themselves as internal use.
  30289. */
  30290. cameraRigMode: number;
  30291. /**
  30292. * Defines the distance between both "eyes" in case of a RIG
  30293. */
  30294. interaxialDistance: number;
  30295. /**
  30296. * Defines if stereoscopic rendering is done side by side or over under.
  30297. */
  30298. isStereoscopicSideBySide: boolean;
  30299. /**
  30300. * 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
  30301. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30302. * else in the scene.
  30303. */
  30304. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30305. /**
  30306. * When set, the camera will render to this render target instead of the default canvas
  30307. */
  30308. outputRenderTarget: Nullable<RenderTargetTexture>;
  30309. /**
  30310. * Observable triggered when the camera view matrix has changed.
  30311. */
  30312. onViewMatrixChangedObservable: Observable<Camera>;
  30313. /**
  30314. * Observable triggered when the camera Projection matrix has changed.
  30315. */
  30316. onProjectionMatrixChangedObservable: Observable<Camera>;
  30317. /**
  30318. * Observable triggered when the inputs have been processed.
  30319. */
  30320. onAfterCheckInputsObservable: Observable<Camera>;
  30321. /**
  30322. * Observable triggered when reset has been called and applied to the camera.
  30323. */
  30324. onRestoreStateObservable: Observable<Camera>;
  30325. /** @hidden */
  30326. _cameraRigParams: any;
  30327. /** @hidden */
  30328. _rigCameras: Camera[];
  30329. /** @hidden */
  30330. _rigPostProcess: Nullable<PostProcess>;
  30331. protected _webvrViewMatrix: Matrix;
  30332. /** @hidden */
  30333. _skipRendering: boolean;
  30334. /** @hidden */
  30335. _alternateCamera: Camera;
  30336. /** @hidden */
  30337. _projectionMatrix: Matrix;
  30338. /** @hidden */
  30339. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30340. /** @hidden */
  30341. _activeMeshes: SmartArray<AbstractMesh>;
  30342. protected _globalPosition: Vector3;
  30343. /** hidden */
  30344. _computedViewMatrix: Matrix;
  30345. private _doNotComputeProjectionMatrix;
  30346. private _transformMatrix;
  30347. private _frustumPlanes;
  30348. private _refreshFrustumPlanes;
  30349. private _storedFov;
  30350. private _stateStored;
  30351. /**
  30352. * Instantiates a new camera object.
  30353. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30354. * @see http://doc.babylonjs.com/features/cameras
  30355. * @param name Defines the name of the camera in the scene
  30356. * @param position Defines the position of the camera
  30357. * @param scene Defines the scene the camera belongs too
  30358. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30359. */
  30360. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30361. /**
  30362. * Store current camera state (fov, position, etc..)
  30363. * @returns the camera
  30364. */
  30365. storeState(): Camera;
  30366. /**
  30367. * Restores the camera state values if it has been stored. You must call storeState() first
  30368. */
  30369. protected _restoreStateValues(): boolean;
  30370. /**
  30371. * Restored camera state. You must call storeState() first.
  30372. * @returns true if restored and false otherwise
  30373. */
  30374. restoreState(): boolean;
  30375. /**
  30376. * Gets the class name of the camera.
  30377. * @returns the class name
  30378. */
  30379. getClassName(): string;
  30380. /** @hidden */
  30381. readonly _isCamera: boolean;
  30382. /**
  30383. * Gets a string representation of the camera useful for debug purpose.
  30384. * @param fullDetails Defines that a more verboe level of logging is required
  30385. * @returns the string representation
  30386. */
  30387. toString(fullDetails?: boolean): string;
  30388. /**
  30389. * Gets the current world space position of the camera.
  30390. */
  30391. readonly globalPosition: Vector3;
  30392. /**
  30393. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30394. * @returns the active meshe list
  30395. */
  30396. getActiveMeshes(): SmartArray<AbstractMesh>;
  30397. /**
  30398. * Check wether a mesh is part of the current active mesh list of the camera
  30399. * @param mesh Defines the mesh to check
  30400. * @returns true if active, false otherwise
  30401. */
  30402. isActiveMesh(mesh: Mesh): boolean;
  30403. /**
  30404. * Is this camera ready to be used/rendered
  30405. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30406. * @return true if the camera is ready
  30407. */
  30408. isReady(completeCheck?: boolean): boolean;
  30409. /** @hidden */
  30410. _initCache(): void;
  30411. /** @hidden */
  30412. _updateCache(ignoreParentClass?: boolean): void;
  30413. /** @hidden */
  30414. _isSynchronized(): boolean;
  30415. /** @hidden */
  30416. _isSynchronizedViewMatrix(): boolean;
  30417. /** @hidden */
  30418. _isSynchronizedProjectionMatrix(): boolean;
  30419. /**
  30420. * Attach the input controls to a specific dom element to get the input from.
  30421. * @param element Defines the element the controls should be listened from
  30422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30423. */
  30424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30425. /**
  30426. * Detach the current controls from the specified dom element.
  30427. * @param element Defines the element to stop listening the inputs from
  30428. */
  30429. detachControl(element: HTMLElement): void;
  30430. /**
  30431. * Update the camera state according to the different inputs gathered during the frame.
  30432. */
  30433. update(): void;
  30434. /** @hidden */
  30435. _checkInputs(): void;
  30436. /** @hidden */
  30437. readonly rigCameras: Camera[];
  30438. /**
  30439. * Gets the post process used by the rig cameras
  30440. */
  30441. readonly rigPostProcess: Nullable<PostProcess>;
  30442. /**
  30443. * Internal, gets the first post proces.
  30444. * @returns the first post process to be run on this camera.
  30445. */
  30446. _getFirstPostProcess(): Nullable<PostProcess>;
  30447. private _cascadePostProcessesToRigCams;
  30448. /**
  30449. * Attach a post process to the camera.
  30450. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30451. * @param postProcess The post process to attach to the camera
  30452. * @param insertAt The position of the post process in case several of them are in use in the scene
  30453. * @returns the position the post process has been inserted at
  30454. */
  30455. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30456. /**
  30457. * Detach a post process to the camera.
  30458. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30459. * @param postProcess The post process to detach from the camera
  30460. */
  30461. detachPostProcess(postProcess: PostProcess): void;
  30462. /**
  30463. * Gets the current world matrix of the camera
  30464. */
  30465. getWorldMatrix(): Matrix;
  30466. /** @hidden */
  30467. _getViewMatrix(): Matrix;
  30468. /**
  30469. * Gets the current view matrix of the camera.
  30470. * @param force forces the camera to recompute the matrix without looking at the cached state
  30471. * @returns the view matrix
  30472. */
  30473. getViewMatrix(force?: boolean): Matrix;
  30474. /**
  30475. * Freeze the projection matrix.
  30476. * It will prevent the cache check of the camera projection compute and can speed up perf
  30477. * if no parameter of the camera are meant to change
  30478. * @param projection Defines manually a projection if necessary
  30479. */
  30480. freezeProjectionMatrix(projection?: Matrix): void;
  30481. /**
  30482. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30483. */
  30484. unfreezeProjectionMatrix(): void;
  30485. /**
  30486. * Gets the current projection matrix of the camera.
  30487. * @param force forces the camera to recompute the matrix without looking at the cached state
  30488. * @returns the projection matrix
  30489. */
  30490. getProjectionMatrix(force?: boolean): Matrix;
  30491. /**
  30492. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30493. * @returns a Matrix
  30494. */
  30495. getTransformationMatrix(): Matrix;
  30496. private _updateFrustumPlanes;
  30497. /**
  30498. * Checks if a cullable object (mesh...) is in the camera frustum
  30499. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30500. * @param target The object to check
  30501. * @returns true if the object is in frustum otherwise false
  30502. */
  30503. isInFrustum(target: ICullable): boolean;
  30504. /**
  30505. * Checks if a cullable object (mesh...) is in the camera frustum
  30506. * Unlike isInFrustum this cheks the full bounding box
  30507. * @param target The object to check
  30508. * @returns true if the object is in frustum otherwise false
  30509. */
  30510. isCompletelyInFrustum(target: ICullable): boolean;
  30511. /**
  30512. * Gets a ray in the forward direction from the camera.
  30513. * @param length Defines the length of the ray to create
  30514. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30515. * @param origin Defines the start point of the ray which defaults to the camera position
  30516. * @returns the forward ray
  30517. */
  30518. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30519. /**
  30520. * Releases resources associated with this node.
  30521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30523. */
  30524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30525. /** @hidden */
  30526. _isLeftCamera: boolean;
  30527. /**
  30528. * Gets the left camera of a rig setup in case of Rigged Camera
  30529. */
  30530. readonly isLeftCamera: boolean;
  30531. /** @hidden */
  30532. _isRightCamera: boolean;
  30533. /**
  30534. * Gets the right camera of a rig setup in case of Rigged Camera
  30535. */
  30536. readonly isRightCamera: boolean;
  30537. /**
  30538. * Gets the left camera of a rig setup in case of Rigged Camera
  30539. */
  30540. readonly leftCamera: Nullable<FreeCamera>;
  30541. /**
  30542. * Gets the right camera of a rig setup in case of Rigged Camera
  30543. */
  30544. readonly rightCamera: Nullable<FreeCamera>;
  30545. /**
  30546. * Gets the left camera target of a rig setup in case of Rigged Camera
  30547. * @returns the target position
  30548. */
  30549. getLeftTarget(): Nullable<Vector3>;
  30550. /**
  30551. * Gets the right camera target of a rig setup in case of Rigged Camera
  30552. * @returns the target position
  30553. */
  30554. getRightTarget(): Nullable<Vector3>;
  30555. /**
  30556. * @hidden
  30557. */
  30558. setCameraRigMode(mode: number, rigParams: any): void;
  30559. /** @hidden */
  30560. static _setStereoscopicRigMode(camera: Camera): void;
  30561. /** @hidden */
  30562. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30563. /** @hidden */
  30564. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30565. /** @hidden */
  30566. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30567. /** @hidden */
  30568. _getVRProjectionMatrix(): Matrix;
  30569. protected _updateCameraRotationMatrix(): void;
  30570. protected _updateWebVRCameraRotationMatrix(): void;
  30571. /**
  30572. * This function MUST be overwritten by the different WebVR cameras available.
  30573. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30574. * @hidden
  30575. */
  30576. _getWebVRProjectionMatrix(): Matrix;
  30577. /**
  30578. * This function MUST be overwritten by the different WebVR cameras available.
  30579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30580. * @hidden
  30581. */
  30582. _getWebVRViewMatrix(): Matrix;
  30583. /** @hidden */
  30584. setCameraRigParameter(name: string, value: any): void;
  30585. /**
  30586. * needs to be overridden by children so sub has required properties to be copied
  30587. * @hidden
  30588. */
  30589. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30590. /**
  30591. * May need to be overridden by children
  30592. * @hidden
  30593. */
  30594. _updateRigCameras(): void;
  30595. /** @hidden */
  30596. _setupInputs(): void;
  30597. /**
  30598. * Serialiaze the camera setup to a json represention
  30599. * @returns the JSON representation
  30600. */
  30601. serialize(): any;
  30602. /**
  30603. * Clones the current camera.
  30604. * @param name The cloned camera name
  30605. * @returns the cloned camera
  30606. */
  30607. clone(name: string): Camera;
  30608. /**
  30609. * Gets the direction of the camera relative to a given local axis.
  30610. * @param localAxis Defines the reference axis to provide a relative direction.
  30611. * @return the direction
  30612. */
  30613. getDirection(localAxis: Vector3): Vector3;
  30614. /**
  30615. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30616. * @param localAxis Defines the reference axis to provide a relative direction.
  30617. * @param result Defines the vector to store the result in
  30618. */
  30619. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30620. /**
  30621. * Gets a camera constructor for a given camera type
  30622. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30623. * @param name The name of the camera the result will be able to instantiate
  30624. * @param scene The scene the result will construct the camera in
  30625. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30626. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30627. * @returns a factory method to construc the camera
  30628. */
  30629. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30630. /**
  30631. * Compute the world matrix of the camera.
  30632. * @returns the camera workd matrix
  30633. */
  30634. computeWorldMatrix(): Matrix;
  30635. /**
  30636. * Parse a JSON and creates the camera from the parsed information
  30637. * @param parsedCamera The JSON to parse
  30638. * @param scene The scene to instantiate the camera in
  30639. * @returns the newly constructed camera
  30640. */
  30641. static Parse(parsedCamera: any, scene: Scene): Camera;
  30642. }
  30643. }
  30644. declare module "babylonjs/Misc/tools" {
  30645. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30646. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30647. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30648. import { Observable } from "babylonjs/Misc/observable";
  30649. import { DomManagement } from "babylonjs/Misc/domManagement";
  30650. import { Camera } from "babylonjs/Cameras/camera";
  30651. import { Engine } from "babylonjs/Engines/engine";
  30652. import { Animation } from "babylonjs/Animations/animation";
  30653. /**
  30654. * Interface for any object that can request an animation frame
  30655. */
  30656. export interface ICustomAnimationFrameRequester {
  30657. /**
  30658. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30659. */
  30660. renderFunction?: Function;
  30661. /**
  30662. * Called to request the next frame to render to
  30663. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30664. */
  30665. requestAnimationFrame: Function;
  30666. /**
  30667. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30668. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30669. */
  30670. requestID?: number;
  30671. }
  30672. /**
  30673. * Interface containing an array of animations
  30674. */
  30675. export interface IAnimatable {
  30676. /**
  30677. * Array of animations
  30678. */
  30679. animations: Array<Animation>;
  30680. }
  30681. /** Interface used by value gradients (color, factor, ...) */
  30682. export interface IValueGradient {
  30683. /**
  30684. * Gets or sets the gradient value (between 0 and 1)
  30685. */
  30686. gradient: number;
  30687. }
  30688. /** Class used to store color4 gradient */
  30689. export class ColorGradient implements IValueGradient {
  30690. /**
  30691. * Gets or sets the gradient value (between 0 and 1)
  30692. */
  30693. gradient: number;
  30694. /**
  30695. * Gets or sets first associated color
  30696. */
  30697. color1: Color4;
  30698. /**
  30699. * Gets or sets second associated color
  30700. */
  30701. color2?: Color4;
  30702. /**
  30703. * Will get a color picked randomly between color1 and color2.
  30704. * If color2 is undefined then color1 will be used
  30705. * @param result defines the target Color4 to store the result in
  30706. */
  30707. getColorToRef(result: Color4): void;
  30708. }
  30709. /** Class used to store color 3 gradient */
  30710. export class Color3Gradient implements IValueGradient {
  30711. /**
  30712. * Gets or sets the gradient value (between 0 and 1)
  30713. */
  30714. gradient: number;
  30715. /**
  30716. * Gets or sets the associated color
  30717. */
  30718. color: Color3;
  30719. }
  30720. /** Class used to store factor gradient */
  30721. export class FactorGradient implements IValueGradient {
  30722. /**
  30723. * Gets or sets the gradient value (between 0 and 1)
  30724. */
  30725. gradient: number;
  30726. /**
  30727. * Gets or sets first associated factor
  30728. */
  30729. factor1: number;
  30730. /**
  30731. * Gets or sets second associated factor
  30732. */
  30733. factor2?: number;
  30734. /**
  30735. * Will get a number picked randomly between factor1 and factor2.
  30736. * If factor2 is undefined then factor1 will be used
  30737. * @returns the picked number
  30738. */
  30739. getFactor(): number;
  30740. }
  30741. /**
  30742. * @ignore
  30743. * Application error to support additional information when loading a file
  30744. */
  30745. export class LoadFileError extends Error {
  30746. /** defines the optional XHR request */
  30747. request?: XMLHttpRequest | undefined;
  30748. private static _setPrototypeOf;
  30749. /**
  30750. * Creates a new LoadFileError
  30751. * @param message defines the message of the error
  30752. * @param request defines the optional XHR request
  30753. */
  30754. constructor(message: string,
  30755. /** defines the optional XHR request */
  30756. request?: XMLHttpRequest | undefined);
  30757. }
  30758. /**
  30759. * Class used to define a retry strategy when error happens while loading assets
  30760. */
  30761. export class RetryStrategy {
  30762. /**
  30763. * Function used to defines an exponential back off strategy
  30764. * @param maxRetries defines the maximum number of retries (3 by default)
  30765. * @param baseInterval defines the interval between retries
  30766. * @returns the strategy function to use
  30767. */
  30768. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30769. }
  30770. /**
  30771. * File request interface
  30772. */
  30773. export interface IFileRequest {
  30774. /**
  30775. * Raised when the request is complete (success or error).
  30776. */
  30777. onCompleteObservable: Observable<IFileRequest>;
  30778. /**
  30779. * Aborts the request for a file.
  30780. */
  30781. abort: () => void;
  30782. }
  30783. /**
  30784. * Class containing a set of static utilities functions
  30785. */
  30786. export class Tools {
  30787. /**
  30788. * Gets or sets the base URL to use to load assets
  30789. */
  30790. static BaseUrl: string;
  30791. /**
  30792. * Enable/Disable Custom HTTP Request Headers globally.
  30793. * default = false
  30794. * @see CustomRequestHeaders
  30795. */
  30796. static UseCustomRequestHeaders: boolean;
  30797. /**
  30798. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30799. * i.e. when loading files, where the server/service expects an Authorization header.
  30800. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30801. */
  30802. static CustomRequestHeaders: {
  30803. [key: string]: string;
  30804. };
  30805. /**
  30806. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30807. */
  30808. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30809. /**
  30810. * Default behaviour for cors in the application.
  30811. * It can be a string if the expected behavior is identical in the entire app.
  30812. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30813. */
  30814. static CorsBehavior: string | ((url: string | string[]) => string);
  30815. /**
  30816. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30817. * @ignorenaming
  30818. */
  30819. static UseFallbackTexture: boolean;
  30820. /**
  30821. * Use this object to register external classes like custom textures or material
  30822. * to allow the laoders to instantiate them
  30823. */
  30824. static RegisteredExternalClasses: {
  30825. [key: string]: Object;
  30826. };
  30827. /**
  30828. * Texture content used if a texture cannot loaded
  30829. * @ignorenaming
  30830. */
  30831. static fallbackTexture: string;
  30832. /**
  30833. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30834. * @param u defines the coordinate on X axis
  30835. * @param v defines the coordinate on Y axis
  30836. * @param width defines the width of the source data
  30837. * @param height defines the height of the source data
  30838. * @param pixels defines the source byte array
  30839. * @param color defines the output color
  30840. */
  30841. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30842. /**
  30843. * Interpolates between a and b via alpha
  30844. * @param a The lower value (returned when alpha = 0)
  30845. * @param b The upper value (returned when alpha = 1)
  30846. * @param alpha The interpolation-factor
  30847. * @return The mixed value
  30848. */
  30849. static Mix(a: number, b: number, alpha: number): number;
  30850. /**
  30851. * Tries to instantiate a new object from a given class name
  30852. * @param className defines the class name to instantiate
  30853. * @returns the new object or null if the system was not able to do the instantiation
  30854. */
  30855. static Instantiate(className: string): any;
  30856. /**
  30857. * Provides a slice function that will work even on IE
  30858. * @param data defines the array to slice
  30859. * @param start defines the start of the data (optional)
  30860. * @param end defines the end of the data (optional)
  30861. * @returns the new sliced array
  30862. */
  30863. static Slice<T>(data: T, start?: number, end?: number): T;
  30864. /**
  30865. * Polyfill for setImmediate
  30866. * @param action defines the action to execute after the current execution block
  30867. */
  30868. static SetImmediate(action: () => void): void;
  30869. /**
  30870. * Function indicating if a number is an exponent of 2
  30871. * @param value defines the value to test
  30872. * @returns true if the value is an exponent of 2
  30873. */
  30874. static IsExponentOfTwo(value: number): boolean;
  30875. private static _tmpFloatArray;
  30876. /**
  30877. * Returns the nearest 32-bit single precision float representation of a Number
  30878. * @param value A Number. If the parameter is of a different type, it will get converted
  30879. * to a number or to NaN if it cannot be converted
  30880. * @returns number
  30881. */
  30882. static FloatRound(value: number): number;
  30883. /**
  30884. * Find the next highest power of two.
  30885. * @param x Number to start search from.
  30886. * @return Next highest power of two.
  30887. */
  30888. static CeilingPOT(x: number): number;
  30889. /**
  30890. * Find the next lowest power of two.
  30891. * @param x Number to start search from.
  30892. * @return Next lowest power of two.
  30893. */
  30894. static FloorPOT(x: number): number;
  30895. /**
  30896. * Find the nearest power of two.
  30897. * @param x Number to start search from.
  30898. * @return Next nearest power of two.
  30899. */
  30900. static NearestPOT(x: number): number;
  30901. /**
  30902. * Get the closest exponent of two
  30903. * @param value defines the value to approximate
  30904. * @param max defines the maximum value to return
  30905. * @param mode defines how to define the closest value
  30906. * @returns closest exponent of two of the given value
  30907. */
  30908. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30909. /**
  30910. * Extracts the filename from a path
  30911. * @param path defines the path to use
  30912. * @returns the filename
  30913. */
  30914. static GetFilename(path: string): string;
  30915. /**
  30916. * Extracts the "folder" part of a path (everything before the filename).
  30917. * @param uri The URI to extract the info from
  30918. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30919. * @returns The "folder" part of the path
  30920. */
  30921. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30922. /**
  30923. * Extracts text content from a DOM element hierarchy
  30924. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30925. */
  30926. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30927. /**
  30928. * Convert an angle in radians to degrees
  30929. * @param angle defines the angle to convert
  30930. * @returns the angle in degrees
  30931. */
  30932. static ToDegrees(angle: number): number;
  30933. /**
  30934. * Convert an angle in degrees to radians
  30935. * @param angle defines the angle to convert
  30936. * @returns the angle in radians
  30937. */
  30938. static ToRadians(angle: number): number;
  30939. /**
  30940. * Encode a buffer to a base64 string
  30941. * @param buffer defines the buffer to encode
  30942. * @returns the encoded string
  30943. */
  30944. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30945. /**
  30946. * Extracts minimum and maximum values from a list of indexed positions
  30947. * @param positions defines the positions to use
  30948. * @param indices defines the indices to the positions
  30949. * @param indexStart defines the start index
  30950. * @param indexCount defines the end index
  30951. * @param bias defines bias value to add to the result
  30952. * @return minimum and maximum values
  30953. */
  30954. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30955. minimum: Vector3;
  30956. maximum: Vector3;
  30957. };
  30958. /**
  30959. * Extracts minimum and maximum values from a list of positions
  30960. * @param positions defines the positions to use
  30961. * @param start defines the start index in the positions array
  30962. * @param count defines the number of positions to handle
  30963. * @param bias defines bias value to add to the result
  30964. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30965. * @return minimum and maximum values
  30966. */
  30967. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30968. minimum: Vector3;
  30969. maximum: Vector3;
  30970. };
  30971. /**
  30972. * Returns an array if obj is not an array
  30973. * @param obj defines the object to evaluate as an array
  30974. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30975. * @returns either obj directly if obj is an array or a new array containing obj
  30976. */
  30977. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30978. /**
  30979. * Gets the pointer prefix to use
  30980. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30981. */
  30982. static GetPointerPrefix(): string;
  30983. /**
  30984. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30985. * @param func - the function to be called
  30986. * @param requester - the object that will request the next frame. Falls back to window.
  30987. * @returns frame number
  30988. */
  30989. static QueueNewFrame(func: () => void, requester?: any): number;
  30990. /**
  30991. * Ask the browser to promote the current element to fullscreen rendering mode
  30992. * @param element defines the DOM element to promote
  30993. */
  30994. static RequestFullscreen(element: HTMLElement): void;
  30995. /**
  30996. * Asks the browser to exit fullscreen mode
  30997. */
  30998. static ExitFullscreen(): void;
  30999. /**
  31000. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31001. * @param url define the url we are trying
  31002. * @param element define the dom element where to configure the cors policy
  31003. */
  31004. static SetCorsBehavior(url: string | string[], element: {
  31005. crossOrigin: string | null;
  31006. }): void;
  31007. /**
  31008. * Removes unwanted characters from an url
  31009. * @param url defines the url to clean
  31010. * @returns the cleaned url
  31011. */
  31012. static CleanUrl(url: string): string;
  31013. /**
  31014. * Gets or sets a function used to pre-process url before using them to load assets
  31015. */
  31016. static PreprocessUrl: (url: string) => string;
  31017. /**
  31018. * Loads an image as an HTMLImageElement.
  31019. * @param input url string, ArrayBuffer, or Blob to load
  31020. * @param onLoad callback called when the image successfully loads
  31021. * @param onError callback called when the image fails to load
  31022. * @param offlineProvider offline provider for caching
  31023. * @returns the HTMLImageElement of the loaded image
  31024. */
  31025. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31026. /**
  31027. * Loads a file
  31028. * @param url url string, ArrayBuffer, or Blob to load
  31029. * @param onSuccess callback called when the file successfully loads
  31030. * @param onProgress callback called while file is loading (if the server supports this mode)
  31031. * @param offlineProvider defines the offline provider for caching
  31032. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31033. * @param onError callback called when the file fails to load
  31034. * @returns a file request object
  31035. */
  31036. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  31037. /**
  31038. * Load a script (identified by an url). When the url returns, the
  31039. * content of this file is added into a new script element, attached to the DOM (body element)
  31040. * @param scriptUrl defines the url of the script to laod
  31041. * @param onSuccess defines the callback called when the script is loaded
  31042. * @param onError defines the callback to call if an error occurs
  31043. */
  31044. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31045. /**
  31046. * Loads a file from a blob
  31047. * @param fileToLoad defines the blob to use
  31048. * @param callback defines the callback to call when data is loaded
  31049. * @param progressCallback defines the callback to call during loading process
  31050. * @returns a file request object
  31051. */
  31052. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31053. /**
  31054. * Loads a file
  31055. * @param fileToLoad defines the file to load
  31056. * @param callback defines the callback to call when data is loaded
  31057. * @param progressCallBack defines the callback to call during loading process
  31058. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31059. * @returns a file request object
  31060. */
  31061. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31062. /**
  31063. * Creates a data url from a given string content
  31064. * @param content defines the content to convert
  31065. * @returns the new data url link
  31066. */
  31067. static FileAsURL(content: string): string;
  31068. /**
  31069. * Format the given number to a specific decimal format
  31070. * @param value defines the number to format
  31071. * @param decimals defines the number of decimals to use
  31072. * @returns the formatted string
  31073. */
  31074. static Format(value: number, decimals?: number): string;
  31075. /**
  31076. * Checks if a given vector is inside a specific range
  31077. * @param v defines the vector to test
  31078. * @param min defines the minimum range
  31079. * @param max defines the maximum range
  31080. */
  31081. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31082. /**
  31083. * Tries to copy an object by duplicating every property
  31084. * @param source defines the source object
  31085. * @param destination defines the target object
  31086. * @param doNotCopyList defines a list of properties to avoid
  31087. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31088. */
  31089. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31090. /**
  31091. * Gets a boolean indicating if the given object has no own property
  31092. * @param obj defines the object to test
  31093. * @returns true if object has no own property
  31094. */
  31095. static IsEmpty(obj: any): boolean;
  31096. /**
  31097. * Function used to register events at window level
  31098. * @param events defines the events to register
  31099. */
  31100. static RegisterTopRootEvents(events: {
  31101. name: string;
  31102. handler: Nullable<(e: FocusEvent) => any>;
  31103. }[]): void;
  31104. /**
  31105. * Function used to unregister events from window level
  31106. * @param events defines the events to unregister
  31107. */
  31108. static UnregisterTopRootEvents(events: {
  31109. name: string;
  31110. handler: Nullable<(e: FocusEvent) => any>;
  31111. }[]): void;
  31112. /**
  31113. * @ignore
  31114. */
  31115. static _ScreenshotCanvas: HTMLCanvasElement;
  31116. /**
  31117. * Dumps the current bound framebuffer
  31118. * @param width defines the rendering width
  31119. * @param height defines the rendering height
  31120. * @param engine defines the hosting engine
  31121. * @param successCallback defines the callback triggered once the data are available
  31122. * @param mimeType defines the mime type of the result
  31123. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31124. */
  31125. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31126. /**
  31127. * Converts the canvas data to blob.
  31128. * This acts as a polyfill for browsers not supporting the to blob function.
  31129. * @param canvas Defines the canvas to extract the data from
  31130. * @param successCallback Defines the callback triggered once the data are available
  31131. * @param mimeType Defines the mime type of the result
  31132. */
  31133. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31134. /**
  31135. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31136. * @param successCallback defines the callback triggered once the data are available
  31137. * @param mimeType defines the mime type of the result
  31138. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31139. */
  31140. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31141. /**
  31142. * Downloads a blob in the browser
  31143. * @param blob defines the blob to download
  31144. * @param fileName defines the name of the downloaded file
  31145. */
  31146. static Download(blob: Blob, fileName: string): void;
  31147. /**
  31148. * Captures a screenshot of the current rendering
  31149. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31150. * @param engine defines the rendering engine
  31151. * @param camera defines the source camera
  31152. * @param size This parameter can be set to a single number or to an object with the
  31153. * following (optional) properties: precision, width, height. If a single number is passed,
  31154. * it will be used for both width and height. If an object is passed, the screenshot size
  31155. * will be derived from the parameters. The precision property is a multiplier allowing
  31156. * rendering at a higher or lower resolution
  31157. * @param successCallback defines the callback receives a single parameter which contains the
  31158. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31159. * src parameter of an <img> to display it
  31160. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31161. * Check your browser for supported MIME types
  31162. */
  31163. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31164. /**
  31165. * Generates an image screenshot from the specified camera.
  31166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31167. * @param engine The engine to use for rendering
  31168. * @param camera The camera to use for rendering
  31169. * @param size This parameter can be set to a single number or to an object with the
  31170. * following (optional) properties: precision, width, height. If a single number is passed,
  31171. * it will be used for both width and height. If an object is passed, the screenshot size
  31172. * will be derived from the parameters. The precision property is a multiplier allowing
  31173. * rendering at a higher or lower resolution
  31174. * @param successCallback The callback receives a single parameter which contains the
  31175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31176. * src parameter of an <img> to display it
  31177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31178. * Check your browser for supported MIME types
  31179. * @param samples Texture samples (default: 1)
  31180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31181. * @param fileName A name for for the downloaded file.
  31182. */
  31183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31184. /**
  31185. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31186. * Be aware Math.random() could cause collisions, but:
  31187. * "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"
  31188. * @returns a pseudo random id
  31189. */
  31190. static RandomId(): string;
  31191. /**
  31192. * Test if the given uri is a base64 string
  31193. * @param uri The uri to test
  31194. * @return True if the uri is a base64 string or false otherwise
  31195. */
  31196. static IsBase64(uri: string): boolean;
  31197. /**
  31198. * Decode the given base64 uri.
  31199. * @param uri The uri to decode
  31200. * @return The decoded base64 data.
  31201. */
  31202. static DecodeBase64(uri: string): ArrayBuffer;
  31203. /**
  31204. * No log
  31205. */
  31206. static readonly NoneLogLevel: number;
  31207. /**
  31208. * Only message logs
  31209. */
  31210. static readonly MessageLogLevel: number;
  31211. /**
  31212. * Only warning logs
  31213. */
  31214. static readonly WarningLogLevel: number;
  31215. /**
  31216. * Only error logs
  31217. */
  31218. static readonly ErrorLogLevel: number;
  31219. /**
  31220. * All logs
  31221. */
  31222. static readonly AllLogLevel: number;
  31223. /**
  31224. * Gets a value indicating the number of loading errors
  31225. * @ignorenaming
  31226. */
  31227. static readonly errorsCount: number;
  31228. /**
  31229. * Callback called when a new log is added
  31230. */
  31231. static OnNewCacheEntry: (entry: string) => void;
  31232. /**
  31233. * Log a message to the console
  31234. * @param message defines the message to log
  31235. */
  31236. static Log(message: string): void;
  31237. /**
  31238. * Write a warning message to the console
  31239. * @param message defines the message to log
  31240. */
  31241. static Warn(message: string): void;
  31242. /**
  31243. * Write an error message to the console
  31244. * @param message defines the message to log
  31245. */
  31246. static Error(message: string): void;
  31247. /**
  31248. * Gets current log cache (list of logs)
  31249. */
  31250. static readonly LogCache: string;
  31251. /**
  31252. * Clears the log cache
  31253. */
  31254. static ClearLogCache(): void;
  31255. /**
  31256. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31257. */
  31258. static LogLevels: number;
  31259. /**
  31260. * Checks if the loaded document was accessed via `file:`-Protocol.
  31261. * @returns boolean
  31262. */
  31263. static IsFileURL(): boolean;
  31264. /**
  31265. * Checks if the window object exists
  31266. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31267. */
  31268. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31269. /**
  31270. * No performance log
  31271. */
  31272. static readonly PerformanceNoneLogLevel: number;
  31273. /**
  31274. * Use user marks to log performance
  31275. */
  31276. static readonly PerformanceUserMarkLogLevel: number;
  31277. /**
  31278. * Log performance to the console
  31279. */
  31280. static readonly PerformanceConsoleLogLevel: number;
  31281. private static _performance;
  31282. /**
  31283. * Sets the current performance log level
  31284. */
  31285. static PerformanceLogLevel: number;
  31286. private static _StartPerformanceCounterDisabled;
  31287. private static _EndPerformanceCounterDisabled;
  31288. private static _StartUserMark;
  31289. private static _EndUserMark;
  31290. private static _StartPerformanceConsole;
  31291. private static _EndPerformanceConsole;
  31292. /**
  31293. * Injects the @see CustomRequestHeaders into the given request
  31294. * @param request the request that should be used for injection
  31295. */
  31296. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31297. /**
  31298. * Starts a performance counter
  31299. */
  31300. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31301. /**
  31302. * Ends a specific performance coutner
  31303. */
  31304. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31305. /**
  31306. * Gets either window.performance.now() if supported or Date.now() else
  31307. */
  31308. static readonly Now: number;
  31309. /**
  31310. * This method will return the name of the class used to create the instance of the given object.
  31311. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31312. * @param object the object to get the class name from
  31313. * @param isType defines if the object is actually a type
  31314. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31315. */
  31316. static GetClassName(object: any, isType?: boolean): string;
  31317. /**
  31318. * Gets the first element of an array satisfying a given predicate
  31319. * @param array defines the array to browse
  31320. * @param predicate defines the predicate to use
  31321. * @returns null if not found or the element
  31322. */
  31323. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31324. /**
  31325. * This method will return the name of the full name of the class, including its owning module (if any).
  31326. * 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).
  31327. * @param object the object to get the class name from
  31328. * @param isType defines if the object is actually a type
  31329. * @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.
  31330. * @ignorenaming
  31331. */
  31332. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31333. /**
  31334. * Returns a promise that resolves after the given amount of time.
  31335. * @param delay Number of milliseconds to delay
  31336. * @returns Promise that resolves after the given amount of time
  31337. */
  31338. static DelayAsync(delay: number): Promise<void>;
  31339. /**
  31340. * Gets the current gradient from an array of IValueGradient
  31341. * @param ratio defines the current ratio to get
  31342. * @param gradients defines the array of IValueGradient
  31343. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31344. */
  31345. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31346. }
  31347. /**
  31348. * This class is used to track a performance counter which is number based.
  31349. * The user has access to many properties which give statistics of different nature.
  31350. *
  31351. * The implementer can track two kinds of Performance Counter: time and count.
  31352. * 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.
  31353. * 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.
  31354. */
  31355. export class PerfCounter {
  31356. /**
  31357. * Gets or sets a global boolean to turn on and off all the counters
  31358. */
  31359. static Enabled: boolean;
  31360. /**
  31361. * Returns the smallest value ever
  31362. */
  31363. readonly min: number;
  31364. /**
  31365. * Returns the biggest value ever
  31366. */
  31367. readonly max: number;
  31368. /**
  31369. * Returns the average value since the performance counter is running
  31370. */
  31371. readonly average: number;
  31372. /**
  31373. * Returns the average value of the last second the counter was monitored
  31374. */
  31375. readonly lastSecAverage: number;
  31376. /**
  31377. * Returns the current value
  31378. */
  31379. readonly current: number;
  31380. /**
  31381. * Gets the accumulated total
  31382. */
  31383. readonly total: number;
  31384. /**
  31385. * Gets the total value count
  31386. */
  31387. readonly count: number;
  31388. /**
  31389. * Creates a new counter
  31390. */
  31391. constructor();
  31392. /**
  31393. * Call this method to start monitoring a new frame.
  31394. * 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.
  31395. */
  31396. fetchNewFrame(): void;
  31397. /**
  31398. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31399. * @param newCount the count value to add to the monitored count
  31400. * @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.
  31401. */
  31402. addCount(newCount: number, fetchResult: boolean): void;
  31403. /**
  31404. * Start monitoring this performance counter
  31405. */
  31406. beginMonitoring(): void;
  31407. /**
  31408. * Compute the time lapsed since the previous beginMonitoring() call.
  31409. * @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
  31410. */
  31411. endMonitoring(newFrame?: boolean): void;
  31412. private _fetchResult;
  31413. private _startMonitoringTime;
  31414. private _min;
  31415. private _max;
  31416. private _average;
  31417. private _current;
  31418. private _totalValueCount;
  31419. private _totalAccumulated;
  31420. private _lastSecAverage;
  31421. private _lastSecAccumulated;
  31422. private _lastSecTime;
  31423. private _lastSecValueCount;
  31424. }
  31425. /**
  31426. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31427. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31428. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31429. * @param name The name of the class, case should be preserved
  31430. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31431. */
  31432. export function className(name: string, module?: string): (target: Object) => void;
  31433. /**
  31434. * An implementation of a loop for asynchronous functions.
  31435. */
  31436. export class AsyncLoop {
  31437. /**
  31438. * Defines the number of iterations for the loop
  31439. */
  31440. iterations: number;
  31441. /**
  31442. * Defines the current index of the loop.
  31443. */
  31444. index: number;
  31445. private _done;
  31446. private _fn;
  31447. private _successCallback;
  31448. /**
  31449. * Constructor.
  31450. * @param iterations the number of iterations.
  31451. * @param func the function to run each iteration
  31452. * @param successCallback the callback that will be called upon succesful execution
  31453. * @param offset starting offset.
  31454. */
  31455. constructor(
  31456. /**
  31457. * Defines the number of iterations for the loop
  31458. */
  31459. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31460. /**
  31461. * Execute the next iteration. Must be called after the last iteration was finished.
  31462. */
  31463. executeNext(): void;
  31464. /**
  31465. * Break the loop and run the success callback.
  31466. */
  31467. breakLoop(): void;
  31468. /**
  31469. * Create and run an async loop.
  31470. * @param iterations the number of iterations.
  31471. * @param fn the function to run each iteration
  31472. * @param successCallback the callback that will be called upon succesful execution
  31473. * @param offset starting offset.
  31474. * @returns the created async loop object
  31475. */
  31476. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31477. /**
  31478. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31479. * @param iterations total number of iterations
  31480. * @param syncedIterations number of synchronous iterations in each async iteration.
  31481. * @param fn the function to call each iteration.
  31482. * @param callback a success call back that will be called when iterating stops.
  31483. * @param breakFunction a break condition (optional)
  31484. * @param timeout timeout settings for the setTimeout function. default - 0.
  31485. * @returns the created async loop object
  31486. */
  31487. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31488. }
  31489. }
  31490. declare module "babylonjs/Collisions/collisionCoordinator" {
  31491. import { Nullable } from "babylonjs/types";
  31492. import { Scene } from "babylonjs/scene";
  31493. import { Vector3 } from "babylonjs/Maths/math";
  31494. import { Collider } from "babylonjs/Collisions/collider";
  31495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31496. /** @hidden */
  31497. export interface ICollisionCoordinator {
  31498. createCollider(): Collider;
  31499. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31500. init(scene: Scene): void;
  31501. }
  31502. /** @hidden */
  31503. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31504. private _scene;
  31505. private _scaledPosition;
  31506. private _scaledVelocity;
  31507. private _finalPosition;
  31508. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31509. createCollider(): Collider;
  31510. init(scene: Scene): void;
  31511. private _collideWithWorld;
  31512. }
  31513. }
  31514. declare module "babylonjs/Animations/animationGroup" {
  31515. import { Animatable } from "babylonjs/Animations/animatable";
  31516. import { Animation } from "babylonjs/Animations/animation";
  31517. import { Scene, IDisposable } from "babylonjs/scene";
  31518. import { Observable } from "babylonjs/Misc/observable";
  31519. import { Nullable } from "babylonjs/types";
  31520. /**
  31521. * This class defines the direct association between an animation and a target
  31522. */
  31523. export class TargetedAnimation {
  31524. /**
  31525. * Animation to perform
  31526. */
  31527. animation: Animation;
  31528. /**
  31529. * Target to animate
  31530. */
  31531. target: any;
  31532. }
  31533. /**
  31534. * Use this class to create coordinated animations on multiple targets
  31535. */
  31536. export class AnimationGroup implements IDisposable {
  31537. /** The name of the animation group */
  31538. name: string;
  31539. private _scene;
  31540. private _targetedAnimations;
  31541. private _animatables;
  31542. private _from;
  31543. private _to;
  31544. private _isStarted;
  31545. private _isPaused;
  31546. private _speedRatio;
  31547. /**
  31548. * Gets or sets the unique id of the node
  31549. */
  31550. uniqueId: number;
  31551. /**
  31552. * This observable will notify when one animation have ended
  31553. */
  31554. onAnimationEndObservable: Observable<TargetedAnimation>;
  31555. /**
  31556. * Observer raised when one animation loops
  31557. */
  31558. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31559. /**
  31560. * This observable will notify when all animations have ended.
  31561. */
  31562. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31563. /**
  31564. * This observable will notify when all animations have paused.
  31565. */
  31566. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31567. /**
  31568. * This observable will notify when all animations are playing.
  31569. */
  31570. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31571. /**
  31572. * Gets the first frame
  31573. */
  31574. readonly from: number;
  31575. /**
  31576. * Gets the last frame
  31577. */
  31578. readonly to: number;
  31579. /**
  31580. * Define if the animations are started
  31581. */
  31582. readonly isStarted: boolean;
  31583. /**
  31584. * Gets a value indicating that the current group is playing
  31585. */
  31586. readonly isPlaying: boolean;
  31587. /**
  31588. * Gets or sets the speed ratio to use for all animations
  31589. */
  31590. /**
  31591. * Gets or sets the speed ratio to use for all animations
  31592. */
  31593. speedRatio: number;
  31594. /**
  31595. * Gets the targeted animations for this animation group
  31596. */
  31597. readonly targetedAnimations: Array<TargetedAnimation>;
  31598. /**
  31599. * returning the list of animatables controlled by this animation group.
  31600. */
  31601. readonly animatables: Array<Animatable>;
  31602. /**
  31603. * Instantiates a new Animation Group.
  31604. * This helps managing several animations at once.
  31605. * @see http://doc.babylonjs.com/how_to/group
  31606. * @param name Defines the name of the group
  31607. * @param scene Defines the scene the group belongs to
  31608. */
  31609. constructor(
  31610. /** The name of the animation group */
  31611. name: string, scene?: Nullable<Scene>);
  31612. /**
  31613. * Add an animation (with its target) in the group
  31614. * @param animation defines the animation we want to add
  31615. * @param target defines the target of the animation
  31616. * @returns the TargetedAnimation object
  31617. */
  31618. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31619. /**
  31620. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31621. * It can add constant keys at begin or end
  31622. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31623. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31624. * @returns the animation group
  31625. */
  31626. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31627. /**
  31628. * Start all animations on given targets
  31629. * @param loop defines if animations must loop
  31630. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31631. * @param from defines the from key (optional)
  31632. * @param to defines the to key (optional)
  31633. * @returns the current animation group
  31634. */
  31635. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31636. /**
  31637. * Pause all animations
  31638. * @returns the animation group
  31639. */
  31640. pause(): AnimationGroup;
  31641. /**
  31642. * Play all animations to initial state
  31643. * This function will start() the animations if they were not started or will restart() them if they were paused
  31644. * @param loop defines if animations must loop
  31645. * @returns the animation group
  31646. */
  31647. play(loop?: boolean): AnimationGroup;
  31648. /**
  31649. * Reset all animations to initial state
  31650. * @returns the animation group
  31651. */
  31652. reset(): AnimationGroup;
  31653. /**
  31654. * Restart animations from key 0
  31655. * @returns the animation group
  31656. */
  31657. restart(): AnimationGroup;
  31658. /**
  31659. * Stop all animations
  31660. * @returns the animation group
  31661. */
  31662. stop(): AnimationGroup;
  31663. /**
  31664. * Set animation weight for all animatables
  31665. * @param weight defines the weight to use
  31666. * @return the animationGroup
  31667. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31668. */
  31669. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31670. /**
  31671. * Synchronize and normalize all animatables with a source animatable
  31672. * @param root defines the root animatable to synchronize with
  31673. * @return the animationGroup
  31674. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31675. */
  31676. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31677. /**
  31678. * Goes to a specific frame in this animation group
  31679. * @param frame the frame number to go to
  31680. * @return the animationGroup
  31681. */
  31682. goToFrame(frame: number): AnimationGroup;
  31683. /**
  31684. * Dispose all associated resources
  31685. */
  31686. dispose(): void;
  31687. private _checkAnimationGroupEnded;
  31688. /**
  31689. * Clone the current animation group and returns a copy
  31690. * @param newName defines the name of the new group
  31691. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31692. * @returns the new aniamtion group
  31693. */
  31694. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31695. /**
  31696. * Returns a new AnimationGroup object parsed from the source provided.
  31697. * @param parsedAnimationGroup defines the source
  31698. * @param scene defines the scene that will receive the animationGroup
  31699. * @returns a new AnimationGroup
  31700. */
  31701. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31702. /**
  31703. * Returns the string "AnimationGroup"
  31704. * @returns "AnimationGroup"
  31705. */
  31706. getClassName(): string;
  31707. /**
  31708. * Creates a detailled string about the object
  31709. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31710. * @returns a string representing the object
  31711. */
  31712. toString(fullDetails?: boolean): string;
  31713. }
  31714. }
  31715. declare module "babylonjs/scene" {
  31716. import { Nullable } from "babylonjs/types";
  31717. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31718. import { Observable } from "babylonjs/Misc/observable";
  31719. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31720. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31721. import { Geometry } from "babylonjs/Meshes/geometry";
  31722. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31725. import { Mesh } from "babylonjs/Meshes/mesh";
  31726. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31727. import { Bone } from "babylonjs/Bones/bone";
  31728. import { Skeleton } from "babylonjs/Bones/skeleton";
  31729. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31730. import { Camera } from "babylonjs/Cameras/camera";
  31731. import { AbstractScene } from "babylonjs/abstractScene";
  31732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31734. import { Material } from "babylonjs/Materials/material";
  31735. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31736. import { Effect } from "babylonjs/Materials/effect";
  31737. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31738. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31739. import { Light } from "babylonjs/Lights/light";
  31740. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31741. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31742. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31743. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31744. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31745. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31746. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31747. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31748. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31749. import { Engine } from "babylonjs/Engines/engine";
  31750. import { Node } from "babylonjs/node";
  31751. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31752. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31753. import { Ray } from "babylonjs/Culling/ray";
  31754. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31755. import { Animation } from "babylonjs/Animations/animation";
  31756. import { Animatable } from "babylonjs/Animations/animatable";
  31757. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31758. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31759. import { Collider } from "babylonjs/Collisions/collider";
  31760. /**
  31761. * Define an interface for all classes that will hold resources
  31762. */
  31763. export interface IDisposable {
  31764. /**
  31765. * Releases all held resources
  31766. */
  31767. dispose(): void;
  31768. }
  31769. /** Interface defining initialization parameters for Scene class */
  31770. export interface SceneOptions {
  31771. /**
  31772. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31773. * It will improve performance when the number of geometries becomes important.
  31774. */
  31775. useGeometryUniqueIdsMap?: boolean;
  31776. /**
  31777. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31778. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31779. */
  31780. useMaterialMeshMap?: boolean;
  31781. /**
  31782. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31783. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31784. */
  31785. useClonedMeshhMap?: boolean;
  31786. }
  31787. /**
  31788. * Represents a scene to be rendered by the engine.
  31789. * @see http://doc.babylonjs.com/features/scene
  31790. */
  31791. export class Scene extends AbstractScene implements IAnimatable {
  31792. private static _uniqueIdCounter;
  31793. /** The fog is deactivated */
  31794. static readonly FOGMODE_NONE: number;
  31795. /** The fog density is following an exponential function */
  31796. static readonly FOGMODE_EXP: number;
  31797. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31798. static readonly FOGMODE_EXP2: number;
  31799. /** The fog density is following a linear function. */
  31800. static readonly FOGMODE_LINEAR: number;
  31801. /**
  31802. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31803. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31804. */
  31805. static MinDeltaTime: number;
  31806. /**
  31807. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31808. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31809. */
  31810. static MaxDeltaTime: number;
  31811. /**
  31812. * Factory used to create the default material.
  31813. * @param name The name of the material to create
  31814. * @param scene The scene to create the material for
  31815. * @returns The default material
  31816. */
  31817. static DefaultMaterialFactory(scene: Scene): Material;
  31818. /**
  31819. * Factory used to create the a collision coordinator.
  31820. * @returns The collision coordinator
  31821. */
  31822. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31823. /** @hidden */
  31824. readonly _isScene: boolean;
  31825. /**
  31826. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31827. */
  31828. autoClear: boolean;
  31829. /**
  31830. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31831. */
  31832. autoClearDepthAndStencil: boolean;
  31833. /**
  31834. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31835. */
  31836. clearColor: Color4;
  31837. /**
  31838. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31839. */
  31840. ambientColor: Color3;
  31841. /** @hidden */
  31842. _environmentBRDFTexture: BaseTexture;
  31843. /** @hidden */
  31844. protected _environmentTexture: Nullable<BaseTexture>;
  31845. /**
  31846. * Texture used in all pbr material as the reflection texture.
  31847. * As in the majority of the scene they are the same (exception for multi room and so on),
  31848. * this is easier to reference from here than from all the materials.
  31849. */
  31850. /**
  31851. * Texture used in all pbr material as the reflection texture.
  31852. * As in the majority of the scene they are the same (exception for multi room and so on),
  31853. * this is easier to set here than in all the materials.
  31854. */
  31855. environmentTexture: Nullable<BaseTexture>;
  31856. /** @hidden */
  31857. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31858. /**
  31859. * Default image processing configuration used either in the rendering
  31860. * Forward main pass or through the imageProcessingPostProcess if present.
  31861. * As in the majority of the scene they are the same (exception for multi camera),
  31862. * this is easier to reference from here than from all the materials and post process.
  31863. *
  31864. * No setter as we it is a shared configuration, you can set the values instead.
  31865. */
  31866. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31867. private _forceWireframe;
  31868. /**
  31869. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31870. */
  31871. forceWireframe: boolean;
  31872. private _forcePointsCloud;
  31873. /**
  31874. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31875. */
  31876. forcePointsCloud: boolean;
  31877. /**
  31878. * Gets or sets the active clipplane 1
  31879. */
  31880. clipPlane: Nullable<Plane>;
  31881. /**
  31882. * Gets or sets the active clipplane 2
  31883. */
  31884. clipPlane2: Nullable<Plane>;
  31885. /**
  31886. * Gets or sets the active clipplane 3
  31887. */
  31888. clipPlane3: Nullable<Plane>;
  31889. /**
  31890. * Gets or sets the active clipplane 4
  31891. */
  31892. clipPlane4: Nullable<Plane>;
  31893. /**
  31894. * Gets or sets a boolean indicating if animations are enabled
  31895. */
  31896. animationsEnabled: boolean;
  31897. private _animationPropertiesOverride;
  31898. /**
  31899. * Gets or sets the animation properties override
  31900. */
  31901. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31902. /**
  31903. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31904. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31905. */
  31906. useConstantAnimationDeltaTime: boolean;
  31907. /**
  31908. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31909. * Please note that it requires to run a ray cast through the scene on every frame
  31910. */
  31911. constantlyUpdateMeshUnderPointer: boolean;
  31912. /**
  31913. * Defines the HTML cursor to use when hovering over interactive elements
  31914. */
  31915. hoverCursor: string;
  31916. /**
  31917. * Defines the HTML default cursor to use (empty by default)
  31918. */
  31919. defaultCursor: string;
  31920. /**
  31921. * This is used to call preventDefault() on pointer down
  31922. * in order to block unwanted artifacts like system double clicks
  31923. */
  31924. preventDefaultOnPointerDown: boolean;
  31925. /**
  31926. * This is used to call preventDefault() on pointer up
  31927. * in order to block unwanted artifacts like system double clicks
  31928. */
  31929. preventDefaultOnPointerUp: boolean;
  31930. /**
  31931. * Gets or sets user defined metadata
  31932. */
  31933. metadata: any;
  31934. /**
  31935. * For internal use only. Please do not use.
  31936. */
  31937. reservedDataStore: any;
  31938. /**
  31939. * Gets the name of the plugin used to load this scene (null by default)
  31940. */
  31941. loadingPluginName: string;
  31942. /**
  31943. * Use this array to add regular expressions used to disable offline support for specific urls
  31944. */
  31945. disableOfflineSupportExceptionRules: RegExp[];
  31946. /**
  31947. * An event triggered when the scene is disposed.
  31948. */
  31949. onDisposeObservable: Observable<Scene>;
  31950. private _onDisposeObserver;
  31951. /** Sets a function to be executed when this scene is disposed. */
  31952. onDispose: () => void;
  31953. /**
  31954. * An event triggered before rendering the scene (right after animations and physics)
  31955. */
  31956. onBeforeRenderObservable: Observable<Scene>;
  31957. private _onBeforeRenderObserver;
  31958. /** Sets a function to be executed before rendering this scene */
  31959. beforeRender: Nullable<() => void>;
  31960. /**
  31961. * An event triggered after rendering the scene
  31962. */
  31963. onAfterRenderObservable: Observable<Scene>;
  31964. private _onAfterRenderObserver;
  31965. /** Sets a function to be executed after rendering this scene */
  31966. afterRender: Nullable<() => void>;
  31967. /**
  31968. * An event triggered before animating the scene
  31969. */
  31970. onBeforeAnimationsObservable: Observable<Scene>;
  31971. /**
  31972. * An event triggered after animations processing
  31973. */
  31974. onAfterAnimationsObservable: Observable<Scene>;
  31975. /**
  31976. * An event triggered before draw calls are ready to be sent
  31977. */
  31978. onBeforeDrawPhaseObservable: Observable<Scene>;
  31979. /**
  31980. * An event triggered after draw calls have been sent
  31981. */
  31982. onAfterDrawPhaseObservable: Observable<Scene>;
  31983. /**
  31984. * An event triggered when the scene is ready
  31985. */
  31986. onReadyObservable: Observable<Scene>;
  31987. /**
  31988. * An event triggered before rendering a camera
  31989. */
  31990. onBeforeCameraRenderObservable: Observable<Camera>;
  31991. private _onBeforeCameraRenderObserver;
  31992. /** Sets a function to be executed before rendering a camera*/
  31993. beforeCameraRender: () => void;
  31994. /**
  31995. * An event triggered after rendering a camera
  31996. */
  31997. onAfterCameraRenderObservable: Observable<Camera>;
  31998. private _onAfterCameraRenderObserver;
  31999. /** Sets a function to be executed after rendering a camera*/
  32000. afterCameraRender: () => void;
  32001. /**
  32002. * An event triggered when active meshes evaluation is about to start
  32003. */
  32004. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32005. /**
  32006. * An event triggered when active meshes evaluation is done
  32007. */
  32008. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32009. /**
  32010. * An event triggered when particles rendering is about to start
  32011. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32012. */
  32013. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32014. /**
  32015. * An event triggered when particles rendering is done
  32016. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32017. */
  32018. onAfterParticlesRenderingObservable: Observable<Scene>;
  32019. /**
  32020. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32021. */
  32022. onDataLoadedObservable: Observable<Scene>;
  32023. /**
  32024. * An event triggered when a camera is created
  32025. */
  32026. onNewCameraAddedObservable: Observable<Camera>;
  32027. /**
  32028. * An event triggered when a camera is removed
  32029. */
  32030. onCameraRemovedObservable: Observable<Camera>;
  32031. /**
  32032. * An event triggered when a light is created
  32033. */
  32034. onNewLightAddedObservable: Observable<Light>;
  32035. /**
  32036. * An event triggered when a light is removed
  32037. */
  32038. onLightRemovedObservable: Observable<Light>;
  32039. /**
  32040. * An event triggered when a geometry is created
  32041. */
  32042. onNewGeometryAddedObservable: Observable<Geometry>;
  32043. /**
  32044. * An event triggered when a geometry is removed
  32045. */
  32046. onGeometryRemovedObservable: Observable<Geometry>;
  32047. /**
  32048. * An event triggered when a transform node is created
  32049. */
  32050. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32051. /**
  32052. * An event triggered when a transform node is removed
  32053. */
  32054. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32055. /**
  32056. * An event triggered when a mesh is created
  32057. */
  32058. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32059. /**
  32060. * An event triggered when a mesh is removed
  32061. */
  32062. onMeshRemovedObservable: Observable<AbstractMesh>;
  32063. /**
  32064. * An event triggered when a material is created
  32065. */
  32066. onNewMaterialAddedObservable: Observable<Material>;
  32067. /**
  32068. * An event triggered when a material is removed
  32069. */
  32070. onMaterialRemovedObservable: Observable<Material>;
  32071. /**
  32072. * An event triggered when a texture is created
  32073. */
  32074. onNewTextureAddedObservable: Observable<BaseTexture>;
  32075. /**
  32076. * An event triggered when a texture is removed
  32077. */
  32078. onTextureRemovedObservable: Observable<BaseTexture>;
  32079. /**
  32080. * An event triggered when render targets are about to be rendered
  32081. * Can happen multiple times per frame.
  32082. */
  32083. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32084. /**
  32085. * An event triggered when render targets were rendered.
  32086. * Can happen multiple times per frame.
  32087. */
  32088. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32089. /**
  32090. * An event triggered before calculating deterministic simulation step
  32091. */
  32092. onBeforeStepObservable: Observable<Scene>;
  32093. /**
  32094. * An event triggered after calculating deterministic simulation step
  32095. */
  32096. onAfterStepObservable: Observable<Scene>;
  32097. /**
  32098. * An event triggered when the activeCamera property is updated
  32099. */
  32100. onActiveCameraChanged: Observable<Scene>;
  32101. /**
  32102. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32103. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32104. * 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)
  32105. */
  32106. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32107. /**
  32108. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32109. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32110. * 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)
  32111. */
  32112. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32113. /**
  32114. * This Observable will when a mesh has been imported into the scene.
  32115. */
  32116. onMeshImportedObservable: Observable<AbstractMesh>;
  32117. /**
  32118. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32119. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32120. */
  32121. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32122. /** @hidden */
  32123. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32124. /**
  32125. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32126. */
  32127. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32128. /**
  32129. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32130. */
  32131. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32132. /**
  32133. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32134. */
  32135. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32136. private _onPointerMove;
  32137. private _onPointerDown;
  32138. private _onPointerUp;
  32139. /** Callback called when a pointer move is detected */
  32140. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32141. /** Callback called when a pointer down is detected */
  32142. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32143. /** Callback called when a pointer up is detected */
  32144. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32145. /** Callback called when a pointer pick is detected */
  32146. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32147. /**
  32148. * 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).
  32149. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32150. */
  32151. onPrePointerObservable: Observable<PointerInfoPre>;
  32152. /**
  32153. * Observable event triggered each time an input event is received from the rendering canvas
  32154. */
  32155. onPointerObservable: Observable<PointerInfo>;
  32156. /**
  32157. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32158. */
  32159. readonly unTranslatedPointer: Vector2;
  32160. /** The distance in pixel that you have to move to prevent some events */
  32161. static DragMovementThreshold: number;
  32162. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32163. static LongPressDelay: number;
  32164. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32165. static DoubleClickDelay: number;
  32166. /** If you need to check double click without raising a single click at first click, enable this flag */
  32167. static ExclusiveDoubleClickMode: boolean;
  32168. private _initClickEvent;
  32169. private _initActionManager;
  32170. private _delayedSimpleClick;
  32171. private _delayedSimpleClickTimeout;
  32172. private _previousDelayedSimpleClickTimeout;
  32173. private _meshPickProceed;
  32174. private _previousButtonPressed;
  32175. private _currentPickResult;
  32176. private _previousPickResult;
  32177. private _totalPointersPressed;
  32178. private _doubleClickOccured;
  32179. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32180. cameraToUseForPointers: Nullable<Camera>;
  32181. private _pointerX;
  32182. private _pointerY;
  32183. private _unTranslatedPointerX;
  32184. private _unTranslatedPointerY;
  32185. private _startingPointerPosition;
  32186. private _previousStartingPointerPosition;
  32187. private _startingPointerTime;
  32188. private _previousStartingPointerTime;
  32189. private _pointerCaptures;
  32190. private _timeAccumulator;
  32191. private _currentStepId;
  32192. private _currentInternalStep;
  32193. /** @hidden */
  32194. _mirroredCameraPosition: Nullable<Vector3>;
  32195. /**
  32196. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32197. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32198. */
  32199. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32200. /**
  32201. * Observable event triggered each time an keyboard event is received from the hosting window
  32202. */
  32203. onKeyboardObservable: Observable<KeyboardInfo>;
  32204. private _onKeyDown;
  32205. private _onKeyUp;
  32206. private _onCanvasFocusObserver;
  32207. private _onCanvasBlurObserver;
  32208. private _useRightHandedSystem;
  32209. /**
  32210. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32211. */
  32212. useRightHandedSystem: boolean;
  32213. /**
  32214. * Sets the step Id used by deterministic lock step
  32215. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32216. * @param newStepId defines the step Id
  32217. */
  32218. setStepId(newStepId: number): void;
  32219. /**
  32220. * Gets the step Id used by deterministic lock step
  32221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32222. * @returns the step Id
  32223. */
  32224. getStepId(): number;
  32225. /**
  32226. * Gets the internal step used by deterministic lock step
  32227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32228. * @returns the internal step
  32229. */
  32230. getInternalStep(): number;
  32231. private _fogEnabled;
  32232. /**
  32233. * Gets or sets a boolean indicating if fog is enabled on this scene
  32234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32235. * (Default is true)
  32236. */
  32237. fogEnabled: boolean;
  32238. private _fogMode;
  32239. /**
  32240. * Gets or sets the fog mode to use
  32241. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32242. * | mode | value |
  32243. * | --- | --- |
  32244. * | FOGMODE_NONE | 0 |
  32245. * | FOGMODE_EXP | 1 |
  32246. * | FOGMODE_EXP2 | 2 |
  32247. * | FOGMODE_LINEAR | 3 |
  32248. */
  32249. fogMode: number;
  32250. /**
  32251. * Gets or sets the fog color to use
  32252. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32253. * (Default is Color3(0.2, 0.2, 0.3))
  32254. */
  32255. fogColor: Color3;
  32256. /**
  32257. * Gets or sets the fog density to use
  32258. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32259. * (Default is 0.1)
  32260. */
  32261. fogDensity: number;
  32262. /**
  32263. * Gets or sets the fog start distance to use
  32264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32265. * (Default is 0)
  32266. */
  32267. fogStart: number;
  32268. /**
  32269. * Gets or sets the fog end distance to use
  32270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32271. * (Default is 1000)
  32272. */
  32273. fogEnd: number;
  32274. private _shadowsEnabled;
  32275. /**
  32276. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32277. */
  32278. shadowsEnabled: boolean;
  32279. private _lightsEnabled;
  32280. /**
  32281. * Gets or sets a boolean indicating if lights are enabled on this scene
  32282. */
  32283. lightsEnabled: boolean;
  32284. /** All of the active cameras added to this scene. */
  32285. activeCameras: Camera[];
  32286. private _activeCamera;
  32287. /** Gets or sets the current active camera */
  32288. activeCamera: Nullable<Camera>;
  32289. private _defaultMaterial;
  32290. /** The default material used on meshes when no material is affected */
  32291. /** The default material used on meshes when no material is affected */
  32292. defaultMaterial: Material;
  32293. private _texturesEnabled;
  32294. /**
  32295. * Gets or sets a boolean indicating if textures are enabled on this scene
  32296. */
  32297. texturesEnabled: boolean;
  32298. /**
  32299. * Gets or sets a boolean indicating if particles are enabled on this scene
  32300. */
  32301. particlesEnabled: boolean;
  32302. /**
  32303. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32304. */
  32305. spritesEnabled: boolean;
  32306. private _skeletonsEnabled;
  32307. /**
  32308. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32309. */
  32310. skeletonsEnabled: boolean;
  32311. /**
  32312. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32313. */
  32314. lensFlaresEnabled: boolean;
  32315. /**
  32316. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32318. */
  32319. collisionsEnabled: boolean;
  32320. private _collisionCoordinator;
  32321. /** @hidden */
  32322. readonly collisionCoordinator: ICollisionCoordinator;
  32323. /**
  32324. * Defines the gravity applied to this scene (used only for collisions)
  32325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32326. */
  32327. gravity: Vector3;
  32328. /**
  32329. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32330. */
  32331. postProcessesEnabled: boolean;
  32332. /**
  32333. * The list of postprocesses added to the scene
  32334. */
  32335. postProcesses: PostProcess[];
  32336. /**
  32337. * Gets the current postprocess manager
  32338. */
  32339. postProcessManager: PostProcessManager;
  32340. /**
  32341. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32342. */
  32343. renderTargetsEnabled: boolean;
  32344. /**
  32345. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32346. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32347. */
  32348. dumpNextRenderTargets: boolean;
  32349. /**
  32350. * The list of user defined render targets added to the scene
  32351. */
  32352. customRenderTargets: RenderTargetTexture[];
  32353. /**
  32354. * Defines if texture loading must be delayed
  32355. * If true, textures will only be loaded when they need to be rendered
  32356. */
  32357. useDelayedTextureLoading: boolean;
  32358. /**
  32359. * Gets the list of meshes imported to the scene through SceneLoader
  32360. */
  32361. importedMeshesFiles: String[];
  32362. /**
  32363. * Gets or sets a boolean indicating if probes are enabled on this scene
  32364. */
  32365. probesEnabled: boolean;
  32366. /**
  32367. * Gets or sets the current offline provider to use to store scene data
  32368. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32369. */
  32370. offlineProvider: IOfflineProvider;
  32371. /**
  32372. * Gets or sets the action manager associated with the scene
  32373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32374. */
  32375. actionManager: AbstractActionManager;
  32376. private _meshesForIntersections;
  32377. /**
  32378. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32379. */
  32380. proceduralTexturesEnabled: boolean;
  32381. private _engine;
  32382. private _totalVertices;
  32383. /** @hidden */
  32384. _activeIndices: PerfCounter;
  32385. /** @hidden */
  32386. _activeParticles: PerfCounter;
  32387. /** @hidden */
  32388. _activeBones: PerfCounter;
  32389. private _animationRatio;
  32390. /** @hidden */
  32391. _animationTimeLast: number;
  32392. /** @hidden */
  32393. _animationTime: number;
  32394. /**
  32395. * Gets or sets a general scale for animation speed
  32396. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32397. */
  32398. animationTimeScale: number;
  32399. /** @hidden */
  32400. _cachedMaterial: Nullable<Material>;
  32401. /** @hidden */
  32402. _cachedEffect: Nullable<Effect>;
  32403. /** @hidden */
  32404. _cachedVisibility: Nullable<number>;
  32405. private _renderId;
  32406. private _frameId;
  32407. private _executeWhenReadyTimeoutId;
  32408. private _intermediateRendering;
  32409. private _viewUpdateFlag;
  32410. private _projectionUpdateFlag;
  32411. private _alternateViewUpdateFlag;
  32412. private _alternateProjectionUpdateFlag;
  32413. /** @hidden */
  32414. _toBeDisposed: Nullable<IDisposable>[];
  32415. private _activeRequests;
  32416. /** @hidden */
  32417. _pendingData: any[];
  32418. private _isDisposed;
  32419. /**
  32420. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32421. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32422. */
  32423. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32424. private _activeMeshes;
  32425. private _processedMaterials;
  32426. private _renderTargets;
  32427. /** @hidden */
  32428. _activeParticleSystems: SmartArray<IParticleSystem>;
  32429. private _activeSkeletons;
  32430. private _softwareSkinnedMeshes;
  32431. private _renderingManager;
  32432. /** @hidden */
  32433. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32434. private _transformMatrix;
  32435. private _sceneUbo;
  32436. private _alternateSceneUbo;
  32437. private _viewMatrix;
  32438. private _projectionMatrix;
  32439. private _alternateViewMatrix;
  32440. private _alternateProjectionMatrix;
  32441. private _alternateTransformMatrix;
  32442. private _useAlternateCameraConfiguration;
  32443. private _alternateRendering;
  32444. private _wheelEventName;
  32445. /** @hidden */
  32446. _forcedViewPosition: Nullable<Vector3>;
  32447. /** @hidden */
  32448. readonly _isAlternateRenderingEnabled: boolean;
  32449. private _frustumPlanes;
  32450. /**
  32451. * Gets the list of frustum planes (built from the active camera)
  32452. */
  32453. readonly frustumPlanes: Plane[];
  32454. /**
  32455. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32456. * This is useful if there are more lights that the maximum simulteanous authorized
  32457. */
  32458. requireLightSorting: boolean;
  32459. /** @hidden */
  32460. readonly useMaterialMeshMap: boolean;
  32461. /** @hidden */
  32462. readonly useClonedMeshhMap: boolean;
  32463. private _pointerOverMesh;
  32464. private _pickedDownMesh;
  32465. private _pickedUpMesh;
  32466. private _externalData;
  32467. private _uid;
  32468. /**
  32469. * @hidden
  32470. * Backing store of defined scene components.
  32471. */
  32472. _components: ISceneComponent[];
  32473. /**
  32474. * @hidden
  32475. * Backing store of defined scene components.
  32476. */
  32477. _serializableComponents: ISceneSerializableComponent[];
  32478. /**
  32479. * List of components to register on the next registration step.
  32480. */
  32481. private _transientComponents;
  32482. /**
  32483. * Registers the transient components if needed.
  32484. */
  32485. private _registerTransientComponents;
  32486. /**
  32487. * @hidden
  32488. * Add a component to the scene.
  32489. * Note that the ccomponent could be registered on th next frame if this is called after
  32490. * the register component stage.
  32491. * @param component Defines the component to add to the scene
  32492. */
  32493. _addComponent(component: ISceneComponent): void;
  32494. /**
  32495. * @hidden
  32496. * Gets a component from the scene.
  32497. * @param name defines the name of the component to retrieve
  32498. * @returns the component or null if not present
  32499. */
  32500. _getComponent(name: string): Nullable<ISceneComponent>;
  32501. /**
  32502. * @hidden
  32503. * Defines the actions happening before camera updates.
  32504. */
  32505. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32506. /**
  32507. * @hidden
  32508. * Defines the actions happening before clear the canvas.
  32509. */
  32510. _beforeClearStage: Stage<SimpleStageAction>;
  32511. /**
  32512. * @hidden
  32513. * Defines the actions when collecting render targets for the frame.
  32514. */
  32515. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32516. /**
  32517. * @hidden
  32518. * Defines the actions happening for one camera in the frame.
  32519. */
  32520. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32521. /**
  32522. * @hidden
  32523. * Defines the actions happening during the per mesh ready checks.
  32524. */
  32525. _isReadyForMeshStage: Stage<MeshStageAction>;
  32526. /**
  32527. * @hidden
  32528. * Defines the actions happening before evaluate active mesh checks.
  32529. */
  32530. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32531. /**
  32532. * @hidden
  32533. * Defines the actions happening during the evaluate sub mesh checks.
  32534. */
  32535. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32536. /**
  32537. * @hidden
  32538. * Defines the actions happening during the active mesh stage.
  32539. */
  32540. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32541. /**
  32542. * @hidden
  32543. * Defines the actions happening during the per camera render target step.
  32544. */
  32545. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32546. /**
  32547. * @hidden
  32548. * Defines the actions happening just before the active camera is drawing.
  32549. */
  32550. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32551. /**
  32552. * @hidden
  32553. * Defines the actions happening just before a render target is drawing.
  32554. */
  32555. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32556. /**
  32557. * @hidden
  32558. * Defines the actions happening just before a rendering group is drawing.
  32559. */
  32560. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32561. /**
  32562. * @hidden
  32563. * Defines the actions happening just before a mesh is drawing.
  32564. */
  32565. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32566. /**
  32567. * @hidden
  32568. * Defines the actions happening just after a mesh has been drawn.
  32569. */
  32570. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32571. /**
  32572. * @hidden
  32573. * Defines the actions happening just after a rendering group has been drawn.
  32574. */
  32575. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32576. /**
  32577. * @hidden
  32578. * Defines the actions happening just after the active camera has been drawn.
  32579. */
  32580. _afterCameraDrawStage: Stage<CameraStageAction>;
  32581. /**
  32582. * @hidden
  32583. * Defines the actions happening just after a render target has been drawn.
  32584. */
  32585. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32586. /**
  32587. * @hidden
  32588. * Defines the actions happening just after rendering all cameras and computing intersections.
  32589. */
  32590. _afterRenderStage: Stage<SimpleStageAction>;
  32591. /**
  32592. * @hidden
  32593. * Defines the actions happening when a pointer move event happens.
  32594. */
  32595. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32596. /**
  32597. * @hidden
  32598. * Defines the actions happening when a pointer down event happens.
  32599. */
  32600. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32601. /**
  32602. * @hidden
  32603. * Defines the actions happening when a pointer up event happens.
  32604. */
  32605. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32606. /**
  32607. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32608. */
  32609. private geometriesByUniqueId;
  32610. /**
  32611. * Creates a new Scene
  32612. * @param engine defines the engine to use to render this scene
  32613. * @param options defines the scene options
  32614. */
  32615. constructor(engine: Engine, options?: SceneOptions);
  32616. private _defaultMeshCandidates;
  32617. /**
  32618. * @hidden
  32619. */
  32620. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32621. private _defaultSubMeshCandidates;
  32622. /**
  32623. * @hidden
  32624. */
  32625. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32626. /**
  32627. * Sets the default candidate providers for the scene.
  32628. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32629. * and getCollidingSubMeshCandidates to their default function
  32630. */
  32631. setDefaultCandidateProviders(): void;
  32632. /**
  32633. * Gets the mesh that is currently under the pointer
  32634. */
  32635. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32636. /**
  32637. * Gets or sets the current on-screen X position of the pointer
  32638. */
  32639. pointerX: number;
  32640. /**
  32641. * Gets or sets the current on-screen Y position of the pointer
  32642. */
  32643. pointerY: number;
  32644. /**
  32645. * Gets the cached material (ie. the latest rendered one)
  32646. * @returns the cached material
  32647. */
  32648. getCachedMaterial(): Nullable<Material>;
  32649. /**
  32650. * Gets the cached effect (ie. the latest rendered one)
  32651. * @returns the cached effect
  32652. */
  32653. getCachedEffect(): Nullable<Effect>;
  32654. /**
  32655. * Gets the cached visibility state (ie. the latest rendered one)
  32656. * @returns the cached visibility state
  32657. */
  32658. getCachedVisibility(): Nullable<number>;
  32659. /**
  32660. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32661. * @param material defines the current material
  32662. * @param effect defines the current effect
  32663. * @param visibility defines the current visibility state
  32664. * @returns true if one parameter is not cached
  32665. */
  32666. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32667. /**
  32668. * Gets the engine associated with the scene
  32669. * @returns an Engine
  32670. */
  32671. getEngine(): Engine;
  32672. /**
  32673. * Gets the total number of vertices rendered per frame
  32674. * @returns the total number of vertices rendered per frame
  32675. */
  32676. getTotalVertices(): number;
  32677. /**
  32678. * Gets the performance counter for total vertices
  32679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32680. */
  32681. readonly totalVerticesPerfCounter: PerfCounter;
  32682. /**
  32683. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32684. * @returns the total number of active indices rendered per frame
  32685. */
  32686. getActiveIndices(): number;
  32687. /**
  32688. * Gets the performance counter for active indices
  32689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32690. */
  32691. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32692. /**
  32693. * Gets the total number of active particles rendered per frame
  32694. * @returns the total number of active particles rendered per frame
  32695. */
  32696. getActiveParticles(): number;
  32697. /**
  32698. * Gets the performance counter for active particles
  32699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32700. */
  32701. readonly activeParticlesPerfCounter: PerfCounter;
  32702. /**
  32703. * Gets the total number of active bones rendered per frame
  32704. * @returns the total number of active bones rendered per frame
  32705. */
  32706. getActiveBones(): number;
  32707. /**
  32708. * Gets the performance counter for active bones
  32709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32710. */
  32711. readonly activeBonesPerfCounter: PerfCounter;
  32712. /**
  32713. * Gets the array of active meshes
  32714. * @returns an array of AbstractMesh
  32715. */
  32716. getActiveMeshes(): SmartArray<AbstractMesh>;
  32717. /**
  32718. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32719. * @returns a number
  32720. */
  32721. getAnimationRatio(): number;
  32722. /**
  32723. * Gets an unique Id for the current render phase
  32724. * @returns a number
  32725. */
  32726. getRenderId(): number;
  32727. /**
  32728. * Gets an unique Id for the current frame
  32729. * @returns a number
  32730. */
  32731. getFrameId(): number;
  32732. /** Call this function if you want to manually increment the render Id*/
  32733. incrementRenderId(): void;
  32734. private _updatePointerPosition;
  32735. private _createUbo;
  32736. private _createAlternateUbo;
  32737. private _setRayOnPointerInfo;
  32738. /**
  32739. * Use this method to simulate a pointer move on a mesh
  32740. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32741. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32742. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32743. * @returns the current scene
  32744. */
  32745. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32746. private _processPointerMove;
  32747. private _checkPrePointerObservable;
  32748. /**
  32749. * Use this method to simulate a pointer down on a mesh
  32750. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32751. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32752. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32753. * @returns the current scene
  32754. */
  32755. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32756. private _processPointerDown;
  32757. /**
  32758. * Use this method to simulate a pointer up on a mesh
  32759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32762. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32763. * @returns the current scene
  32764. */
  32765. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32766. private _processPointerUp;
  32767. /**
  32768. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32769. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32770. * @returns true if the pointer was captured
  32771. */
  32772. isPointerCaptured(pointerId?: number): boolean;
  32773. /** @hidden */
  32774. _isPointerSwiping(): boolean;
  32775. /**
  32776. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32777. * @param attachUp defines if you want to attach events to pointerup
  32778. * @param attachDown defines if you want to attach events to pointerdown
  32779. * @param attachMove defines if you want to attach events to pointermove
  32780. */
  32781. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32782. /** Detaches all event handlers*/
  32783. detachControl(): void;
  32784. /**
  32785. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32786. * Delay loaded resources are not taking in account
  32787. * @return true if all required resources are ready
  32788. */
  32789. isReady(): boolean;
  32790. /** Resets all cached information relative to material (including effect and visibility) */
  32791. resetCachedMaterial(): void;
  32792. /**
  32793. * Registers a function to be called before every frame render
  32794. * @param func defines the function to register
  32795. */
  32796. registerBeforeRender(func: () => void): void;
  32797. /**
  32798. * Unregisters a function called before every frame render
  32799. * @param func defines the function to unregister
  32800. */
  32801. unregisterBeforeRender(func: () => void): void;
  32802. /**
  32803. * Registers a function to be called after every frame render
  32804. * @param func defines the function to register
  32805. */
  32806. registerAfterRender(func: () => void): void;
  32807. /**
  32808. * Unregisters a function called after every frame render
  32809. * @param func defines the function to unregister
  32810. */
  32811. unregisterAfterRender(func: () => void): void;
  32812. private _executeOnceBeforeRender;
  32813. /**
  32814. * The provided function will run before render once and will be disposed afterwards.
  32815. * A timeout delay can be provided so that the function will be executed in N ms.
  32816. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32817. * @param func The function to be executed.
  32818. * @param timeout optional delay in ms
  32819. */
  32820. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32821. /** @hidden */
  32822. _addPendingData(data: any): void;
  32823. /** @hidden */
  32824. _removePendingData(data: any): void;
  32825. /**
  32826. * Returns the number of items waiting to be loaded
  32827. * @returns the number of items waiting to be loaded
  32828. */
  32829. getWaitingItemsCount(): number;
  32830. /**
  32831. * Returns a boolean indicating if the scene is still loading data
  32832. */
  32833. readonly isLoading: boolean;
  32834. /**
  32835. * Registers a function to be executed when the scene is ready
  32836. * @param {Function} func - the function to be executed
  32837. */
  32838. executeWhenReady(func: () => void): void;
  32839. /**
  32840. * Returns a promise that resolves when the scene is ready
  32841. * @returns A promise that resolves when the scene is ready
  32842. */
  32843. whenReadyAsync(): Promise<void>;
  32844. /** @hidden */
  32845. _checkIsReady(): void;
  32846. /**
  32847. * Gets all animatable attached to the scene
  32848. */
  32849. readonly animatables: Animatable[];
  32850. /**
  32851. * Resets the last animation time frame.
  32852. * Useful to override when animations start running when loading a scene for the first time.
  32853. */
  32854. resetLastAnimationTimeFrame(): void;
  32855. /** @hidden */
  32856. _switchToAlternateCameraConfiguration(active: boolean): void;
  32857. /**
  32858. * Gets the current view matrix
  32859. * @returns a Matrix
  32860. */
  32861. getViewMatrix(): Matrix;
  32862. /**
  32863. * Gets the current projection matrix
  32864. * @returns a Matrix
  32865. */
  32866. getProjectionMatrix(): Matrix;
  32867. /**
  32868. * Gets the current transform matrix
  32869. * @returns a Matrix made of View * Projection
  32870. */
  32871. getTransformMatrix(): Matrix;
  32872. /**
  32873. * Sets the current transform matrix
  32874. * @param view defines the View matrix to use
  32875. * @param projection defines the Projection matrix to use
  32876. */
  32877. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32878. /** @hidden */
  32879. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32880. /**
  32881. * Gets the uniform buffer used to store scene data
  32882. * @returns a UniformBuffer
  32883. */
  32884. getSceneUniformBuffer(): UniformBuffer;
  32885. /**
  32886. * Gets an unique (relatively to the current scene) Id
  32887. * @returns an unique number for the scene
  32888. */
  32889. getUniqueId(): number;
  32890. /**
  32891. * Add a mesh to the list of scene's meshes
  32892. * @param newMesh defines the mesh to add
  32893. * @param recursive if all child meshes should also be added to the scene
  32894. */
  32895. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32896. /**
  32897. * Remove a mesh for the list of scene's meshes
  32898. * @param toRemove defines the mesh to remove
  32899. * @param recursive if all child meshes should also be removed from the scene
  32900. * @returns the index where the mesh was in the mesh list
  32901. */
  32902. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32903. /**
  32904. * Add a transform node to the list of scene's transform nodes
  32905. * @param newTransformNode defines the transform node to add
  32906. */
  32907. addTransformNode(newTransformNode: TransformNode): void;
  32908. /**
  32909. * Remove a transform node for the list of scene's transform nodes
  32910. * @param toRemove defines the transform node to remove
  32911. * @returns the index where the transform node was in the transform node list
  32912. */
  32913. removeTransformNode(toRemove: TransformNode): number;
  32914. /**
  32915. * Remove a skeleton for the list of scene's skeletons
  32916. * @param toRemove defines the skeleton to remove
  32917. * @returns the index where the skeleton was in the skeleton list
  32918. */
  32919. removeSkeleton(toRemove: Skeleton): number;
  32920. /**
  32921. * Remove a morph target for the list of scene's morph targets
  32922. * @param toRemove defines the morph target to remove
  32923. * @returns the index where the morph target was in the morph target list
  32924. */
  32925. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32926. /**
  32927. * Remove a light for the list of scene's lights
  32928. * @param toRemove defines the light to remove
  32929. * @returns the index where the light was in the light list
  32930. */
  32931. removeLight(toRemove: Light): number;
  32932. /**
  32933. * Remove a camera for the list of scene's cameras
  32934. * @param toRemove defines the camera to remove
  32935. * @returns the index where the camera was in the camera list
  32936. */
  32937. removeCamera(toRemove: Camera): number;
  32938. /**
  32939. * Remove a particle system for the list of scene's particle systems
  32940. * @param toRemove defines the particle system to remove
  32941. * @returns the index where the particle system was in the particle system list
  32942. */
  32943. removeParticleSystem(toRemove: IParticleSystem): number;
  32944. /**
  32945. * Remove a animation for the list of scene's animations
  32946. * @param toRemove defines the animation to remove
  32947. * @returns the index where the animation was in the animation list
  32948. */
  32949. removeAnimation(toRemove: Animation): number;
  32950. /**
  32951. * Removes the given animation group from this scene.
  32952. * @param toRemove The animation group to remove
  32953. * @returns The index of the removed animation group
  32954. */
  32955. removeAnimationGroup(toRemove: AnimationGroup): number;
  32956. /**
  32957. * Removes the given multi-material from this scene.
  32958. * @param toRemove The multi-material to remove
  32959. * @returns The index of the removed multi-material
  32960. */
  32961. removeMultiMaterial(toRemove: MultiMaterial): number;
  32962. /**
  32963. * Removes the given material from this scene.
  32964. * @param toRemove The material to remove
  32965. * @returns The index of the removed material
  32966. */
  32967. removeMaterial(toRemove: Material): number;
  32968. /**
  32969. * Removes the given action manager from this scene.
  32970. * @param toRemove The action manager to remove
  32971. * @returns The index of the removed action manager
  32972. */
  32973. removeActionManager(toRemove: AbstractActionManager): number;
  32974. /**
  32975. * Removes the given texture from this scene.
  32976. * @param toRemove The texture to remove
  32977. * @returns The index of the removed texture
  32978. */
  32979. removeTexture(toRemove: BaseTexture): number;
  32980. /**
  32981. * Adds the given light to this scene
  32982. * @param newLight The light to add
  32983. */
  32984. addLight(newLight: Light): void;
  32985. /**
  32986. * Sorts the list list based on light priorities
  32987. */
  32988. sortLightsByPriority(): void;
  32989. /**
  32990. * Adds the given camera to this scene
  32991. * @param newCamera The camera to add
  32992. */
  32993. addCamera(newCamera: Camera): void;
  32994. /**
  32995. * Adds the given skeleton to this scene
  32996. * @param newSkeleton The skeleton to add
  32997. */
  32998. addSkeleton(newSkeleton: Skeleton): void;
  32999. /**
  33000. * Adds the given particle system to this scene
  33001. * @param newParticleSystem The particle system to add
  33002. */
  33003. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33004. /**
  33005. * Adds the given animation to this scene
  33006. * @param newAnimation The animation to add
  33007. */
  33008. addAnimation(newAnimation: Animation): void;
  33009. /**
  33010. * Adds the given animation group to this scene.
  33011. * @param newAnimationGroup The animation group to add
  33012. */
  33013. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33014. /**
  33015. * Adds the given multi-material to this scene
  33016. * @param newMultiMaterial The multi-material to add
  33017. */
  33018. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33019. /**
  33020. * Adds the given material to this scene
  33021. * @param newMaterial The material to add
  33022. */
  33023. addMaterial(newMaterial: Material): void;
  33024. /**
  33025. * Adds the given morph target to this scene
  33026. * @param newMorphTargetManager The morph target to add
  33027. */
  33028. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33029. /**
  33030. * Adds the given geometry to this scene
  33031. * @param newGeometry The geometry to add
  33032. */
  33033. addGeometry(newGeometry: Geometry): void;
  33034. /**
  33035. * Adds the given action manager to this scene
  33036. * @param newActionManager The action manager to add
  33037. */
  33038. addActionManager(newActionManager: AbstractActionManager): void;
  33039. /**
  33040. * Adds the given texture to this scene.
  33041. * @param newTexture The texture to add
  33042. */
  33043. addTexture(newTexture: BaseTexture): void;
  33044. /**
  33045. * Switch active camera
  33046. * @param newCamera defines the new active camera
  33047. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33048. */
  33049. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33050. /**
  33051. * sets the active camera of the scene using its ID
  33052. * @param id defines the camera's ID
  33053. * @return the new active camera or null if none found.
  33054. */
  33055. setActiveCameraByID(id: string): Nullable<Camera>;
  33056. /**
  33057. * sets the active camera of the scene using its name
  33058. * @param name defines the camera's name
  33059. * @returns the new active camera or null if none found.
  33060. */
  33061. setActiveCameraByName(name: string): Nullable<Camera>;
  33062. /**
  33063. * get an animation group using its name
  33064. * @param name defines the material's name
  33065. * @return the animation group or null if none found.
  33066. */
  33067. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33068. /**
  33069. * get a material using its id
  33070. * @param id defines the material's ID
  33071. * @return the material or null if none found.
  33072. */
  33073. getMaterialByID(id: string): Nullable<Material>;
  33074. /**
  33075. * Gets a material using its name
  33076. * @param name defines the material's name
  33077. * @return the material or null if none found.
  33078. */
  33079. getMaterialByName(name: string): Nullable<Material>;
  33080. /**
  33081. * Gets a camera using its id
  33082. * @param id defines the id to look for
  33083. * @returns the camera or null if not found
  33084. */
  33085. getCameraByID(id: string): Nullable<Camera>;
  33086. /**
  33087. * Gets a camera using its unique id
  33088. * @param uniqueId defines the unique id to look for
  33089. * @returns the camera or null if not found
  33090. */
  33091. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33092. /**
  33093. * Gets a camera using its name
  33094. * @param name defines the camera's name
  33095. * @return the camera or null if none found.
  33096. */
  33097. getCameraByName(name: string): Nullable<Camera>;
  33098. /**
  33099. * Gets a bone using its id
  33100. * @param id defines the bone's id
  33101. * @return the bone or null if not found
  33102. */
  33103. getBoneByID(id: string): Nullable<Bone>;
  33104. /**
  33105. * Gets a bone using its id
  33106. * @param name defines the bone's name
  33107. * @return the bone or null if not found
  33108. */
  33109. getBoneByName(name: string): Nullable<Bone>;
  33110. /**
  33111. * Gets a light node using its name
  33112. * @param name defines the the light's name
  33113. * @return the light or null if none found.
  33114. */
  33115. getLightByName(name: string): Nullable<Light>;
  33116. /**
  33117. * Gets a light node using its id
  33118. * @param id defines the light's id
  33119. * @return the light or null if none found.
  33120. */
  33121. getLightByID(id: string): Nullable<Light>;
  33122. /**
  33123. * Gets a light node using its scene-generated unique ID
  33124. * @param uniqueId defines the light's unique id
  33125. * @return the light or null if none found.
  33126. */
  33127. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33128. /**
  33129. * Gets a particle system by id
  33130. * @param id defines the particle system id
  33131. * @return the corresponding system or null if none found
  33132. */
  33133. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33134. /**
  33135. * Gets a geometry using its ID
  33136. * @param id defines the geometry's id
  33137. * @return the geometry or null if none found.
  33138. */
  33139. getGeometryByID(id: string): Nullable<Geometry>;
  33140. private _getGeometryByUniqueID;
  33141. /**
  33142. * Add a new geometry to this scene
  33143. * @param geometry defines the geometry to be added to the scene.
  33144. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33145. * @return a boolean defining if the geometry was added or not
  33146. */
  33147. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33148. /**
  33149. * Removes an existing geometry
  33150. * @param geometry defines the geometry to be removed from the scene
  33151. * @return a boolean defining if the geometry was removed or not
  33152. */
  33153. removeGeometry(geometry: Geometry): boolean;
  33154. /**
  33155. * Gets the list of geometries attached to the scene
  33156. * @returns an array of Geometry
  33157. */
  33158. getGeometries(): Geometry[];
  33159. /**
  33160. * Gets the first added mesh found of a given ID
  33161. * @param id defines the id to search for
  33162. * @return the mesh found or null if not found at all
  33163. */
  33164. getMeshByID(id: string): Nullable<AbstractMesh>;
  33165. /**
  33166. * Gets a list of meshes using their id
  33167. * @param id defines the id to search for
  33168. * @returns a list of meshes
  33169. */
  33170. getMeshesByID(id: string): Array<AbstractMesh>;
  33171. /**
  33172. * Gets the first added transform node found of a given ID
  33173. * @param id defines the id to search for
  33174. * @return the found transform node or null if not found at all.
  33175. */
  33176. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33177. /**
  33178. * Gets a list of transform nodes using their id
  33179. * @param id defines the id to search for
  33180. * @returns a list of transform nodes
  33181. */
  33182. getTransformNodesByID(id: string): Array<TransformNode>;
  33183. /**
  33184. * Gets a mesh with its auto-generated unique id
  33185. * @param uniqueId defines the unique id to search for
  33186. * @return the found mesh or null if not found at all.
  33187. */
  33188. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33189. /**
  33190. * Gets a the last added mesh using a given id
  33191. * @param id defines the id to search for
  33192. * @return the found mesh or null if not found at all.
  33193. */
  33194. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33195. /**
  33196. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33197. * @param id defines the id to search for
  33198. * @return the found node or null if not found at all
  33199. */
  33200. getLastEntryByID(id: string): Nullable<Node>;
  33201. /**
  33202. * Gets a node (Mesh, Camera, Light) using a given id
  33203. * @param id defines the id to search for
  33204. * @return the found node or null if not found at all
  33205. */
  33206. getNodeByID(id: string): Nullable<Node>;
  33207. /**
  33208. * Gets a node (Mesh, Camera, Light) using a given name
  33209. * @param name defines the name to search for
  33210. * @return the found node or null if not found at all.
  33211. */
  33212. getNodeByName(name: string): Nullable<Node>;
  33213. /**
  33214. * Gets a mesh using a given name
  33215. * @param name defines the name to search for
  33216. * @return the found mesh or null if not found at all.
  33217. */
  33218. getMeshByName(name: string): Nullable<AbstractMesh>;
  33219. /**
  33220. * Gets a transform node using a given name
  33221. * @param name defines the name to search for
  33222. * @return the found transform node or null if not found at all.
  33223. */
  33224. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33225. /**
  33226. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33227. * @param id defines the id to search for
  33228. * @return the found skeleton or null if not found at all.
  33229. */
  33230. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33231. /**
  33232. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33233. * @param id defines the id to search for
  33234. * @return the found skeleton or null if not found at all.
  33235. */
  33236. getSkeletonById(id: string): Nullable<Skeleton>;
  33237. /**
  33238. * Gets a skeleton using a given name
  33239. * @param name defines the name to search for
  33240. * @return the found skeleton or null if not found at all.
  33241. */
  33242. getSkeletonByName(name: string): Nullable<Skeleton>;
  33243. /**
  33244. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33245. * @param id defines the id to search for
  33246. * @return the found morph target manager or null if not found at all.
  33247. */
  33248. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33249. /**
  33250. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33251. * @param id defines the id to search for
  33252. * @return the found morph target or null if not found at all.
  33253. */
  33254. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33255. /**
  33256. * Gets a boolean indicating if the given mesh is active
  33257. * @param mesh defines the mesh to look for
  33258. * @returns true if the mesh is in the active list
  33259. */
  33260. isActiveMesh(mesh: AbstractMesh): boolean;
  33261. /**
  33262. * Return a unique id as a string which can serve as an identifier for the scene
  33263. */
  33264. readonly uid: string;
  33265. /**
  33266. * Add an externaly attached data from its key.
  33267. * This method call will fail and return false, if such key already exists.
  33268. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33269. * @param key the unique key that identifies the data
  33270. * @param data the data object to associate to the key for this Engine instance
  33271. * @return true if no such key were already present and the data was added successfully, false otherwise
  33272. */
  33273. addExternalData<T>(key: string, data: T): boolean;
  33274. /**
  33275. * Get an externaly attached data from its key
  33276. * @param key the unique key that identifies the data
  33277. * @return the associated data, if present (can be null), or undefined if not present
  33278. */
  33279. getExternalData<T>(key: string): Nullable<T>;
  33280. /**
  33281. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33282. * @param key the unique key that identifies the data
  33283. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33284. * @return the associated data, can be null if the factory returned null.
  33285. */
  33286. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33287. /**
  33288. * Remove an externaly attached data from the Engine instance
  33289. * @param key the unique key that identifies the data
  33290. * @return true if the data was successfully removed, false if it doesn't exist
  33291. */
  33292. removeExternalData(key: string): boolean;
  33293. private _evaluateSubMesh;
  33294. /**
  33295. * Clear the processed materials smart array preventing retention point in material dispose.
  33296. */
  33297. freeProcessedMaterials(): void;
  33298. private _preventFreeActiveMeshesAndRenderingGroups;
  33299. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33300. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33301. * when disposing several meshes in a row or a hierarchy of meshes.
  33302. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33303. */
  33304. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33305. /**
  33306. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33307. */
  33308. freeActiveMeshes(): void;
  33309. /**
  33310. * Clear the info related to rendering groups preventing retention points during dispose.
  33311. */
  33312. freeRenderingGroups(): void;
  33313. /** @hidden */
  33314. _isInIntermediateRendering(): boolean;
  33315. /**
  33316. * Lambda returning the list of potentially active meshes.
  33317. */
  33318. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33319. /**
  33320. * Lambda returning the list of potentially active sub meshes.
  33321. */
  33322. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33323. /**
  33324. * Lambda returning the list of potentially intersecting sub meshes.
  33325. */
  33326. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33327. /**
  33328. * Lambda returning the list of potentially colliding sub meshes.
  33329. */
  33330. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33331. private _activeMeshesFrozen;
  33332. /**
  33333. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33334. * @returns the current scene
  33335. */
  33336. freezeActiveMeshes(): Scene;
  33337. /**
  33338. * Use this function to restart evaluating active meshes on every frame
  33339. * @returns the current scene
  33340. */
  33341. unfreezeActiveMeshes(): Scene;
  33342. private _evaluateActiveMeshes;
  33343. private _activeMesh;
  33344. /**
  33345. * Update the transform matrix to update from the current active camera
  33346. * @param force defines a boolean used to force the update even if cache is up to date
  33347. */
  33348. updateTransformMatrix(force?: boolean): void;
  33349. /**
  33350. * 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)
  33351. * @param alternateCamera defines the camera to use
  33352. */
  33353. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33354. /** @hidden */
  33355. _allowPostProcessClearColor: boolean;
  33356. private _renderForCamera;
  33357. private _processSubCameras;
  33358. private _checkIntersections;
  33359. /** @hidden */
  33360. _advancePhysicsEngineStep(step: number): void;
  33361. /**
  33362. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33363. */
  33364. getDeterministicFrameTime: () => number;
  33365. /** @hidden */
  33366. _animate(): void;
  33367. /**
  33368. * Render the scene
  33369. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33370. */
  33371. render(updateCameras?: boolean): void;
  33372. /**
  33373. * Freeze all materials
  33374. * A frozen material will not be updatable but should be faster to render
  33375. */
  33376. freezeMaterials(): void;
  33377. /**
  33378. * Unfreeze all materials
  33379. * A frozen material will not be updatable but should be faster to render
  33380. */
  33381. unfreezeMaterials(): void;
  33382. /**
  33383. * Releases all held ressources
  33384. */
  33385. dispose(): void;
  33386. /**
  33387. * Gets if the scene is already disposed
  33388. */
  33389. readonly isDisposed: boolean;
  33390. /**
  33391. * Call this function to reduce memory footprint of the scene.
  33392. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33393. */
  33394. clearCachedVertexData(): void;
  33395. /**
  33396. * This function will remove the local cached buffer data from texture.
  33397. * It will save memory but will prevent the texture from being rebuilt
  33398. */
  33399. cleanCachedTextureBuffer(): void;
  33400. /**
  33401. * Get the world extend vectors with an optional filter
  33402. *
  33403. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33404. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33405. */
  33406. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33407. min: Vector3;
  33408. max: Vector3;
  33409. };
  33410. /**
  33411. * Creates a ray that can be used to pick in the scene
  33412. * @param x defines the x coordinate of the origin (on-screen)
  33413. * @param y defines the y coordinate of the origin (on-screen)
  33414. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33415. * @param camera defines the camera to use for the picking
  33416. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33417. * @returns a Ray
  33418. */
  33419. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33420. /**
  33421. * Creates a ray that can be used to pick in the scene
  33422. * @param x defines the x coordinate of the origin (on-screen)
  33423. * @param y defines the y coordinate of the origin (on-screen)
  33424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33425. * @param result defines the ray where to store the picking ray
  33426. * @param camera defines the camera to use for the picking
  33427. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33428. * @returns the current scene
  33429. */
  33430. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33431. /**
  33432. * Creates a ray that can be used to pick in the scene
  33433. * @param x defines the x coordinate of the origin (on-screen)
  33434. * @param y defines the y coordinate of the origin (on-screen)
  33435. * @param camera defines the camera to use for the picking
  33436. * @returns a Ray
  33437. */
  33438. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33439. /**
  33440. * Creates a ray that can be used to pick in the scene
  33441. * @param x defines the x coordinate of the origin (on-screen)
  33442. * @param y defines the y coordinate of the origin (on-screen)
  33443. * @param result defines the ray where to store the picking ray
  33444. * @param camera defines the camera to use for the picking
  33445. * @returns the current scene
  33446. */
  33447. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33448. /** Launch a ray to try to pick a mesh in the scene
  33449. * @param x position on screen
  33450. * @param y position on screen
  33451. * @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
  33452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33453. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33454. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33455. * @returns a PickingInfo
  33456. */
  33457. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33458. /** Use the given ray to pick a mesh in the scene
  33459. * @param ray The ray to use to pick meshes
  33460. * @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
  33461. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33462. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33463. * @returns a PickingInfo
  33464. */
  33465. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33466. /**
  33467. * Launch a ray to try to pick a mesh in the scene
  33468. * @param x X position on screen
  33469. * @param y Y position on screen
  33470. * @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
  33471. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33472. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33473. * @returns an array of PickingInfo
  33474. */
  33475. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33476. /**
  33477. * Launch a ray to try to pick a mesh in the scene
  33478. * @param ray Ray to use
  33479. * @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
  33480. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33481. * @returns an array of PickingInfo
  33482. */
  33483. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33484. /**
  33485. * Force the value of meshUnderPointer
  33486. * @param mesh defines the mesh to use
  33487. */
  33488. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33489. /**
  33490. * Gets the mesh under the pointer
  33491. * @returns a Mesh or null if no mesh is under the pointer
  33492. */
  33493. getPointerOverMesh(): Nullable<AbstractMesh>;
  33494. /** @hidden */
  33495. _rebuildGeometries(): void;
  33496. /** @hidden */
  33497. _rebuildTextures(): void;
  33498. private _getByTags;
  33499. /**
  33500. * Get a list of meshes by tags
  33501. * @param tagsQuery defines the tags query to use
  33502. * @param forEach defines a predicate used to filter results
  33503. * @returns an array of Mesh
  33504. */
  33505. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33506. /**
  33507. * Get a list of cameras by tags
  33508. * @param tagsQuery defines the tags query to use
  33509. * @param forEach defines a predicate used to filter results
  33510. * @returns an array of Camera
  33511. */
  33512. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33513. /**
  33514. * Get a list of lights by tags
  33515. * @param tagsQuery defines the tags query to use
  33516. * @param forEach defines a predicate used to filter results
  33517. * @returns an array of Light
  33518. */
  33519. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33520. /**
  33521. * Get a list of materials by tags
  33522. * @param tagsQuery defines the tags query to use
  33523. * @param forEach defines a predicate used to filter results
  33524. * @returns an array of Material
  33525. */
  33526. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33527. /**
  33528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33529. * This allowed control for front to back rendering or reversly depending of the special needs.
  33530. *
  33531. * @param renderingGroupId The rendering group id corresponding to its index
  33532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33535. */
  33536. 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;
  33537. /**
  33538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33539. *
  33540. * @param renderingGroupId The rendering group id corresponding to its index
  33541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33542. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33543. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33544. */
  33545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33546. /**
  33547. * Gets the current auto clear configuration for one rendering group of the rendering
  33548. * manager.
  33549. * @param index the rendering group index to get the information for
  33550. * @returns The auto clear setup for the requested rendering group
  33551. */
  33552. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33553. private _blockMaterialDirtyMechanism;
  33554. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33555. blockMaterialDirtyMechanism: boolean;
  33556. /**
  33557. * Will flag all materials as dirty to trigger new shader compilation
  33558. * @param flag defines the flag used to specify which material part must be marked as dirty
  33559. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33560. */
  33561. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33562. /** @hidden */
  33563. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33564. /** @hidden */
  33565. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33566. }
  33567. }
  33568. declare module "babylonjs/assetContainer" {
  33569. import { AbstractScene } from "babylonjs/abstractScene";
  33570. import { Scene } from "babylonjs/scene";
  33571. import { Mesh } from "babylonjs/Meshes/mesh";
  33572. /**
  33573. * Set of assets to keep when moving a scene into an asset container.
  33574. */
  33575. export class KeepAssets extends AbstractScene {
  33576. }
  33577. /**
  33578. * Container with a set of assets that can be added or removed from a scene.
  33579. */
  33580. export class AssetContainer extends AbstractScene {
  33581. /**
  33582. * The scene the AssetContainer belongs to.
  33583. */
  33584. scene: Scene;
  33585. /**
  33586. * Instantiates an AssetContainer.
  33587. * @param scene The scene the AssetContainer belongs to.
  33588. */
  33589. constructor(scene: Scene);
  33590. /**
  33591. * Adds all the assets from the container to the scene.
  33592. */
  33593. addAllToScene(): void;
  33594. /**
  33595. * Removes all the assets in the container from the scene
  33596. */
  33597. removeAllFromScene(): void;
  33598. /**
  33599. * Disposes all the assets in the container
  33600. */
  33601. dispose(): void;
  33602. private _moveAssets;
  33603. /**
  33604. * Removes all the assets contained in the scene and adds them to the container.
  33605. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33606. */
  33607. moveAllFromScene(keepAssets?: KeepAssets): void;
  33608. /**
  33609. * 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.
  33610. * @returns the root mesh
  33611. */
  33612. createRootMesh(): Mesh;
  33613. }
  33614. }
  33615. declare module "babylonjs/abstractScene" {
  33616. import { Scene } from "babylonjs/scene";
  33617. import { Nullable } from "babylonjs/types";
  33618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33619. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33620. import { Geometry } from "babylonjs/Meshes/geometry";
  33621. import { Skeleton } from "babylonjs/Bones/skeleton";
  33622. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33623. import { AssetContainer } from "babylonjs/assetContainer";
  33624. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33625. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33627. import { Material } from "babylonjs/Materials/material";
  33628. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33629. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33630. import { Camera } from "babylonjs/Cameras/camera";
  33631. import { Light } from "babylonjs/Lights/light";
  33632. import { Node } from "babylonjs/node";
  33633. import { Animation } from "babylonjs/Animations/animation";
  33634. /**
  33635. * Defines how the parser contract is defined.
  33636. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33637. */
  33638. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33639. /**
  33640. * Defines how the individual parser contract is defined.
  33641. * These parser can parse an individual asset
  33642. */
  33643. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33644. /**
  33645. * Base class of the scene acting as a container for the different elements composing a scene.
  33646. * This class is dynamically extended by the different components of the scene increasing
  33647. * flexibility and reducing coupling
  33648. */
  33649. export abstract class AbstractScene {
  33650. /**
  33651. * Stores the list of available parsers in the application.
  33652. */
  33653. private static _BabylonFileParsers;
  33654. /**
  33655. * Stores the list of available individual parsers in the application.
  33656. */
  33657. private static _IndividualBabylonFileParsers;
  33658. /**
  33659. * Adds a parser in the list of available ones
  33660. * @param name Defines the name of the parser
  33661. * @param parser Defines the parser to add
  33662. */
  33663. static AddParser(name: string, parser: BabylonFileParser): void;
  33664. /**
  33665. * Gets a general parser from the list of avaialble ones
  33666. * @param name Defines the name of the parser
  33667. * @returns the requested parser or null
  33668. */
  33669. static GetParser(name: string): Nullable<BabylonFileParser>;
  33670. /**
  33671. * Adds n individual parser in the list of available ones
  33672. * @param name Defines the name of the parser
  33673. * @param parser Defines the parser to add
  33674. */
  33675. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33676. /**
  33677. * Gets an individual parser from the list of avaialble ones
  33678. * @param name Defines the name of the parser
  33679. * @returns the requested parser or null
  33680. */
  33681. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33682. /**
  33683. * Parser json data and populate both a scene and its associated container object
  33684. * @param jsonData Defines the data to parse
  33685. * @param scene Defines the scene to parse the data for
  33686. * @param container Defines the container attached to the parsing sequence
  33687. * @param rootUrl Defines the root url of the data
  33688. */
  33689. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33690. /**
  33691. * Gets the list of root nodes (ie. nodes with no parent)
  33692. */
  33693. rootNodes: Node[];
  33694. /** All of the cameras added to this scene
  33695. * @see http://doc.babylonjs.com/babylon101/cameras
  33696. */
  33697. cameras: Camera[];
  33698. /**
  33699. * All of the lights added to this scene
  33700. * @see http://doc.babylonjs.com/babylon101/lights
  33701. */
  33702. lights: Light[];
  33703. /**
  33704. * All of the (abstract) meshes added to this scene
  33705. */
  33706. meshes: AbstractMesh[];
  33707. /**
  33708. * The list of skeletons added to the scene
  33709. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33710. */
  33711. skeletons: Skeleton[];
  33712. /**
  33713. * All of the particle systems added to this scene
  33714. * @see http://doc.babylonjs.com/babylon101/particles
  33715. */
  33716. particleSystems: IParticleSystem[];
  33717. /**
  33718. * Gets a list of Animations associated with the scene
  33719. */
  33720. animations: Animation[];
  33721. /**
  33722. * All of the animation groups added to this scene
  33723. * @see http://doc.babylonjs.com/how_to/group
  33724. */
  33725. animationGroups: AnimationGroup[];
  33726. /**
  33727. * All of the multi-materials added to this scene
  33728. * @see http://doc.babylonjs.com/how_to/multi_materials
  33729. */
  33730. multiMaterials: MultiMaterial[];
  33731. /**
  33732. * All of the materials added to this scene
  33733. * In the context of a Scene, it is not supposed to be modified manually.
  33734. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33735. * Note also that the order of the Material wihin the array is not significant and might change.
  33736. * @see http://doc.babylonjs.com/babylon101/materials
  33737. */
  33738. materials: Material[];
  33739. /**
  33740. * The list of morph target managers added to the scene
  33741. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33742. */
  33743. morphTargetManagers: MorphTargetManager[];
  33744. /**
  33745. * The list of geometries used in the scene.
  33746. */
  33747. geometries: Geometry[];
  33748. /**
  33749. * All of the tranform nodes added to this scene
  33750. * In the context of a Scene, it is not supposed to be modified manually.
  33751. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33752. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33753. * @see http://doc.babylonjs.com/how_to/transformnode
  33754. */
  33755. transformNodes: TransformNode[];
  33756. /**
  33757. * ActionManagers available on the scene.
  33758. */
  33759. actionManagers: AbstractActionManager[];
  33760. /**
  33761. * Textures to keep.
  33762. */
  33763. textures: BaseTexture[];
  33764. }
  33765. }
  33766. declare module "babylonjs/Audio/sound" {
  33767. import { Observable } from "babylonjs/Misc/observable";
  33768. import { Vector3 } from "babylonjs/Maths/math";
  33769. import { Nullable } from "babylonjs/types";
  33770. import { Scene } from "babylonjs/scene";
  33771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33772. /**
  33773. * Defines a sound that can be played in the application.
  33774. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33776. */
  33777. export class Sound {
  33778. /**
  33779. * The name of the sound in the scene.
  33780. */
  33781. name: string;
  33782. /**
  33783. * Does the sound autoplay once loaded.
  33784. */
  33785. autoplay: boolean;
  33786. /**
  33787. * Does the sound loop after it finishes playing once.
  33788. */
  33789. loop: boolean;
  33790. /**
  33791. * Does the sound use a custom attenuation curve to simulate the falloff
  33792. * happening when the source gets further away from the camera.
  33793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33794. */
  33795. useCustomAttenuation: boolean;
  33796. /**
  33797. * The sound track id this sound belongs to.
  33798. */
  33799. soundTrackId: number;
  33800. /**
  33801. * Is this sound currently played.
  33802. */
  33803. isPlaying: boolean;
  33804. /**
  33805. * Is this sound currently paused.
  33806. */
  33807. isPaused: boolean;
  33808. /**
  33809. * Does this sound enables spatial sound.
  33810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33811. */
  33812. spatialSound: boolean;
  33813. /**
  33814. * Define the reference distance the sound should be heard perfectly.
  33815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33816. */
  33817. refDistance: number;
  33818. /**
  33819. * Define the roll off factor of spatial sounds.
  33820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33821. */
  33822. rolloffFactor: number;
  33823. /**
  33824. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33826. */
  33827. maxDistance: number;
  33828. /**
  33829. * Define the distance attenuation model the sound will follow.
  33830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33831. */
  33832. distanceModel: string;
  33833. /**
  33834. * @hidden
  33835. * Back Compat
  33836. **/
  33837. onended: () => any;
  33838. /**
  33839. * Observable event when the current playing sound finishes.
  33840. */
  33841. onEndedObservable: Observable<Sound>;
  33842. private _panningModel;
  33843. private _playbackRate;
  33844. private _streaming;
  33845. private _startTime;
  33846. private _startOffset;
  33847. private _position;
  33848. /** @hidden */
  33849. _positionInEmitterSpace: boolean;
  33850. private _localDirection;
  33851. private _volume;
  33852. private _isReadyToPlay;
  33853. private _isDirectional;
  33854. private _readyToPlayCallback;
  33855. private _audioBuffer;
  33856. private _soundSource;
  33857. private _streamingSource;
  33858. private _soundPanner;
  33859. private _soundGain;
  33860. private _inputAudioNode;
  33861. private _outputAudioNode;
  33862. private _coneInnerAngle;
  33863. private _coneOuterAngle;
  33864. private _coneOuterGain;
  33865. private _scene;
  33866. private _connectedTransformNode;
  33867. private _customAttenuationFunction;
  33868. private _registerFunc;
  33869. private _isOutputConnected;
  33870. private _htmlAudioElement;
  33871. private _urlType;
  33872. /** @hidden */
  33873. static _SceneComponentInitialization: (scene: Scene) => void;
  33874. /**
  33875. * Create a sound and attach it to a scene
  33876. * @param name Name of your sound
  33877. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33878. * @param scene defines the scene the sound belongs to
  33879. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33880. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33881. */
  33882. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33883. /**
  33884. * Release the sound and its associated resources
  33885. */
  33886. dispose(): void;
  33887. /**
  33888. * Gets if the sounds is ready to be played or not.
  33889. * @returns true if ready, otherwise false
  33890. */
  33891. isReady(): boolean;
  33892. private _soundLoaded;
  33893. /**
  33894. * Sets the data of the sound from an audiobuffer
  33895. * @param audioBuffer The audioBuffer containing the data
  33896. */
  33897. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33898. /**
  33899. * Updates the current sounds options such as maxdistance, loop...
  33900. * @param options A JSON object containing values named as the object properties
  33901. */
  33902. updateOptions(options: any): void;
  33903. private _createSpatialParameters;
  33904. private _updateSpatialParameters;
  33905. /**
  33906. * Switch the panning model to HRTF:
  33907. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33909. */
  33910. switchPanningModelToHRTF(): void;
  33911. /**
  33912. * Switch the panning model to Equal Power:
  33913. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33915. */
  33916. switchPanningModelToEqualPower(): void;
  33917. private _switchPanningModel;
  33918. /**
  33919. * Connect this sound to a sound track audio node like gain...
  33920. * @param soundTrackAudioNode the sound track audio node to connect to
  33921. */
  33922. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33923. /**
  33924. * Transform this sound into a directional source
  33925. * @param coneInnerAngle Size of the inner cone in degree
  33926. * @param coneOuterAngle Size of the outer cone in degree
  33927. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33928. */
  33929. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33930. /**
  33931. * Gets or sets the inner angle for the directional cone.
  33932. */
  33933. /**
  33934. * Gets or sets the inner angle for the directional cone.
  33935. */
  33936. directionalConeInnerAngle: number;
  33937. /**
  33938. * Gets or sets the outer angle for the directional cone.
  33939. */
  33940. /**
  33941. * Gets or sets the outer angle for the directional cone.
  33942. */
  33943. directionalConeOuterAngle: number;
  33944. /**
  33945. * Sets the position of the emitter if spatial sound is enabled
  33946. * @param newPosition Defines the new posisiton
  33947. */
  33948. setPosition(newPosition: Vector3): void;
  33949. /**
  33950. * Sets the local direction of the emitter if spatial sound is enabled
  33951. * @param newLocalDirection Defines the new local direction
  33952. */
  33953. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33954. private _updateDirection;
  33955. /** @hidden */
  33956. updateDistanceFromListener(): void;
  33957. /**
  33958. * Sets a new custom attenuation function for the sound.
  33959. * @param callback Defines the function used for the attenuation
  33960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33961. */
  33962. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33963. /**
  33964. * Play the sound
  33965. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33966. * @param offset (optional) Start the sound setting it at a specific time
  33967. */
  33968. play(time?: number, offset?: number): void;
  33969. private _onended;
  33970. /**
  33971. * Stop the sound
  33972. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33973. */
  33974. stop(time?: number): void;
  33975. /**
  33976. * Put the sound in pause
  33977. */
  33978. pause(): void;
  33979. /**
  33980. * Sets a dedicated volume for this sounds
  33981. * @param newVolume Define the new volume of the sound
  33982. * @param time Define in how long the sound should be at this value
  33983. */
  33984. setVolume(newVolume: number, time?: number): void;
  33985. /**
  33986. * Set the sound play back rate
  33987. * @param newPlaybackRate Define the playback rate the sound should be played at
  33988. */
  33989. setPlaybackRate(newPlaybackRate: number): void;
  33990. /**
  33991. * Gets the volume of the sound.
  33992. * @returns the volume of the sound
  33993. */
  33994. getVolume(): number;
  33995. /**
  33996. * Attach the sound to a dedicated mesh
  33997. * @param transformNode The transform node to connect the sound with
  33998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33999. */
  34000. attachToMesh(transformNode: TransformNode): void;
  34001. /**
  34002. * Detach the sound from the previously attached mesh
  34003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34004. */
  34005. detachFromMesh(): void;
  34006. private _onRegisterAfterWorldMatrixUpdate;
  34007. /**
  34008. * Clone the current sound in the scene.
  34009. * @returns the new sound clone
  34010. */
  34011. clone(): Nullable<Sound>;
  34012. /**
  34013. * Gets the current underlying audio buffer containing the data
  34014. * @returns the audio buffer
  34015. */
  34016. getAudioBuffer(): Nullable<AudioBuffer>;
  34017. /**
  34018. * Serializes the Sound in a JSON representation
  34019. * @returns the JSON representation of the sound
  34020. */
  34021. serialize(): any;
  34022. /**
  34023. * Parse a JSON representation of a sound to innstantiate in a given scene
  34024. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34025. * @param scene Define the scene the new parsed sound should be created in
  34026. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34027. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34028. * @returns the newly parsed sound
  34029. */
  34030. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34031. }
  34032. }
  34033. declare module "babylonjs/Actions/directAudioActions" {
  34034. import { Action } from "babylonjs/Actions/action";
  34035. import { Condition } from "babylonjs/Actions/condition";
  34036. import { Sound } from "babylonjs/Audio/sound";
  34037. /**
  34038. * This defines an action helpful to play a defined sound on a triggered action.
  34039. */
  34040. export class PlaySoundAction extends Action {
  34041. private _sound;
  34042. /**
  34043. * Instantiate the action
  34044. * @param triggerOptions defines the trigger options
  34045. * @param sound defines the sound to play
  34046. * @param condition defines the trigger related conditions
  34047. */
  34048. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34049. /** @hidden */
  34050. _prepare(): void;
  34051. /**
  34052. * Execute the action and play the sound.
  34053. */
  34054. execute(): void;
  34055. /**
  34056. * Serializes the actions and its related information.
  34057. * @param parent defines the object to serialize in
  34058. * @returns the serialized object
  34059. */
  34060. serialize(parent: any): any;
  34061. }
  34062. /**
  34063. * This defines an action helpful to stop a defined sound on a triggered action.
  34064. */
  34065. export class StopSoundAction extends Action {
  34066. private _sound;
  34067. /**
  34068. * Instantiate the action
  34069. * @param triggerOptions defines the trigger options
  34070. * @param sound defines the sound to stop
  34071. * @param condition defines the trigger related conditions
  34072. */
  34073. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34074. /** @hidden */
  34075. _prepare(): void;
  34076. /**
  34077. * Execute the action and stop the sound.
  34078. */
  34079. execute(): void;
  34080. /**
  34081. * Serializes the actions and its related information.
  34082. * @param parent defines the object to serialize in
  34083. * @returns the serialized object
  34084. */
  34085. serialize(parent: any): any;
  34086. }
  34087. }
  34088. declare module "babylonjs/Actions/interpolateValueAction" {
  34089. import { Action } from "babylonjs/Actions/action";
  34090. import { Condition } from "babylonjs/Actions/condition";
  34091. import { Observable } from "babylonjs/Misc/observable";
  34092. /**
  34093. * This defines an action responsible to change the value of a property
  34094. * by interpolating between its current value and the newly set one once triggered.
  34095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34096. */
  34097. export class InterpolateValueAction extends Action {
  34098. /**
  34099. * Defines the path of the property where the value should be interpolated
  34100. */
  34101. propertyPath: string;
  34102. /**
  34103. * Defines the target value at the end of the interpolation.
  34104. */
  34105. value: any;
  34106. /**
  34107. * Defines the time it will take for the property to interpolate to the value.
  34108. */
  34109. duration: number;
  34110. /**
  34111. * Defines if the other scene animations should be stopped when the action has been triggered
  34112. */
  34113. stopOtherAnimations?: boolean;
  34114. /**
  34115. * Defines a callback raised once the interpolation animation has been done.
  34116. */
  34117. onInterpolationDone?: () => void;
  34118. /**
  34119. * Observable triggered once the interpolation animation has been done.
  34120. */
  34121. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34122. private _target;
  34123. private _effectiveTarget;
  34124. private _property;
  34125. /**
  34126. * Instantiate the action
  34127. * @param triggerOptions defines the trigger options
  34128. * @param target defines the object containing the value to interpolate
  34129. * @param propertyPath defines the path to the property in the target object
  34130. * @param value defines the target value at the end of the interpolation
  34131. * @param duration deines the time it will take for the property to interpolate to the value.
  34132. * @param condition defines the trigger related conditions
  34133. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34134. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34135. */
  34136. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34137. /** @hidden */
  34138. _prepare(): void;
  34139. /**
  34140. * Execute the action starts the value interpolation.
  34141. */
  34142. execute(): void;
  34143. /**
  34144. * Serializes the actions and its related information.
  34145. * @param parent defines the object to serialize in
  34146. * @returns the serialized object
  34147. */
  34148. serialize(parent: any): any;
  34149. }
  34150. }
  34151. declare module "babylonjs/Actions/index" {
  34152. export * from "babylonjs/Actions/action";
  34153. export * from "babylonjs/Actions/actionEvent";
  34154. export * from "babylonjs/Actions/actionManager";
  34155. export * from "babylonjs/Actions/condition";
  34156. export * from "babylonjs/Actions/directActions";
  34157. export * from "babylonjs/Actions/directAudioActions";
  34158. export * from "babylonjs/Actions/interpolateValueAction";
  34159. }
  34160. declare module "babylonjs/Animations/index" {
  34161. export * from "babylonjs/Animations/animatable";
  34162. export * from "babylonjs/Animations/animation";
  34163. export * from "babylonjs/Animations/animationGroup";
  34164. export * from "babylonjs/Animations/animationPropertiesOverride";
  34165. export * from "babylonjs/Animations/easing";
  34166. export * from "babylonjs/Animations/runtimeAnimation";
  34167. export * from "babylonjs/Animations/animationEvent";
  34168. export * from "babylonjs/Animations/animationGroup";
  34169. export * from "babylonjs/Animations/animationKey";
  34170. export * from "babylonjs/Animations/animationRange";
  34171. }
  34172. declare module "babylonjs/Audio/soundTrack" {
  34173. import { Sound } from "babylonjs/Audio/sound";
  34174. import { Analyser } from "babylonjs/Audio/analyser";
  34175. import { Scene } from "babylonjs/scene";
  34176. /**
  34177. * Options allowed during the creation of a sound track.
  34178. */
  34179. export interface ISoundTrackOptions {
  34180. /**
  34181. * The volume the sound track should take during creation
  34182. */
  34183. volume?: number;
  34184. /**
  34185. * Define if the sound track is the main sound track of the scene
  34186. */
  34187. mainTrack?: boolean;
  34188. }
  34189. /**
  34190. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34191. * It will be also used in a future release to apply effects on a specific track.
  34192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34193. */
  34194. export class SoundTrack {
  34195. /**
  34196. * The unique identifier of the sound track in the scene.
  34197. */
  34198. id: number;
  34199. /**
  34200. * The list of sounds included in the sound track.
  34201. */
  34202. soundCollection: Array<Sound>;
  34203. private _outputAudioNode;
  34204. private _scene;
  34205. private _isMainTrack;
  34206. private _connectedAnalyser;
  34207. private _options;
  34208. private _isInitialized;
  34209. /**
  34210. * Creates a new sound track.
  34211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34212. * @param scene Define the scene the sound track belongs to
  34213. * @param options
  34214. */
  34215. constructor(scene: Scene, options?: ISoundTrackOptions);
  34216. private _initializeSoundTrackAudioGraph;
  34217. /**
  34218. * Release the sound track and its associated resources
  34219. */
  34220. dispose(): void;
  34221. /**
  34222. * Adds a sound to this sound track
  34223. * @param sound define the cound to add
  34224. * @ignoreNaming
  34225. */
  34226. AddSound(sound: Sound): void;
  34227. /**
  34228. * Removes a sound to this sound track
  34229. * @param sound define the cound to remove
  34230. * @ignoreNaming
  34231. */
  34232. RemoveSound(sound: Sound): void;
  34233. /**
  34234. * Set a global volume for the full sound track.
  34235. * @param newVolume Define the new volume of the sound track
  34236. */
  34237. setVolume(newVolume: number): void;
  34238. /**
  34239. * Switch the panning model to HRTF:
  34240. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34242. */
  34243. switchPanningModelToHRTF(): void;
  34244. /**
  34245. * Switch the panning model to Equal Power:
  34246. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34248. */
  34249. switchPanningModelToEqualPower(): void;
  34250. /**
  34251. * Connect the sound track to an audio analyser allowing some amazing
  34252. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34254. * @param analyser The analyser to connect to the engine
  34255. */
  34256. connectToAnalyser(analyser: Analyser): void;
  34257. }
  34258. }
  34259. declare module "babylonjs/Audio/audioSceneComponent" {
  34260. import { Sound } from "babylonjs/Audio/sound";
  34261. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34262. import { Nullable } from "babylonjs/types";
  34263. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34264. import { Scene } from "babylonjs/scene";
  34265. import { AbstractScene } from "babylonjs/abstractScene";
  34266. module "babylonjs/abstractScene" {
  34267. interface AbstractScene {
  34268. /**
  34269. * The list of sounds used in the scene.
  34270. */
  34271. sounds: Nullable<Array<Sound>>;
  34272. }
  34273. }
  34274. module "babylonjs/scene" {
  34275. interface Scene {
  34276. /**
  34277. * @hidden
  34278. * Backing field
  34279. */
  34280. _mainSoundTrack: SoundTrack;
  34281. /**
  34282. * The main sound track played by the scene.
  34283. * It cotains your primary collection of sounds.
  34284. */
  34285. mainSoundTrack: SoundTrack;
  34286. /**
  34287. * The list of sound tracks added to the scene
  34288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34289. */
  34290. soundTracks: Nullable<Array<SoundTrack>>;
  34291. /**
  34292. * Gets a sound using a given name
  34293. * @param name defines the name to search for
  34294. * @return the found sound or null if not found at all.
  34295. */
  34296. getSoundByName(name: string): Nullable<Sound>;
  34297. /**
  34298. * Gets or sets if audio support is enabled
  34299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34300. */
  34301. audioEnabled: boolean;
  34302. /**
  34303. * Gets or sets if audio will be output to headphones
  34304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34305. */
  34306. headphone: boolean;
  34307. }
  34308. }
  34309. /**
  34310. * Defines the sound scene component responsible to manage any sounds
  34311. * in a given scene.
  34312. */
  34313. export class AudioSceneComponent implements ISceneSerializableComponent {
  34314. /**
  34315. * The component name helpfull to identify the component in the list of scene components.
  34316. */
  34317. readonly name: string;
  34318. /**
  34319. * The scene the component belongs to.
  34320. */
  34321. scene: Scene;
  34322. private _audioEnabled;
  34323. /**
  34324. * Gets whether audio is enabled or not.
  34325. * Please use related enable/disable method to switch state.
  34326. */
  34327. readonly audioEnabled: boolean;
  34328. private _headphone;
  34329. /**
  34330. * Gets whether audio is outputing to headphone or not.
  34331. * Please use the according Switch methods to change output.
  34332. */
  34333. readonly headphone: boolean;
  34334. /**
  34335. * Creates a new instance of the component for the given scene
  34336. * @param scene Defines the scene to register the component in
  34337. */
  34338. constructor(scene: Scene);
  34339. /**
  34340. * Registers the component in a given scene
  34341. */
  34342. register(): void;
  34343. /**
  34344. * Rebuilds the elements related to this component in case of
  34345. * context lost for instance.
  34346. */
  34347. rebuild(): void;
  34348. /**
  34349. * Serializes the component data to the specified json object
  34350. * @param serializationObject The object to serialize to
  34351. */
  34352. serialize(serializationObject: any): void;
  34353. /**
  34354. * Adds all the element from the container to the scene
  34355. * @param container the container holding the elements
  34356. */
  34357. addFromContainer(container: AbstractScene): void;
  34358. /**
  34359. * Removes all the elements in the container from the scene
  34360. * @param container contains the elements to remove
  34361. */
  34362. removeFromContainer(container: AbstractScene): void;
  34363. /**
  34364. * Disposes the component and the associated ressources.
  34365. */
  34366. dispose(): void;
  34367. /**
  34368. * Disables audio in the associated scene.
  34369. */
  34370. disableAudio(): void;
  34371. /**
  34372. * Enables audio in the associated scene.
  34373. */
  34374. enableAudio(): void;
  34375. /**
  34376. * Switch audio to headphone output.
  34377. */
  34378. switchAudioModeForHeadphones(): void;
  34379. /**
  34380. * Switch audio to normal speakers.
  34381. */
  34382. switchAudioModeForNormalSpeakers(): void;
  34383. private _afterRender;
  34384. }
  34385. }
  34386. declare module "babylonjs/Audio/weightedsound" {
  34387. import { Sound } from "babylonjs/Audio/sound";
  34388. /**
  34389. * Wraps one or more Sound objects and selects one with random weight for playback.
  34390. */
  34391. export class WeightedSound {
  34392. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34393. loop: boolean;
  34394. private _coneInnerAngle;
  34395. private _coneOuterAngle;
  34396. private _volume;
  34397. /** A Sound is currently playing. */
  34398. isPlaying: boolean;
  34399. /** A Sound is currently paused. */
  34400. isPaused: boolean;
  34401. private _sounds;
  34402. private _weights;
  34403. private _currentIndex?;
  34404. /**
  34405. * Creates a new WeightedSound from the list of sounds given.
  34406. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34407. * @param sounds Array of Sounds that will be selected from.
  34408. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34409. */
  34410. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34411. /**
  34412. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34413. */
  34414. /**
  34415. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34416. */
  34417. directionalConeInnerAngle: number;
  34418. /**
  34419. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34420. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34421. */
  34422. /**
  34423. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34424. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34425. */
  34426. directionalConeOuterAngle: number;
  34427. /**
  34428. * Playback volume.
  34429. */
  34430. /**
  34431. * Playback volume.
  34432. */
  34433. volume: number;
  34434. private _onended;
  34435. /**
  34436. * Suspend playback
  34437. */
  34438. pause(): void;
  34439. /**
  34440. * Stop playback
  34441. */
  34442. stop(): void;
  34443. /**
  34444. * Start playback.
  34445. * @param startOffset Position the clip head at a specific time in seconds.
  34446. */
  34447. play(startOffset?: number): void;
  34448. }
  34449. }
  34450. declare module "babylonjs/Audio/index" {
  34451. export * from "babylonjs/Audio/analyser";
  34452. export * from "babylonjs/Audio/audioEngine";
  34453. export * from "babylonjs/Audio/audioSceneComponent";
  34454. export * from "babylonjs/Audio/sound";
  34455. export * from "babylonjs/Audio/soundTrack";
  34456. export * from "babylonjs/Audio/weightedsound";
  34457. }
  34458. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34459. import { Behavior } from "babylonjs/Behaviors/behavior";
  34460. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34461. import { BackEase } from "babylonjs/Animations/easing";
  34462. /**
  34463. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34464. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34465. */
  34466. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34467. /**
  34468. * Gets the name of the behavior.
  34469. */
  34470. readonly name: string;
  34471. /**
  34472. * The easing function used by animations
  34473. */
  34474. static EasingFunction: BackEase;
  34475. /**
  34476. * The easing mode used by animations
  34477. */
  34478. static EasingMode: number;
  34479. /**
  34480. * The duration of the animation, in milliseconds
  34481. */
  34482. transitionDuration: number;
  34483. /**
  34484. * Length of the distance animated by the transition when lower radius is reached
  34485. */
  34486. lowerRadiusTransitionRange: number;
  34487. /**
  34488. * Length of the distance animated by the transition when upper radius is reached
  34489. */
  34490. upperRadiusTransitionRange: number;
  34491. private _autoTransitionRange;
  34492. /**
  34493. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34494. */
  34495. /**
  34496. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34497. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34498. */
  34499. autoTransitionRange: boolean;
  34500. private _attachedCamera;
  34501. private _onAfterCheckInputsObserver;
  34502. private _onMeshTargetChangedObserver;
  34503. /**
  34504. * Initializes the behavior.
  34505. */
  34506. init(): void;
  34507. /**
  34508. * Attaches the behavior to its arc rotate camera.
  34509. * @param camera Defines the camera to attach the behavior to
  34510. */
  34511. attach(camera: ArcRotateCamera): void;
  34512. /**
  34513. * Detaches the behavior from its current arc rotate camera.
  34514. */
  34515. detach(): void;
  34516. private _radiusIsAnimating;
  34517. private _radiusBounceTransition;
  34518. private _animatables;
  34519. private _cachedWheelPrecision;
  34520. /**
  34521. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34522. * @param radiusLimit The limit to check against.
  34523. * @return Bool to indicate if at limit.
  34524. */
  34525. private _isRadiusAtLimit;
  34526. /**
  34527. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34528. * @param radiusDelta The delta by which to animate to. Can be negative.
  34529. */
  34530. private _applyBoundRadiusAnimation;
  34531. /**
  34532. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34533. */
  34534. protected _clearAnimationLocks(): void;
  34535. /**
  34536. * Stops and removes all animations that have been applied to the camera
  34537. */
  34538. stopAllAnimations(): void;
  34539. }
  34540. }
  34541. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34542. import { Behavior } from "babylonjs/Behaviors/behavior";
  34543. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34544. import { ExponentialEase } from "babylonjs/Animations/easing";
  34545. import { Nullable } from "babylonjs/types";
  34546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34547. import { Vector3 } from "babylonjs/Maths/math";
  34548. /**
  34549. * 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.
  34550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34551. */
  34552. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34553. /**
  34554. * Gets the name of the behavior.
  34555. */
  34556. readonly name: string;
  34557. private _mode;
  34558. private _radiusScale;
  34559. private _positionScale;
  34560. private _defaultElevation;
  34561. private _elevationReturnTime;
  34562. private _elevationReturnWaitTime;
  34563. private _zoomStopsAnimation;
  34564. private _framingTime;
  34565. /**
  34566. * The easing function used by animations
  34567. */
  34568. static EasingFunction: ExponentialEase;
  34569. /**
  34570. * The easing mode used by animations
  34571. */
  34572. static EasingMode: number;
  34573. /**
  34574. * Sets the current mode used by the behavior
  34575. */
  34576. /**
  34577. * Gets current mode used by the behavior.
  34578. */
  34579. mode: number;
  34580. /**
  34581. * Sets the scale applied to the radius (1 by default)
  34582. */
  34583. /**
  34584. * Gets the scale applied to the radius
  34585. */
  34586. radiusScale: number;
  34587. /**
  34588. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34589. */
  34590. /**
  34591. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34592. */
  34593. positionScale: number;
  34594. /**
  34595. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34596. * behaviour is triggered, in radians.
  34597. */
  34598. /**
  34599. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34600. * behaviour is triggered, in radians.
  34601. */
  34602. defaultElevation: number;
  34603. /**
  34604. * Sets the time (in milliseconds) taken to return to the default beta position.
  34605. * Negative value indicates camera should not return to default.
  34606. */
  34607. /**
  34608. * Gets the time (in milliseconds) taken to return to the default beta position.
  34609. * Negative value indicates camera should not return to default.
  34610. */
  34611. elevationReturnTime: number;
  34612. /**
  34613. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34614. */
  34615. /**
  34616. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34617. */
  34618. elevationReturnWaitTime: number;
  34619. /**
  34620. * Sets the flag that indicates if user zooming should stop animation.
  34621. */
  34622. /**
  34623. * Gets the flag that indicates if user zooming should stop animation.
  34624. */
  34625. zoomStopsAnimation: boolean;
  34626. /**
  34627. * Sets the transition time when framing the mesh, in milliseconds
  34628. */
  34629. /**
  34630. * Gets the transition time when framing the mesh, in milliseconds
  34631. */
  34632. framingTime: number;
  34633. /**
  34634. * Define if the behavior should automatically change the configured
  34635. * camera limits and sensibilities.
  34636. */
  34637. autoCorrectCameraLimitsAndSensibility: boolean;
  34638. private _onPrePointerObservableObserver;
  34639. private _onAfterCheckInputsObserver;
  34640. private _onMeshTargetChangedObserver;
  34641. private _attachedCamera;
  34642. private _isPointerDown;
  34643. private _lastInteractionTime;
  34644. /**
  34645. * Initializes the behavior.
  34646. */
  34647. init(): void;
  34648. /**
  34649. * Attaches the behavior to its arc rotate camera.
  34650. * @param camera Defines the camera to attach the behavior to
  34651. */
  34652. attach(camera: ArcRotateCamera): void;
  34653. /**
  34654. * Detaches the behavior from its current arc rotate camera.
  34655. */
  34656. detach(): void;
  34657. private _animatables;
  34658. private _betaIsAnimating;
  34659. private _betaTransition;
  34660. private _radiusTransition;
  34661. private _vectorTransition;
  34662. /**
  34663. * Targets the given mesh and updates zoom level accordingly.
  34664. * @param mesh The mesh to target.
  34665. * @param radius Optional. If a cached radius position already exists, overrides default.
  34666. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34669. */
  34670. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34671. /**
  34672. * Targets the given mesh with its children and updates zoom level accordingly.
  34673. * @param mesh The mesh to target.
  34674. * @param radius Optional. If a cached radius position already exists, overrides default.
  34675. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34676. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34677. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34678. */
  34679. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34680. /**
  34681. * Targets the given meshes with their children and updates zoom level accordingly.
  34682. * @param meshes The mesh to target.
  34683. * @param radius Optional. If a cached radius position already exists, overrides default.
  34684. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34687. */
  34688. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34689. /**
  34690. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34691. * @param minimumWorld Determines the smaller position of the bounding box extend
  34692. * @param maximumWorld Determines the bigger position of the bounding box extend
  34693. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34694. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34695. */
  34696. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34697. /**
  34698. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34699. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34700. * frustum width.
  34701. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34702. * to fully enclose the mesh in the viewing frustum.
  34703. */
  34704. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34705. /**
  34706. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34707. * is automatically returned to its default position (expected to be above ground plane).
  34708. */
  34709. private _maintainCameraAboveGround;
  34710. /**
  34711. * Returns the frustum slope based on the canvas ratio and camera FOV
  34712. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34713. */
  34714. private _getFrustumSlope;
  34715. /**
  34716. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34717. */
  34718. private _clearAnimationLocks;
  34719. /**
  34720. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34721. */
  34722. private _applyUserInteraction;
  34723. /**
  34724. * Stops and removes all animations that have been applied to the camera
  34725. */
  34726. stopAllAnimations(): void;
  34727. /**
  34728. * Gets a value indicating if the user is moving the camera
  34729. */
  34730. readonly isUserIsMoving: boolean;
  34731. /**
  34732. * The camera can move all the way towards the mesh.
  34733. */
  34734. static IgnoreBoundsSizeMode: number;
  34735. /**
  34736. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34737. */
  34738. static FitFrustumSidesMode: number;
  34739. }
  34740. }
  34741. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34742. import { Nullable } from "babylonjs/types";
  34743. import { Camera } from "babylonjs/Cameras/camera";
  34744. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34745. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34746. /**
  34747. * Base class for Camera Pointer Inputs.
  34748. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34749. * for example usage.
  34750. */
  34751. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34752. /**
  34753. * Defines the camera the input is attached to.
  34754. */
  34755. abstract camera: Camera;
  34756. /**
  34757. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34758. */
  34759. protected _altKey: boolean;
  34760. protected _ctrlKey: boolean;
  34761. protected _metaKey: boolean;
  34762. protected _shiftKey: boolean;
  34763. /**
  34764. * Which mouse buttons were pressed at time of last mouse event.
  34765. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34766. */
  34767. protected _buttonsPressed: number;
  34768. /**
  34769. * Defines the buttons associated with the input to handle camera move.
  34770. */
  34771. buttons: number[];
  34772. /**
  34773. * Attach the input controls to a specific dom element to get the input from.
  34774. * @param element Defines the element the controls should be listened from
  34775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34776. */
  34777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34778. /**
  34779. * Detach the current controls from the specified dom element.
  34780. * @param element Defines the element to stop listening the inputs from
  34781. */
  34782. detachControl(element: Nullable<HTMLElement>): void;
  34783. /**
  34784. * Gets the class name of the current input.
  34785. * @returns the class name
  34786. */
  34787. getClassName(): string;
  34788. /**
  34789. * Get the friendly name associated with the input class.
  34790. * @returns the input friendly name
  34791. */
  34792. getSimpleName(): string;
  34793. /**
  34794. * Called on pointer POINTERDOUBLETAP event.
  34795. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34796. */
  34797. protected onDoubleTap(type: string): void;
  34798. /**
  34799. * Called on pointer POINTERMOVE event if only a single touch is active.
  34800. * Override this method to provide functionality.
  34801. */
  34802. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34803. /**
  34804. * Called on pointer POINTERMOVE event if multiple touches are active.
  34805. * Override this method to provide functionality.
  34806. */
  34807. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34808. /**
  34809. * Called on JS contextmenu event.
  34810. * Override this method to provide functionality.
  34811. */
  34812. protected onContextMenu(evt: PointerEvent): void;
  34813. /**
  34814. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34815. * press.
  34816. * Override this method to provide functionality.
  34817. */
  34818. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34819. /**
  34820. * Called each time a new POINTERUP event occurs. Ie, for each button
  34821. * release.
  34822. * Override this method to provide functionality.
  34823. */
  34824. protected onButtonUp(evt: PointerEvent): void;
  34825. /**
  34826. * Called when window becomes inactive.
  34827. * Override this method to provide functionality.
  34828. */
  34829. protected onLostFocus(): void;
  34830. private _pointerInput;
  34831. private _observer;
  34832. private _onLostFocus;
  34833. }
  34834. }
  34835. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34836. import { Nullable } from "babylonjs/types";
  34837. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34838. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34839. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34840. /**
  34841. * Manage the pointers inputs to control an arc rotate camera.
  34842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34843. */
  34844. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34845. /**
  34846. * Defines the camera the input is attached to.
  34847. */
  34848. camera: ArcRotateCamera;
  34849. /**
  34850. * Gets the class name of the current input.
  34851. * @returns the class name
  34852. */
  34853. getClassName(): string;
  34854. /**
  34855. * Defines the buttons associated with the input to handle camera move.
  34856. */
  34857. buttons: number[];
  34858. /**
  34859. * Defines the pointer angular sensibility along the X axis or how fast is
  34860. * the camera rotating.
  34861. */
  34862. angularSensibilityX: number;
  34863. /**
  34864. * Defines the pointer angular sensibility along the Y axis or how fast is
  34865. * the camera rotating.
  34866. */
  34867. angularSensibilityY: number;
  34868. /**
  34869. * Defines the pointer pinch precision or how fast is the camera zooming.
  34870. */
  34871. pinchPrecision: number;
  34872. /**
  34873. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34874. * from 0.
  34875. * It defines the percentage of current camera.radius to use as delta when
  34876. * pinch zoom is used.
  34877. */
  34878. pinchDeltaPercentage: number;
  34879. /**
  34880. * Defines the pointer panning sensibility or how fast is the camera moving.
  34881. */
  34882. panningSensibility: number;
  34883. /**
  34884. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34885. */
  34886. multiTouchPanning: boolean;
  34887. /**
  34888. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34889. * zoom (pinch) through multitouch.
  34890. */
  34891. multiTouchPanAndZoom: boolean;
  34892. /**
  34893. * Revers pinch action direction.
  34894. */
  34895. pinchInwards: boolean;
  34896. private _isPanClick;
  34897. private _twoFingerActivityCount;
  34898. private _isPinching;
  34899. /**
  34900. * Called on pointer POINTERMOVE event if only a single touch is active.
  34901. */
  34902. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34903. /**
  34904. * Called on pointer POINTERDOUBLETAP event.
  34905. */
  34906. protected onDoubleTap(type: string): void;
  34907. /**
  34908. * Called on pointer POINTERMOVE event if multiple touches are active.
  34909. */
  34910. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34911. /**
  34912. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34913. * press.
  34914. */
  34915. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34916. /**
  34917. * Called each time a new POINTERUP event occurs. Ie, for each button
  34918. * release.
  34919. */
  34920. protected onButtonUp(evt: PointerEvent): void;
  34921. /**
  34922. * Called when window becomes inactive.
  34923. */
  34924. protected onLostFocus(): void;
  34925. }
  34926. }
  34927. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34928. import { Nullable } from "babylonjs/types";
  34929. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34930. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34931. /**
  34932. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34934. */
  34935. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34936. /**
  34937. * Defines the camera the input is attached to.
  34938. */
  34939. camera: ArcRotateCamera;
  34940. /**
  34941. * Defines the list of key codes associated with the up action (increase alpha)
  34942. */
  34943. keysUp: number[];
  34944. /**
  34945. * Defines the list of key codes associated with the down action (decrease alpha)
  34946. */
  34947. keysDown: number[];
  34948. /**
  34949. * Defines the list of key codes associated with the left action (increase beta)
  34950. */
  34951. keysLeft: number[];
  34952. /**
  34953. * Defines the list of key codes associated with the right action (decrease beta)
  34954. */
  34955. keysRight: number[];
  34956. /**
  34957. * Defines the list of key codes associated with the reset action.
  34958. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34959. */
  34960. keysReset: number[];
  34961. /**
  34962. * Defines the panning sensibility of the inputs.
  34963. * (How fast is the camera paning)
  34964. */
  34965. panningSensibility: number;
  34966. /**
  34967. * Defines the zooming sensibility of the inputs.
  34968. * (How fast is the camera zooming)
  34969. */
  34970. zoomingSensibility: number;
  34971. /**
  34972. * Defines wether maintaining the alt key down switch the movement mode from
  34973. * orientation to zoom.
  34974. */
  34975. useAltToZoom: boolean;
  34976. /**
  34977. * Rotation speed of the camera
  34978. */
  34979. angularSpeed: number;
  34980. private _keys;
  34981. private _ctrlPressed;
  34982. private _altPressed;
  34983. private _onCanvasBlurObserver;
  34984. private _onKeyboardObserver;
  34985. private _engine;
  34986. private _scene;
  34987. /**
  34988. * Attach the input controls to a specific dom element to get the input from.
  34989. * @param element Defines the element the controls should be listened from
  34990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34991. */
  34992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34993. /**
  34994. * Detach the current controls from the specified dom element.
  34995. * @param element Defines the element to stop listening the inputs from
  34996. */
  34997. detachControl(element: Nullable<HTMLElement>): void;
  34998. /**
  34999. * Update the current camera state depending on the inputs that have been used this frame.
  35000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35001. */
  35002. checkInputs(): void;
  35003. /**
  35004. * Gets the class name of the current intput.
  35005. * @returns the class name
  35006. */
  35007. getClassName(): string;
  35008. /**
  35009. * Get the friendly name associated with the input class.
  35010. * @returns the input friendly name
  35011. */
  35012. getSimpleName(): string;
  35013. }
  35014. }
  35015. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35016. import { Nullable } from "babylonjs/types";
  35017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35018. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35019. /**
  35020. * Manage the mouse wheel inputs to control an arc rotate camera.
  35021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35022. */
  35023. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35024. /**
  35025. * Defines the camera the input is attached to.
  35026. */
  35027. camera: ArcRotateCamera;
  35028. /**
  35029. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35030. */
  35031. wheelPrecision: number;
  35032. /**
  35033. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35034. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35035. */
  35036. wheelDeltaPercentage: number;
  35037. private _wheel;
  35038. private _observer;
  35039. /**
  35040. * Attach the input controls to a specific dom element to get the input from.
  35041. * @param element Defines the element the controls should be listened from
  35042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35043. */
  35044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35045. /**
  35046. * Detach the current controls from the specified dom element.
  35047. * @param element Defines the element to stop listening the inputs from
  35048. */
  35049. detachControl(element: Nullable<HTMLElement>): void;
  35050. /**
  35051. * Gets the class name of the current intput.
  35052. * @returns the class name
  35053. */
  35054. getClassName(): string;
  35055. /**
  35056. * Get the friendly name associated with the input class.
  35057. * @returns the input friendly name
  35058. */
  35059. getSimpleName(): string;
  35060. }
  35061. }
  35062. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35063. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35064. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35065. /**
  35066. * Default Inputs manager for the ArcRotateCamera.
  35067. * It groups all the default supported inputs for ease of use.
  35068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35069. */
  35070. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35071. /**
  35072. * Instantiates a new ArcRotateCameraInputsManager.
  35073. * @param camera Defines the camera the inputs belong to
  35074. */
  35075. constructor(camera: ArcRotateCamera);
  35076. /**
  35077. * Add mouse wheel input support to the input manager.
  35078. * @returns the current input manager
  35079. */
  35080. addMouseWheel(): ArcRotateCameraInputsManager;
  35081. /**
  35082. * Add pointers input support to the input manager.
  35083. * @returns the current input manager
  35084. */
  35085. addPointers(): ArcRotateCameraInputsManager;
  35086. /**
  35087. * Add keyboard input support to the input manager.
  35088. * @returns the current input manager
  35089. */
  35090. addKeyboard(): ArcRotateCameraInputsManager;
  35091. }
  35092. }
  35093. declare module "babylonjs/Cameras/arcRotateCamera" {
  35094. import { Observable } from "babylonjs/Misc/observable";
  35095. import { Nullable } from "babylonjs/types";
  35096. import { Scene } from "babylonjs/scene";
  35097. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35099. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35100. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35101. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35102. import { Camera } from "babylonjs/Cameras/camera";
  35103. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35104. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35105. import { Collider } from "babylonjs/Collisions/collider";
  35106. /**
  35107. * This represents an orbital type of camera.
  35108. *
  35109. * 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.
  35110. * 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.
  35111. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35112. */
  35113. export class ArcRotateCamera extends TargetCamera {
  35114. /**
  35115. * Defines the rotation angle of the camera along the longitudinal axis.
  35116. */
  35117. alpha: number;
  35118. /**
  35119. * Defines the rotation angle of the camera along the latitudinal axis.
  35120. */
  35121. beta: number;
  35122. /**
  35123. * Defines the radius of the camera from it s target point.
  35124. */
  35125. radius: number;
  35126. protected _target: Vector3;
  35127. protected _targetHost: Nullable<AbstractMesh>;
  35128. /**
  35129. * Defines the target point of the camera.
  35130. * The camera looks towards it form the radius distance.
  35131. */
  35132. target: Vector3;
  35133. /**
  35134. * Define the current local position of the camera in the scene
  35135. */
  35136. position: Vector3;
  35137. /**
  35138. * Current inertia value on the longitudinal axis.
  35139. * The bigger this number the longer it will take for the camera to stop.
  35140. */
  35141. inertialAlphaOffset: number;
  35142. /**
  35143. * Current inertia value on the latitudinal axis.
  35144. * The bigger this number the longer it will take for the camera to stop.
  35145. */
  35146. inertialBetaOffset: number;
  35147. /**
  35148. * Current inertia value on the radius axis.
  35149. * The bigger this number the longer it will take for the camera to stop.
  35150. */
  35151. inertialRadiusOffset: number;
  35152. /**
  35153. * Minimum allowed angle on the longitudinal axis.
  35154. * This can help limiting how the Camera is able to move in the scene.
  35155. */
  35156. lowerAlphaLimit: Nullable<number>;
  35157. /**
  35158. * Maximum allowed angle on the longitudinal axis.
  35159. * This can help limiting how the Camera is able to move in the scene.
  35160. */
  35161. upperAlphaLimit: Nullable<number>;
  35162. /**
  35163. * Minimum allowed angle on the latitudinal axis.
  35164. * This can help limiting how the Camera is able to move in the scene.
  35165. */
  35166. lowerBetaLimit: number;
  35167. /**
  35168. * Maximum allowed angle on the latitudinal axis.
  35169. * This can help limiting how the Camera is able to move in the scene.
  35170. */
  35171. upperBetaLimit: number;
  35172. /**
  35173. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35174. * This can help limiting how the Camera is able to move in the scene.
  35175. */
  35176. lowerRadiusLimit: Nullable<number>;
  35177. /**
  35178. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35179. * This can help limiting how the Camera is able to move in the scene.
  35180. */
  35181. upperRadiusLimit: Nullable<number>;
  35182. /**
  35183. * Defines the current inertia value used during panning of the camera along the X axis.
  35184. */
  35185. inertialPanningX: number;
  35186. /**
  35187. * Defines the current inertia value used during panning of the camera along the Y axis.
  35188. */
  35189. inertialPanningY: number;
  35190. /**
  35191. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35192. * Basically if your fingers moves away from more than this distance you will be considered
  35193. * in pinch mode.
  35194. */
  35195. pinchToPanMaxDistance: number;
  35196. /**
  35197. * Defines the maximum distance the camera can pan.
  35198. * This could help keeping the cammera always in your scene.
  35199. */
  35200. panningDistanceLimit: Nullable<number>;
  35201. /**
  35202. * Defines the target of the camera before paning.
  35203. */
  35204. panningOriginTarget: Vector3;
  35205. /**
  35206. * Defines the value of the inertia used during panning.
  35207. * 0 would mean stop inertia and one would mean no decelleration at all.
  35208. */
  35209. panningInertia: number;
  35210. /**
  35211. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35212. */
  35213. angularSensibilityX: number;
  35214. /**
  35215. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35216. */
  35217. angularSensibilityY: number;
  35218. /**
  35219. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35220. */
  35221. pinchPrecision: number;
  35222. /**
  35223. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35224. * It will be used instead of pinchDeltaPrecision if different from 0.
  35225. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35226. */
  35227. pinchDeltaPercentage: number;
  35228. /**
  35229. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35230. */
  35231. panningSensibility: number;
  35232. /**
  35233. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35234. */
  35235. keysUp: number[];
  35236. /**
  35237. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35238. */
  35239. keysDown: number[];
  35240. /**
  35241. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35242. */
  35243. keysLeft: number[];
  35244. /**
  35245. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35246. */
  35247. keysRight: number[];
  35248. /**
  35249. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35250. */
  35251. wheelPrecision: number;
  35252. /**
  35253. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35254. * It will be used instead of pinchDeltaPrecision if different from 0.
  35255. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35256. */
  35257. wheelDeltaPercentage: number;
  35258. /**
  35259. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35260. */
  35261. zoomOnFactor: number;
  35262. /**
  35263. * Defines a screen offset for the camera position.
  35264. */
  35265. targetScreenOffset: Vector2;
  35266. /**
  35267. * Allows the camera to be completely reversed.
  35268. * If false the camera can not arrive upside down.
  35269. */
  35270. allowUpsideDown: boolean;
  35271. /**
  35272. * Define if double tap/click is used to restore the previously saved state of the camera.
  35273. */
  35274. useInputToRestoreState: boolean;
  35275. /** @hidden */
  35276. _viewMatrix: Matrix;
  35277. /** @hidden */
  35278. _useCtrlForPanning: boolean;
  35279. /** @hidden */
  35280. _panningMouseButton: number;
  35281. /**
  35282. * Defines the input associated to the camera.
  35283. */
  35284. inputs: ArcRotateCameraInputsManager;
  35285. /** @hidden */
  35286. _reset: () => void;
  35287. /**
  35288. * Defines the allowed panning axis.
  35289. */
  35290. panningAxis: Vector3;
  35291. protected _localDirection: Vector3;
  35292. protected _transformedDirection: Vector3;
  35293. private _bouncingBehavior;
  35294. /**
  35295. * Gets the bouncing behavior of the camera if it has been enabled.
  35296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35297. */
  35298. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35299. /**
  35300. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35302. */
  35303. useBouncingBehavior: boolean;
  35304. private _framingBehavior;
  35305. /**
  35306. * Gets the framing behavior of the camera if it has been enabled.
  35307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35308. */
  35309. readonly framingBehavior: Nullable<FramingBehavior>;
  35310. /**
  35311. * Defines if the framing behavior of the camera is enabled on the camera.
  35312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35313. */
  35314. useFramingBehavior: boolean;
  35315. private _autoRotationBehavior;
  35316. /**
  35317. * Gets the auto rotation behavior of the camera if it has been enabled.
  35318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35319. */
  35320. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35321. /**
  35322. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35324. */
  35325. useAutoRotationBehavior: boolean;
  35326. /**
  35327. * Observable triggered when the mesh target has been changed on the camera.
  35328. */
  35329. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35330. /**
  35331. * Event raised when the camera is colliding with a mesh.
  35332. */
  35333. onCollide: (collidedMesh: AbstractMesh) => void;
  35334. /**
  35335. * Defines whether the camera should check collision with the objects oh the scene.
  35336. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35337. */
  35338. checkCollisions: boolean;
  35339. /**
  35340. * Defines the collision radius of the camera.
  35341. * This simulates a sphere around the camera.
  35342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35343. */
  35344. collisionRadius: Vector3;
  35345. protected _collider: Collider;
  35346. protected _previousPosition: Vector3;
  35347. protected _collisionVelocity: Vector3;
  35348. protected _newPosition: Vector3;
  35349. protected _previousAlpha: number;
  35350. protected _previousBeta: number;
  35351. protected _previousRadius: number;
  35352. protected _collisionTriggered: boolean;
  35353. protected _targetBoundingCenter: Nullable<Vector3>;
  35354. private _computationVector;
  35355. private _tempAxisVector;
  35356. private _tempAxisRotationMatrix;
  35357. /**
  35358. * Instantiates a new ArcRotateCamera in a given scene
  35359. * @param name Defines the name of the camera
  35360. * @param alpha Defines the camera rotation along the logitudinal axis
  35361. * @param beta Defines the camera rotation along the latitudinal axis
  35362. * @param radius Defines the camera distance from its target
  35363. * @param target Defines the camera target
  35364. * @param scene Defines the scene the camera belongs to
  35365. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35366. */
  35367. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35368. /** @hidden */
  35369. _initCache(): void;
  35370. /** @hidden */
  35371. _updateCache(ignoreParentClass?: boolean): void;
  35372. protected _getTargetPosition(): Vector3;
  35373. private _storedAlpha;
  35374. private _storedBeta;
  35375. private _storedRadius;
  35376. private _storedTarget;
  35377. /**
  35378. * Stores the current state of the camera (alpha, beta, radius and target)
  35379. * @returns the camera itself
  35380. */
  35381. storeState(): Camera;
  35382. /**
  35383. * @hidden
  35384. * Restored camera state. You must call storeState() first
  35385. */
  35386. _restoreStateValues(): boolean;
  35387. /** @hidden */
  35388. _isSynchronizedViewMatrix(): boolean;
  35389. /**
  35390. * Attached controls to the current camera.
  35391. * @param element Defines the element the controls should be listened from
  35392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35393. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35394. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35395. */
  35396. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35397. /**
  35398. * Detach the current controls from the camera.
  35399. * The camera will stop reacting to inputs.
  35400. * @param element Defines the element to stop listening the inputs from
  35401. */
  35402. detachControl(element: HTMLElement): void;
  35403. /** @hidden */
  35404. _checkInputs(): void;
  35405. protected _checkLimits(): void;
  35406. /**
  35407. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35408. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35409. */
  35410. rebuildAnglesAndRadius(updateView?: boolean): void;
  35411. /**
  35412. * Use a position to define the current camera related information like aplha, beta and radius
  35413. * @param position Defines the position to set the camera at
  35414. */
  35415. setPosition(position: Vector3): void;
  35416. /**
  35417. * Defines the target the camera should look at.
  35418. * This will automatically adapt alpha beta and radius to fit within the new target.
  35419. * @param target Defines the new target as a Vector or a mesh
  35420. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35421. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35422. */
  35423. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35424. /** @hidden */
  35425. _getViewMatrix(): Matrix;
  35426. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35427. /**
  35428. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35429. * @param meshes Defines the mesh to zoom on
  35430. * @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)
  35431. */
  35432. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35433. /**
  35434. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35435. * The target will be changed but the radius
  35436. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35437. * @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)
  35438. */
  35439. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35440. min: Vector3;
  35441. max: Vector3;
  35442. distance: number;
  35443. }, doNotUpdateMaxZ?: boolean): void;
  35444. /**
  35445. * @override
  35446. * Override Camera.createRigCamera
  35447. */
  35448. createRigCamera(name: string, cameraIndex: number): Camera;
  35449. /**
  35450. * @hidden
  35451. * @override
  35452. * Override Camera._updateRigCameras
  35453. */
  35454. _updateRigCameras(): void;
  35455. /**
  35456. * Destroy the camera and release the current resources hold by it.
  35457. */
  35458. dispose(): void;
  35459. /**
  35460. * Gets the current object class name.
  35461. * @return the class name
  35462. */
  35463. getClassName(): string;
  35464. }
  35465. }
  35466. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35467. import { Behavior } from "babylonjs/Behaviors/behavior";
  35468. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35469. /**
  35470. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35471. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35472. */
  35473. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35474. /**
  35475. * Gets the name of the behavior.
  35476. */
  35477. readonly name: string;
  35478. private _zoomStopsAnimation;
  35479. private _idleRotationSpeed;
  35480. private _idleRotationWaitTime;
  35481. private _idleRotationSpinupTime;
  35482. /**
  35483. * Sets the flag that indicates if user zooming should stop animation.
  35484. */
  35485. /**
  35486. * Gets the flag that indicates if user zooming should stop animation.
  35487. */
  35488. zoomStopsAnimation: boolean;
  35489. /**
  35490. * Sets the default speed at which the camera rotates around the model.
  35491. */
  35492. /**
  35493. * Gets the default speed at which the camera rotates around the model.
  35494. */
  35495. idleRotationSpeed: number;
  35496. /**
  35497. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35498. */
  35499. /**
  35500. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35501. */
  35502. idleRotationWaitTime: number;
  35503. /**
  35504. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35505. */
  35506. /**
  35507. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35508. */
  35509. idleRotationSpinupTime: number;
  35510. /**
  35511. * Gets a value indicating if the camera is currently rotating because of this behavior
  35512. */
  35513. readonly rotationInProgress: boolean;
  35514. private _onPrePointerObservableObserver;
  35515. private _onAfterCheckInputsObserver;
  35516. private _attachedCamera;
  35517. private _isPointerDown;
  35518. private _lastFrameTime;
  35519. private _lastInteractionTime;
  35520. private _cameraRotationSpeed;
  35521. /**
  35522. * Initializes the behavior.
  35523. */
  35524. init(): void;
  35525. /**
  35526. * Attaches the behavior to its arc rotate camera.
  35527. * @param camera Defines the camera to attach the behavior to
  35528. */
  35529. attach(camera: ArcRotateCamera): void;
  35530. /**
  35531. * Detaches the behavior from its current arc rotate camera.
  35532. */
  35533. detach(): void;
  35534. /**
  35535. * Returns true if user is scrolling.
  35536. * @return true if user is scrolling.
  35537. */
  35538. private _userIsZooming;
  35539. private _lastFrameRadius;
  35540. private _shouldAnimationStopForInteraction;
  35541. /**
  35542. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35543. */
  35544. private _applyUserInteraction;
  35545. private _userIsMoving;
  35546. }
  35547. }
  35548. declare module "babylonjs/Behaviors/Cameras/index" {
  35549. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35550. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35551. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35552. }
  35553. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35554. import { Mesh } from "babylonjs/Meshes/mesh";
  35555. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35556. import { Behavior } from "babylonjs/Behaviors/behavior";
  35557. /**
  35558. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35559. */
  35560. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35561. private ui;
  35562. /**
  35563. * The name of the behavior
  35564. */
  35565. name: string;
  35566. /**
  35567. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35568. */
  35569. distanceAwayFromFace: number;
  35570. /**
  35571. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35572. */
  35573. distanceAwayFromBottomOfFace: number;
  35574. private _faceVectors;
  35575. private _target;
  35576. private _scene;
  35577. private _onRenderObserver;
  35578. private _tmpMatrix;
  35579. private _tmpVector;
  35580. /**
  35581. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35582. * @param ui The transform node that should be attched to the mesh
  35583. */
  35584. constructor(ui: TransformNode);
  35585. /**
  35586. * Initializes the behavior
  35587. */
  35588. init(): void;
  35589. private _closestFace;
  35590. private _zeroVector;
  35591. private _lookAtTmpMatrix;
  35592. private _lookAtToRef;
  35593. /**
  35594. * Attaches the AttachToBoxBehavior to the passed in mesh
  35595. * @param target The mesh that the specified node will be attached to
  35596. */
  35597. attach(target: Mesh): void;
  35598. /**
  35599. * Detaches the behavior from the mesh
  35600. */
  35601. detach(): void;
  35602. }
  35603. }
  35604. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35605. import { Behavior } from "babylonjs/Behaviors/behavior";
  35606. import { Mesh } from "babylonjs/Meshes/mesh";
  35607. /**
  35608. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35609. */
  35610. export class FadeInOutBehavior implements Behavior<Mesh> {
  35611. /**
  35612. * Time in milliseconds to delay before fading in (Default: 0)
  35613. */
  35614. delay: number;
  35615. /**
  35616. * Time in milliseconds for the mesh to fade in (Default: 300)
  35617. */
  35618. fadeInTime: number;
  35619. private _millisecondsPerFrame;
  35620. private _hovered;
  35621. private _hoverValue;
  35622. private _ownerNode;
  35623. /**
  35624. * Instatiates the FadeInOutBehavior
  35625. */
  35626. constructor();
  35627. /**
  35628. * The name of the behavior
  35629. */
  35630. readonly name: string;
  35631. /**
  35632. * Initializes the behavior
  35633. */
  35634. init(): void;
  35635. /**
  35636. * Attaches the fade behavior on the passed in mesh
  35637. * @param ownerNode The mesh that will be faded in/out once attached
  35638. */
  35639. attach(ownerNode: Mesh): void;
  35640. /**
  35641. * Detaches the behavior from the mesh
  35642. */
  35643. detach(): void;
  35644. /**
  35645. * Triggers the mesh to begin fading in or out
  35646. * @param value if the object should fade in or out (true to fade in)
  35647. */
  35648. fadeIn(value: boolean): void;
  35649. private _update;
  35650. private _setAllVisibility;
  35651. }
  35652. }
  35653. declare module "babylonjs/Misc/pivotTools" {
  35654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35655. /**
  35656. * Class containing a set of static utilities functions for managing Pivots
  35657. * @hidden
  35658. */
  35659. export class PivotTools {
  35660. private static _PivotCached;
  35661. private static _OldPivotPoint;
  35662. private static _PivotTranslation;
  35663. private static _PivotTmpVector;
  35664. /** @hidden */
  35665. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35666. /** @hidden */
  35667. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35668. }
  35669. }
  35670. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35671. import { Scene } from "babylonjs/scene";
  35672. import { Vector4, Plane } from "babylonjs/Maths/math";
  35673. import { Mesh } from "babylonjs/Meshes/mesh";
  35674. /**
  35675. * Class containing static functions to help procedurally build meshes
  35676. */
  35677. export class PlaneBuilder {
  35678. /**
  35679. * Creates a plane mesh
  35680. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35681. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35682. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35686. * @param name defines the name of the mesh
  35687. * @param options defines the options used to create the mesh
  35688. * @param scene defines the hosting scene
  35689. * @returns the plane mesh
  35690. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35691. */
  35692. static CreatePlane(name: string, options: {
  35693. size?: number;
  35694. width?: number;
  35695. height?: number;
  35696. sideOrientation?: number;
  35697. frontUVs?: Vector4;
  35698. backUVs?: Vector4;
  35699. updatable?: boolean;
  35700. sourcePlane?: Plane;
  35701. }, scene: Scene): Mesh;
  35702. }
  35703. }
  35704. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35705. import { Behavior } from "babylonjs/Behaviors/behavior";
  35706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35707. import { Observable } from "babylonjs/Misc/observable";
  35708. import { Vector3 } from "babylonjs/Maths/math";
  35709. import { Ray } from "babylonjs/Culling/ray";
  35710. import "babylonjs/Meshes/Builders/planeBuilder";
  35711. /**
  35712. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35713. */
  35714. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35715. private static _AnyMouseID;
  35716. private _attachedNode;
  35717. private _dragPlane;
  35718. private _scene;
  35719. private _pointerObserver;
  35720. private _beforeRenderObserver;
  35721. private static _planeScene;
  35722. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35723. /**
  35724. * 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)
  35725. */
  35726. maxDragAngle: number;
  35727. /**
  35728. * @hidden
  35729. */
  35730. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35731. /**
  35732. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35733. */
  35734. currentDraggingPointerID: number;
  35735. /**
  35736. * The last position where the pointer hit the drag plane in world space
  35737. */
  35738. lastDragPosition: Vector3;
  35739. /**
  35740. * If the behavior is currently in a dragging state
  35741. */
  35742. dragging: boolean;
  35743. /**
  35744. * 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)
  35745. */
  35746. dragDeltaRatio: number;
  35747. /**
  35748. * If the drag plane orientation should be updated during the dragging (Default: true)
  35749. */
  35750. updateDragPlane: boolean;
  35751. private _debugMode;
  35752. private _moving;
  35753. /**
  35754. * Fires each time the attached mesh is dragged with the pointer
  35755. * * delta between last drag position and current drag position in world space
  35756. * * dragDistance along the drag axis
  35757. * * dragPlaneNormal normal of the current drag plane used during the drag
  35758. * * dragPlanePoint in world space where the drag intersects the drag plane
  35759. */
  35760. onDragObservable: Observable<{
  35761. delta: Vector3;
  35762. dragPlanePoint: Vector3;
  35763. dragPlaneNormal: Vector3;
  35764. dragDistance: number;
  35765. pointerId: number;
  35766. }>;
  35767. /**
  35768. * Fires each time a drag begins (eg. mouse down on mesh)
  35769. */
  35770. onDragStartObservable: Observable<{
  35771. dragPlanePoint: Vector3;
  35772. pointerId: number;
  35773. }>;
  35774. /**
  35775. * Fires each time a drag ends (eg. mouse release after drag)
  35776. */
  35777. onDragEndObservable: Observable<{
  35778. dragPlanePoint: Vector3;
  35779. pointerId: number;
  35780. }>;
  35781. /**
  35782. * If the attached mesh should be moved when dragged
  35783. */
  35784. moveAttached: boolean;
  35785. /**
  35786. * If the drag behavior will react to drag events (Default: true)
  35787. */
  35788. enabled: boolean;
  35789. /**
  35790. * If camera controls should be detached during the drag
  35791. */
  35792. detachCameraControls: boolean;
  35793. /**
  35794. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35795. */
  35796. useObjectOrienationForDragging: boolean;
  35797. private _options;
  35798. /**
  35799. * Creates a pointer drag behavior that can be attached to a mesh
  35800. * @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)
  35801. */
  35802. constructor(options?: {
  35803. dragAxis?: Vector3;
  35804. dragPlaneNormal?: Vector3;
  35805. });
  35806. /**
  35807. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35808. */
  35809. validateDrag: (targetPosition: Vector3) => boolean;
  35810. /**
  35811. * The name of the behavior
  35812. */
  35813. readonly name: string;
  35814. /**
  35815. * Initializes the behavior
  35816. */
  35817. init(): void;
  35818. private _tmpVector;
  35819. private _alternatePickedPoint;
  35820. private _worldDragAxis;
  35821. private _targetPosition;
  35822. private _attachedElement;
  35823. /**
  35824. * Attaches the drag behavior the passed in mesh
  35825. * @param ownerNode The mesh that will be dragged around once attached
  35826. */
  35827. attach(ownerNode: AbstractMesh): void;
  35828. /**
  35829. * Force relase the drag action by code.
  35830. */
  35831. releaseDrag(): void;
  35832. private _startDragRay;
  35833. private _lastPointerRay;
  35834. /**
  35835. * Simulates the start of a pointer drag event on the behavior
  35836. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35837. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35838. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35839. */
  35840. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35841. private _startDrag;
  35842. private _dragDelta;
  35843. private _moveDrag;
  35844. private _pickWithRayOnDragPlane;
  35845. private _pointA;
  35846. private _pointB;
  35847. private _pointC;
  35848. private _lineA;
  35849. private _lineB;
  35850. private _localAxis;
  35851. private _lookAt;
  35852. private _updateDragPlanePosition;
  35853. /**
  35854. * Detaches the behavior from the mesh
  35855. */
  35856. detach(): void;
  35857. }
  35858. }
  35859. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35860. import { Mesh } from "babylonjs/Meshes/mesh";
  35861. import { Behavior } from "babylonjs/Behaviors/behavior";
  35862. /**
  35863. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35864. */
  35865. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35866. private _dragBehaviorA;
  35867. private _dragBehaviorB;
  35868. private _startDistance;
  35869. private _initialScale;
  35870. private _targetScale;
  35871. private _ownerNode;
  35872. private _sceneRenderObserver;
  35873. /**
  35874. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35875. */
  35876. constructor();
  35877. /**
  35878. * The name of the behavior
  35879. */
  35880. readonly name: string;
  35881. /**
  35882. * Initializes the behavior
  35883. */
  35884. init(): void;
  35885. private _getCurrentDistance;
  35886. /**
  35887. * Attaches the scale behavior the passed in mesh
  35888. * @param ownerNode The mesh that will be scaled around once attached
  35889. */
  35890. attach(ownerNode: Mesh): void;
  35891. /**
  35892. * Detaches the behavior from the mesh
  35893. */
  35894. detach(): void;
  35895. }
  35896. }
  35897. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35898. import { Behavior } from "babylonjs/Behaviors/behavior";
  35899. import { Mesh } from "babylonjs/Meshes/mesh";
  35900. import { Observable } from "babylonjs/Misc/observable";
  35901. /**
  35902. * 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
  35903. */
  35904. export class SixDofDragBehavior implements Behavior<Mesh> {
  35905. private static _virtualScene;
  35906. private _ownerNode;
  35907. private _sceneRenderObserver;
  35908. private _scene;
  35909. private _targetPosition;
  35910. private _virtualOriginMesh;
  35911. private _virtualDragMesh;
  35912. private _pointerObserver;
  35913. private _moving;
  35914. private _startingOrientation;
  35915. /**
  35916. * 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)
  35917. */
  35918. private zDragFactor;
  35919. /**
  35920. * If the object should rotate to face the drag origin
  35921. */
  35922. rotateDraggedObject: boolean;
  35923. /**
  35924. * If the behavior is currently in a dragging state
  35925. */
  35926. dragging: boolean;
  35927. /**
  35928. * 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)
  35929. */
  35930. dragDeltaRatio: number;
  35931. /**
  35932. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35933. */
  35934. currentDraggingPointerID: number;
  35935. /**
  35936. * If camera controls should be detached during the drag
  35937. */
  35938. detachCameraControls: boolean;
  35939. /**
  35940. * Fires each time a drag starts
  35941. */
  35942. onDragStartObservable: Observable<{}>;
  35943. /**
  35944. * Fires each time a drag ends (eg. mouse release after drag)
  35945. */
  35946. onDragEndObservable: Observable<{}>;
  35947. /**
  35948. * 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
  35949. */
  35950. constructor();
  35951. /**
  35952. * The name of the behavior
  35953. */
  35954. readonly name: string;
  35955. /**
  35956. * Initializes the behavior
  35957. */
  35958. init(): void;
  35959. /**
  35960. * Attaches the scale behavior the passed in mesh
  35961. * @param ownerNode The mesh that will be scaled around once attached
  35962. */
  35963. attach(ownerNode: Mesh): void;
  35964. /**
  35965. * Detaches the behavior from the mesh
  35966. */
  35967. detach(): void;
  35968. }
  35969. }
  35970. declare module "babylonjs/Behaviors/Meshes/index" {
  35971. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35972. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35973. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35974. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35975. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35976. }
  35977. declare module "babylonjs/Behaviors/index" {
  35978. export * from "babylonjs/Behaviors/behavior";
  35979. export * from "babylonjs/Behaviors/Cameras/index";
  35980. export * from "babylonjs/Behaviors/Meshes/index";
  35981. }
  35982. declare module "babylonjs/Bones/boneIKController" {
  35983. import { Bone } from "babylonjs/Bones/bone";
  35984. import { Vector3 } from "babylonjs/Maths/math";
  35985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35986. import { Nullable } from "babylonjs/types";
  35987. /**
  35988. * Class used to apply inverse kinematics to bones
  35989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35990. */
  35991. export class BoneIKController {
  35992. private static _tmpVecs;
  35993. private static _tmpQuat;
  35994. private static _tmpMats;
  35995. /**
  35996. * Gets or sets the target mesh
  35997. */
  35998. targetMesh: AbstractMesh;
  35999. /** Gets or sets the mesh used as pole */
  36000. poleTargetMesh: AbstractMesh;
  36001. /**
  36002. * Gets or sets the bone used as pole
  36003. */
  36004. poleTargetBone: Nullable<Bone>;
  36005. /**
  36006. * Gets or sets the target position
  36007. */
  36008. targetPosition: Vector3;
  36009. /**
  36010. * Gets or sets the pole target position
  36011. */
  36012. poleTargetPosition: Vector3;
  36013. /**
  36014. * Gets or sets the pole target local offset
  36015. */
  36016. poleTargetLocalOffset: Vector3;
  36017. /**
  36018. * Gets or sets the pole angle
  36019. */
  36020. poleAngle: number;
  36021. /**
  36022. * Gets or sets the mesh associated with the controller
  36023. */
  36024. mesh: AbstractMesh;
  36025. /**
  36026. * 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)
  36027. */
  36028. slerpAmount: number;
  36029. private _bone1Quat;
  36030. private _bone1Mat;
  36031. private _bone2Ang;
  36032. private _bone1;
  36033. private _bone2;
  36034. private _bone1Length;
  36035. private _bone2Length;
  36036. private _maxAngle;
  36037. private _maxReach;
  36038. private _rightHandedSystem;
  36039. private _bendAxis;
  36040. private _slerping;
  36041. private _adjustRoll;
  36042. /**
  36043. * Gets or sets maximum allowed angle
  36044. */
  36045. maxAngle: number;
  36046. /**
  36047. * Creates a new BoneIKController
  36048. * @param mesh defines the mesh to control
  36049. * @param bone defines the bone to control
  36050. * @param options defines options to set up the controller
  36051. */
  36052. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36053. targetMesh?: AbstractMesh;
  36054. poleTargetMesh?: AbstractMesh;
  36055. poleTargetBone?: Bone;
  36056. poleTargetLocalOffset?: Vector3;
  36057. poleAngle?: number;
  36058. bendAxis?: Vector3;
  36059. maxAngle?: number;
  36060. slerpAmount?: number;
  36061. });
  36062. private _setMaxAngle;
  36063. /**
  36064. * Force the controller to update the bones
  36065. */
  36066. update(): void;
  36067. }
  36068. }
  36069. declare module "babylonjs/Bones/boneLookController" {
  36070. import { Vector3, Space } from "babylonjs/Maths/math";
  36071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36072. import { Bone } from "babylonjs/Bones/bone";
  36073. /**
  36074. * Class used to make a bone look toward a point in space
  36075. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36076. */
  36077. export class BoneLookController {
  36078. private static _tmpVecs;
  36079. private static _tmpQuat;
  36080. private static _tmpMats;
  36081. /**
  36082. * The target Vector3 that the bone will look at
  36083. */
  36084. target: Vector3;
  36085. /**
  36086. * The mesh that the bone is attached to
  36087. */
  36088. mesh: AbstractMesh;
  36089. /**
  36090. * The bone that will be looking to the target
  36091. */
  36092. bone: Bone;
  36093. /**
  36094. * The up axis of the coordinate system that is used when the bone is rotated
  36095. */
  36096. upAxis: Vector3;
  36097. /**
  36098. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36099. */
  36100. upAxisSpace: Space;
  36101. /**
  36102. * Used to make an adjustment to the yaw of the bone
  36103. */
  36104. adjustYaw: number;
  36105. /**
  36106. * Used to make an adjustment to the pitch of the bone
  36107. */
  36108. adjustPitch: number;
  36109. /**
  36110. * Used to make an adjustment to the roll of the bone
  36111. */
  36112. adjustRoll: number;
  36113. /**
  36114. * 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)
  36115. */
  36116. slerpAmount: number;
  36117. private _minYaw;
  36118. private _maxYaw;
  36119. private _minPitch;
  36120. private _maxPitch;
  36121. private _minYawSin;
  36122. private _minYawCos;
  36123. private _maxYawSin;
  36124. private _maxYawCos;
  36125. private _midYawConstraint;
  36126. private _minPitchTan;
  36127. private _maxPitchTan;
  36128. private _boneQuat;
  36129. private _slerping;
  36130. private _transformYawPitch;
  36131. private _transformYawPitchInv;
  36132. private _firstFrameSkipped;
  36133. private _yawRange;
  36134. private _fowardAxis;
  36135. /**
  36136. * Gets or sets the minimum yaw angle that the bone can look to
  36137. */
  36138. minYaw: number;
  36139. /**
  36140. * Gets or sets the maximum yaw angle that the bone can look to
  36141. */
  36142. maxYaw: number;
  36143. /**
  36144. * Gets or sets the minimum pitch angle that the bone can look to
  36145. */
  36146. minPitch: number;
  36147. /**
  36148. * Gets or sets the maximum pitch angle that the bone can look to
  36149. */
  36150. maxPitch: number;
  36151. /**
  36152. * Create a BoneLookController
  36153. * @param mesh the mesh that the bone belongs to
  36154. * @param bone the bone that will be looking to the target
  36155. * @param target the target Vector3 to look at
  36156. * @param options optional settings:
  36157. * * maxYaw: the maximum angle the bone will yaw to
  36158. * * minYaw: the minimum angle the bone will yaw to
  36159. * * maxPitch: the maximum angle the bone will pitch to
  36160. * * minPitch: the minimum angle the bone will yaw to
  36161. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36162. * * upAxis: the up axis of the coordinate system
  36163. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36164. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36165. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36166. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36167. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36168. * * adjustRoll: used to make an adjustment to the roll of the bone
  36169. **/
  36170. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36171. maxYaw?: number;
  36172. minYaw?: number;
  36173. maxPitch?: number;
  36174. minPitch?: number;
  36175. slerpAmount?: number;
  36176. upAxis?: Vector3;
  36177. upAxisSpace?: Space;
  36178. yawAxis?: Vector3;
  36179. pitchAxis?: Vector3;
  36180. adjustYaw?: number;
  36181. adjustPitch?: number;
  36182. adjustRoll?: number;
  36183. });
  36184. /**
  36185. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36186. */
  36187. update(): void;
  36188. private _getAngleDiff;
  36189. private _getAngleBetween;
  36190. private _isAngleBetween;
  36191. }
  36192. }
  36193. declare module "babylonjs/Bones/index" {
  36194. export * from "babylonjs/Bones/bone";
  36195. export * from "babylonjs/Bones/boneIKController";
  36196. export * from "babylonjs/Bones/boneLookController";
  36197. export * from "babylonjs/Bones/skeleton";
  36198. }
  36199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36200. import { Nullable } from "babylonjs/types";
  36201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36203. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36204. /**
  36205. * Manage the gamepad inputs to control an arc rotate camera.
  36206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36207. */
  36208. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36209. /**
  36210. * Defines the camera the input is attached to.
  36211. */
  36212. camera: ArcRotateCamera;
  36213. /**
  36214. * Defines the gamepad the input is gathering event from.
  36215. */
  36216. gamepad: Nullable<Gamepad>;
  36217. /**
  36218. * Defines the gamepad rotation sensiblity.
  36219. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36220. */
  36221. gamepadRotationSensibility: number;
  36222. /**
  36223. * Defines the gamepad move sensiblity.
  36224. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36225. */
  36226. gamepadMoveSensibility: number;
  36227. private _onGamepadConnectedObserver;
  36228. private _onGamepadDisconnectedObserver;
  36229. /**
  36230. * Attach the input controls to a specific dom element to get the input from.
  36231. * @param element Defines the element the controls should be listened from
  36232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36233. */
  36234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36235. /**
  36236. * Detach the current controls from the specified dom element.
  36237. * @param element Defines the element to stop listening the inputs from
  36238. */
  36239. detachControl(element: Nullable<HTMLElement>): void;
  36240. /**
  36241. * Update the current camera state depending on the inputs that have been used this frame.
  36242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36243. */
  36244. checkInputs(): void;
  36245. /**
  36246. * Gets the class name of the current intput.
  36247. * @returns the class name
  36248. */
  36249. getClassName(): string;
  36250. /**
  36251. * Get the friendly name associated with the input class.
  36252. * @returns the input friendly name
  36253. */
  36254. getSimpleName(): string;
  36255. }
  36256. }
  36257. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36258. import { Nullable } from "babylonjs/types";
  36259. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36260. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36261. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36262. interface ArcRotateCameraInputsManager {
  36263. /**
  36264. * Add orientation input support to the input manager.
  36265. * @returns the current input manager
  36266. */
  36267. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36268. }
  36269. }
  36270. /**
  36271. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36273. */
  36274. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36275. /**
  36276. * Defines the camera the input is attached to.
  36277. */
  36278. camera: ArcRotateCamera;
  36279. /**
  36280. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36281. */
  36282. alphaCorrection: number;
  36283. /**
  36284. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36285. */
  36286. gammaCorrection: number;
  36287. private _alpha;
  36288. private _gamma;
  36289. private _dirty;
  36290. private _deviceOrientationHandler;
  36291. /**
  36292. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36293. */
  36294. constructor();
  36295. /**
  36296. * Attach the input controls to a specific dom element to get the input from.
  36297. * @param element Defines the element the controls should be listened from
  36298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36299. */
  36300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36301. /** @hidden */
  36302. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36303. /**
  36304. * Update the current camera state depending on the inputs that have been used this frame.
  36305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36306. */
  36307. checkInputs(): void;
  36308. /**
  36309. * Detach the current controls from the specified dom element.
  36310. * @param element Defines the element to stop listening the inputs from
  36311. */
  36312. detachControl(element: Nullable<HTMLElement>): void;
  36313. /**
  36314. * Gets the class name of the current intput.
  36315. * @returns the class name
  36316. */
  36317. getClassName(): string;
  36318. /**
  36319. * Get the friendly name associated with the input class.
  36320. * @returns the input friendly name
  36321. */
  36322. getSimpleName(): string;
  36323. }
  36324. }
  36325. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36326. import { Nullable } from "babylonjs/types";
  36327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36328. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36329. /**
  36330. * Listen to mouse events to control the camera.
  36331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36332. */
  36333. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36334. /**
  36335. * Defines the camera the input is attached to.
  36336. */
  36337. camera: FlyCamera;
  36338. /**
  36339. * Defines if touch is enabled. (Default is true.)
  36340. */
  36341. touchEnabled: boolean;
  36342. /**
  36343. * Defines the buttons associated with the input to handle camera rotation.
  36344. */
  36345. buttons: number[];
  36346. /**
  36347. * Assign buttons for Yaw control.
  36348. */
  36349. buttonsYaw: number[];
  36350. /**
  36351. * Assign buttons for Pitch control.
  36352. */
  36353. buttonsPitch: number[];
  36354. /**
  36355. * Assign buttons for Roll control.
  36356. */
  36357. buttonsRoll: number[];
  36358. /**
  36359. * Detect if any button is being pressed while mouse is moved.
  36360. * -1 = Mouse locked.
  36361. * 0 = Left button.
  36362. * 1 = Middle Button.
  36363. * 2 = Right Button.
  36364. */
  36365. activeButton: number;
  36366. /**
  36367. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36368. * Higher values reduce its sensitivity.
  36369. */
  36370. angularSensibility: number;
  36371. private _mousemoveCallback;
  36372. private _observer;
  36373. private _rollObserver;
  36374. private previousPosition;
  36375. private noPreventDefault;
  36376. private element;
  36377. /**
  36378. * Listen to mouse events to control the camera.
  36379. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36381. */
  36382. constructor(touchEnabled?: boolean);
  36383. /**
  36384. * Attach the mouse control to the HTML DOM element.
  36385. * @param element Defines the element that listens to the input events.
  36386. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36387. */
  36388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36389. /**
  36390. * Detach the current controls from the specified dom element.
  36391. * @param element Defines the element to stop listening the inputs from
  36392. */
  36393. detachControl(element: Nullable<HTMLElement>): void;
  36394. /**
  36395. * Gets the class name of the current input.
  36396. * @returns the class name.
  36397. */
  36398. getClassName(): string;
  36399. /**
  36400. * Get the friendly name associated with the input class.
  36401. * @returns the input's friendly name.
  36402. */
  36403. getSimpleName(): string;
  36404. private _pointerInput;
  36405. private _onMouseMove;
  36406. /**
  36407. * Rotate camera by mouse offset.
  36408. */
  36409. private rotateCamera;
  36410. }
  36411. }
  36412. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36413. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36414. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36415. /**
  36416. * Default Inputs manager for the FlyCamera.
  36417. * It groups all the default supported inputs for ease of use.
  36418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36419. */
  36420. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36421. /**
  36422. * Instantiates a new FlyCameraInputsManager.
  36423. * @param camera Defines the camera the inputs belong to.
  36424. */
  36425. constructor(camera: FlyCamera);
  36426. /**
  36427. * Add keyboard input support to the input manager.
  36428. * @returns the new FlyCameraKeyboardMoveInput().
  36429. */
  36430. addKeyboard(): FlyCameraInputsManager;
  36431. /**
  36432. * Add mouse input support to the input manager.
  36433. * @param touchEnabled Enable touch screen support.
  36434. * @returns the new FlyCameraMouseInput().
  36435. */
  36436. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36437. }
  36438. }
  36439. declare module "babylonjs/Cameras/flyCamera" {
  36440. import { Scene } from "babylonjs/scene";
  36441. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36443. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36444. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36445. /**
  36446. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36447. * such as in a 3D Space Shooter or a Flight Simulator.
  36448. */
  36449. export class FlyCamera extends TargetCamera {
  36450. /**
  36451. * Define the collision ellipsoid of the camera.
  36452. * This is helpful for simulating a camera body, like a player's body.
  36453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36454. */
  36455. ellipsoid: Vector3;
  36456. /**
  36457. * Define an offset for the position of the ellipsoid around the camera.
  36458. * This can be helpful if the camera is attached away from the player's body center,
  36459. * such as at its head.
  36460. */
  36461. ellipsoidOffset: Vector3;
  36462. /**
  36463. * Enable or disable collisions of the camera with the rest of the scene objects.
  36464. */
  36465. checkCollisions: boolean;
  36466. /**
  36467. * Enable or disable gravity on the camera.
  36468. */
  36469. applyGravity: boolean;
  36470. /**
  36471. * Define the current direction the camera is moving to.
  36472. */
  36473. cameraDirection: Vector3;
  36474. /**
  36475. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36476. * This overrides and empties cameraRotation.
  36477. */
  36478. rotationQuaternion: Quaternion;
  36479. /**
  36480. * Track Roll to maintain the wanted Rolling when looking around.
  36481. */
  36482. _trackRoll: number;
  36483. /**
  36484. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36485. */
  36486. rollCorrect: number;
  36487. /**
  36488. * Mimic a banked turn, Rolling the camera when Yawing.
  36489. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36490. */
  36491. bankedTurn: boolean;
  36492. /**
  36493. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36494. */
  36495. bankedTurnLimit: number;
  36496. /**
  36497. * Value of 0 disables the banked Roll.
  36498. * Value of 1 is equal to the Yaw angle in radians.
  36499. */
  36500. bankedTurnMultiplier: number;
  36501. /**
  36502. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36503. */
  36504. inputs: FlyCameraInputsManager;
  36505. /**
  36506. * Gets the input sensibility for mouse input.
  36507. * Higher values reduce sensitivity.
  36508. */
  36509. /**
  36510. * Sets the input sensibility for a mouse input.
  36511. * Higher values reduce sensitivity.
  36512. */
  36513. angularSensibility: number;
  36514. /**
  36515. * Get the keys for camera movement forward.
  36516. */
  36517. /**
  36518. * Set the keys for camera movement forward.
  36519. */
  36520. keysForward: number[];
  36521. /**
  36522. * Get the keys for camera movement backward.
  36523. */
  36524. keysBackward: number[];
  36525. /**
  36526. * Get the keys for camera movement up.
  36527. */
  36528. /**
  36529. * Set the keys for camera movement up.
  36530. */
  36531. keysUp: number[];
  36532. /**
  36533. * Get the keys for camera movement down.
  36534. */
  36535. /**
  36536. * Set the keys for camera movement down.
  36537. */
  36538. keysDown: number[];
  36539. /**
  36540. * Get the keys for camera movement left.
  36541. */
  36542. /**
  36543. * Set the keys for camera movement left.
  36544. */
  36545. keysLeft: number[];
  36546. /**
  36547. * Set the keys for camera movement right.
  36548. */
  36549. /**
  36550. * Set the keys for camera movement right.
  36551. */
  36552. keysRight: number[];
  36553. /**
  36554. * Event raised when the camera collides with a mesh in the scene.
  36555. */
  36556. onCollide: (collidedMesh: AbstractMesh) => void;
  36557. private _collider;
  36558. private _needMoveForGravity;
  36559. private _oldPosition;
  36560. private _diffPosition;
  36561. private _newPosition;
  36562. /** @hidden */
  36563. _localDirection: Vector3;
  36564. /** @hidden */
  36565. _transformedDirection: Vector3;
  36566. /**
  36567. * Instantiates a FlyCamera.
  36568. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36569. * such as in a 3D Space Shooter or a Flight Simulator.
  36570. * @param name Define the name of the camera in the scene.
  36571. * @param position Define the starting position of the camera in the scene.
  36572. * @param scene Define the scene the camera belongs to.
  36573. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36574. */
  36575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36576. /**
  36577. * Attach a control to the HTML DOM element.
  36578. * @param element Defines the element that listens to the input events.
  36579. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36580. */
  36581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36582. /**
  36583. * Detach a control from the HTML DOM element.
  36584. * The camera will stop reacting to that input.
  36585. * @param element Defines the element that listens to the input events.
  36586. */
  36587. detachControl(element: HTMLElement): void;
  36588. private _collisionMask;
  36589. /**
  36590. * Get the mask that the camera ignores in collision events.
  36591. */
  36592. /**
  36593. * Set the mask that the camera ignores in collision events.
  36594. */
  36595. collisionMask: number;
  36596. /** @hidden */
  36597. _collideWithWorld(displacement: Vector3): void;
  36598. /** @hidden */
  36599. private _onCollisionPositionChange;
  36600. /** @hidden */
  36601. _checkInputs(): void;
  36602. /** @hidden */
  36603. _decideIfNeedsToMove(): boolean;
  36604. /** @hidden */
  36605. _updatePosition(): void;
  36606. /**
  36607. * Restore the Roll to its target value at the rate specified.
  36608. * @param rate - Higher means slower restoring.
  36609. * @hidden
  36610. */
  36611. restoreRoll(rate: number): void;
  36612. /**
  36613. * Destroy the camera and release the current resources held by it.
  36614. */
  36615. dispose(): void;
  36616. /**
  36617. * Get the current object class name.
  36618. * @returns the class name.
  36619. */
  36620. getClassName(): string;
  36621. }
  36622. }
  36623. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36624. import { Nullable } from "babylonjs/types";
  36625. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36626. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36627. /**
  36628. * Listen to keyboard events to control the camera.
  36629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36630. */
  36631. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36632. /**
  36633. * Defines the camera the input is attached to.
  36634. */
  36635. camera: FlyCamera;
  36636. /**
  36637. * The list of keyboard keys used to control the forward move of the camera.
  36638. */
  36639. keysForward: number[];
  36640. /**
  36641. * The list of keyboard keys used to control the backward move of the camera.
  36642. */
  36643. keysBackward: number[];
  36644. /**
  36645. * The list of keyboard keys used to control the forward move of the camera.
  36646. */
  36647. keysUp: number[];
  36648. /**
  36649. * The list of keyboard keys used to control the backward move of the camera.
  36650. */
  36651. keysDown: number[];
  36652. /**
  36653. * The list of keyboard keys used to control the right strafe move of the camera.
  36654. */
  36655. keysRight: number[];
  36656. /**
  36657. * The list of keyboard keys used to control the left strafe move of the camera.
  36658. */
  36659. keysLeft: number[];
  36660. private _keys;
  36661. private _onCanvasBlurObserver;
  36662. private _onKeyboardObserver;
  36663. private _engine;
  36664. private _scene;
  36665. /**
  36666. * Attach the input controls to a specific dom element to get the input from.
  36667. * @param element Defines the element the controls should be listened from
  36668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36669. */
  36670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36671. /**
  36672. * Detach the current controls from the specified dom element.
  36673. * @param element Defines the element to stop listening the inputs from
  36674. */
  36675. detachControl(element: Nullable<HTMLElement>): void;
  36676. /**
  36677. * Gets the class name of the current intput.
  36678. * @returns the class name
  36679. */
  36680. getClassName(): string;
  36681. /** @hidden */
  36682. _onLostFocus(e: FocusEvent): void;
  36683. /**
  36684. * Get the friendly name associated with the input class.
  36685. * @returns the input friendly name
  36686. */
  36687. getSimpleName(): string;
  36688. /**
  36689. * Update the current camera state depending on the inputs that have been used this frame.
  36690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36691. */
  36692. checkInputs(): void;
  36693. }
  36694. }
  36695. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36696. import { Nullable } from "babylonjs/types";
  36697. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36698. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36699. /**
  36700. * Manage the mouse wheel inputs to control a follow camera.
  36701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36702. */
  36703. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36704. /**
  36705. * Defines the camera the input is attached to.
  36706. */
  36707. camera: FollowCamera;
  36708. /**
  36709. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36710. */
  36711. axisControlRadius: boolean;
  36712. /**
  36713. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36714. */
  36715. axisControlHeight: boolean;
  36716. /**
  36717. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36718. */
  36719. axisControlRotation: boolean;
  36720. /**
  36721. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36722. * relation to mouseWheel events.
  36723. */
  36724. wheelPrecision: number;
  36725. /**
  36726. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36727. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36728. */
  36729. wheelDeltaPercentage: number;
  36730. private _wheel;
  36731. private _observer;
  36732. /**
  36733. * Attach the input controls to a specific dom element to get the input from.
  36734. * @param element Defines the element the controls should be listened from
  36735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36736. */
  36737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36738. /**
  36739. * Detach the current controls from the specified dom element.
  36740. * @param element Defines the element to stop listening the inputs from
  36741. */
  36742. detachControl(element: Nullable<HTMLElement>): void;
  36743. /**
  36744. * Gets the class name of the current intput.
  36745. * @returns the class name
  36746. */
  36747. getClassName(): string;
  36748. /**
  36749. * Get the friendly name associated with the input class.
  36750. * @returns the input friendly name
  36751. */
  36752. getSimpleName(): string;
  36753. }
  36754. }
  36755. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36756. import { Nullable } from "babylonjs/types";
  36757. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36758. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36759. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36760. /**
  36761. * Manage the pointers inputs to control an follow camera.
  36762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36763. */
  36764. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36765. /**
  36766. * Defines the camera the input is attached to.
  36767. */
  36768. camera: FollowCamera;
  36769. /**
  36770. * Gets the class name of the current input.
  36771. * @returns the class name
  36772. */
  36773. getClassName(): string;
  36774. /**
  36775. * Defines the pointer angular sensibility along the X axis or how fast is
  36776. * the camera rotating.
  36777. * A negative number will reverse the axis direction.
  36778. */
  36779. angularSensibilityX: number;
  36780. /**
  36781. * Defines the pointer angular sensibility along the Y axis or how fast is
  36782. * the camera rotating.
  36783. * A negative number will reverse the axis direction.
  36784. */
  36785. angularSensibilityY: number;
  36786. /**
  36787. * Defines the pointer pinch precision or how fast is the camera zooming.
  36788. * A negative number will reverse the axis direction.
  36789. */
  36790. pinchPrecision: number;
  36791. /**
  36792. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36793. * from 0.
  36794. * It defines the percentage of current camera.radius to use as delta when
  36795. * pinch zoom is used.
  36796. */
  36797. pinchDeltaPercentage: number;
  36798. /**
  36799. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36800. */
  36801. axisXControlRadius: boolean;
  36802. /**
  36803. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36804. */
  36805. axisXControlHeight: boolean;
  36806. /**
  36807. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36808. */
  36809. axisXControlRotation: boolean;
  36810. /**
  36811. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36812. */
  36813. axisYControlRadius: boolean;
  36814. /**
  36815. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36816. */
  36817. axisYControlHeight: boolean;
  36818. /**
  36819. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36820. */
  36821. axisYControlRotation: boolean;
  36822. /**
  36823. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36824. */
  36825. axisPinchControlRadius: boolean;
  36826. /**
  36827. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36828. */
  36829. axisPinchControlHeight: boolean;
  36830. /**
  36831. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36832. */
  36833. axisPinchControlRotation: boolean;
  36834. /**
  36835. * Log error messages if basic misconfiguration has occurred.
  36836. */
  36837. warningEnable: boolean;
  36838. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36839. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36840. private _warningCounter;
  36841. private _warning;
  36842. }
  36843. }
  36844. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36845. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36846. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36847. /**
  36848. * Default Inputs manager for the FollowCamera.
  36849. * It groups all the default supported inputs for ease of use.
  36850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36851. */
  36852. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36853. /**
  36854. * Instantiates a new FollowCameraInputsManager.
  36855. * @param camera Defines the camera the inputs belong to
  36856. */
  36857. constructor(camera: FollowCamera);
  36858. /**
  36859. * Add keyboard input support to the input manager.
  36860. * @returns the current input manager
  36861. */
  36862. addKeyboard(): FollowCameraInputsManager;
  36863. /**
  36864. * Add mouse wheel input support to the input manager.
  36865. * @returns the current input manager
  36866. */
  36867. addMouseWheel(): FollowCameraInputsManager;
  36868. /**
  36869. * Add pointers input support to the input manager.
  36870. * @returns the current input manager
  36871. */
  36872. addPointers(): FollowCameraInputsManager;
  36873. /**
  36874. * Add orientation input support to the input manager.
  36875. * @returns the current input manager
  36876. */
  36877. addVRDeviceOrientation(): FollowCameraInputsManager;
  36878. }
  36879. }
  36880. declare module "babylonjs/Cameras/followCamera" {
  36881. import { Nullable } from "babylonjs/types";
  36882. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36883. import { Scene } from "babylonjs/scene";
  36884. import { Vector3 } from "babylonjs/Maths/math";
  36885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36886. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36887. /**
  36888. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36889. * an arc rotate version arcFollowCamera are available.
  36890. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36891. */
  36892. export class FollowCamera extends TargetCamera {
  36893. /**
  36894. * Distance the follow camera should follow an object at
  36895. */
  36896. radius: number;
  36897. /**
  36898. * Minimum allowed distance of the camera to the axis of rotation
  36899. * (The camera can not get closer).
  36900. * This can help limiting how the Camera is able to move in the scene.
  36901. */
  36902. lowerRadiusLimit: Nullable<number>;
  36903. /**
  36904. * Maximum allowed distance of the camera to the axis of rotation
  36905. * (The camera can not get further).
  36906. * This can help limiting how the Camera is able to move in the scene.
  36907. */
  36908. upperRadiusLimit: Nullable<number>;
  36909. /**
  36910. * Define a rotation offset between the camera and the object it follows
  36911. */
  36912. rotationOffset: number;
  36913. /**
  36914. * Minimum allowed angle to camera position relative to target object.
  36915. * This can help limiting how the Camera is able to move in the scene.
  36916. */
  36917. lowerRotationOffsetLimit: Nullable<number>;
  36918. /**
  36919. * Maximum allowed angle to camera position relative to target object.
  36920. * This can help limiting how the Camera is able to move in the scene.
  36921. */
  36922. upperRotationOffsetLimit: Nullable<number>;
  36923. /**
  36924. * Define a height offset between the camera and the object it follows.
  36925. * It can help following an object from the top (like a car chaing a plane)
  36926. */
  36927. heightOffset: number;
  36928. /**
  36929. * Minimum allowed height of camera position relative to target object.
  36930. * This can help limiting how the Camera is able to move in the scene.
  36931. */
  36932. lowerHeightOffsetLimit: Nullable<number>;
  36933. /**
  36934. * Maximum allowed height of camera position relative to target object.
  36935. * This can help limiting how the Camera is able to move in the scene.
  36936. */
  36937. upperHeightOffsetLimit: Nullable<number>;
  36938. /**
  36939. * Define how fast the camera can accelerate to follow it s target.
  36940. */
  36941. cameraAcceleration: number;
  36942. /**
  36943. * Define the speed limit of the camera following an object.
  36944. */
  36945. maxCameraSpeed: number;
  36946. /**
  36947. * Define the target of the camera.
  36948. */
  36949. lockedTarget: Nullable<AbstractMesh>;
  36950. /**
  36951. * Defines the input associated with the camera.
  36952. */
  36953. inputs: FollowCameraInputsManager;
  36954. /**
  36955. * Instantiates the follow camera.
  36956. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36957. * @param name Define the name of the camera in the scene
  36958. * @param position Define the position of the camera
  36959. * @param scene Define the scene the camera belong to
  36960. * @param lockedTarget Define the target of the camera
  36961. */
  36962. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36963. private _follow;
  36964. /**
  36965. * Attached controls to the current camera.
  36966. * @param element Defines the element the controls should be listened from
  36967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36968. */
  36969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36970. /**
  36971. * Detach the current controls from the camera.
  36972. * The camera will stop reacting to inputs.
  36973. * @param element Defines the element to stop listening the inputs from
  36974. */
  36975. detachControl(element: HTMLElement): void;
  36976. /** @hidden */
  36977. _checkInputs(): void;
  36978. private _checkLimits;
  36979. /**
  36980. * Gets the camera class name.
  36981. * @returns the class name
  36982. */
  36983. getClassName(): string;
  36984. }
  36985. /**
  36986. * Arc Rotate version of the follow camera.
  36987. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36988. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36989. */
  36990. export class ArcFollowCamera extends TargetCamera {
  36991. /** The longitudinal angle of the camera */
  36992. alpha: number;
  36993. /** The latitudinal angle of the camera */
  36994. beta: number;
  36995. /** The radius of the camera from its target */
  36996. radius: number;
  36997. /** Define the camera target (the messh it should follow) */
  36998. target: Nullable<AbstractMesh>;
  36999. private _cartesianCoordinates;
  37000. /**
  37001. * Instantiates a new ArcFollowCamera
  37002. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37003. * @param name Define the name of the camera
  37004. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37005. * @param beta Define the rotation angle of the camera around the elevation axis
  37006. * @param radius Define the radius of the camera from its target point
  37007. * @param target Define the target of the camera
  37008. * @param scene Define the scene the camera belongs to
  37009. */
  37010. constructor(name: string,
  37011. /** The longitudinal angle of the camera */
  37012. alpha: number,
  37013. /** The latitudinal angle of the camera */
  37014. beta: number,
  37015. /** The radius of the camera from its target */
  37016. radius: number,
  37017. /** Define the camera target (the messh it should follow) */
  37018. target: Nullable<AbstractMesh>, scene: Scene);
  37019. private _follow;
  37020. /** @hidden */
  37021. _checkInputs(): void;
  37022. /**
  37023. * Returns the class name of the object.
  37024. * It is mostly used internally for serialization purposes.
  37025. */
  37026. getClassName(): string;
  37027. }
  37028. }
  37029. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37031. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37032. import { Nullable } from "babylonjs/types";
  37033. /**
  37034. * Manage the keyboard inputs to control the movement of a follow camera.
  37035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37036. */
  37037. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37038. /**
  37039. * Defines the camera the input is attached to.
  37040. */
  37041. camera: FollowCamera;
  37042. /**
  37043. * Defines the list of key codes associated with the up action (increase heightOffset)
  37044. */
  37045. keysHeightOffsetIncr: number[];
  37046. /**
  37047. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37048. */
  37049. keysHeightOffsetDecr: number[];
  37050. /**
  37051. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37052. */
  37053. keysHeightOffsetModifierAlt: boolean;
  37054. /**
  37055. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37056. */
  37057. keysHeightOffsetModifierCtrl: boolean;
  37058. /**
  37059. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37060. */
  37061. keysHeightOffsetModifierShift: boolean;
  37062. /**
  37063. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37064. */
  37065. keysRotationOffsetIncr: number[];
  37066. /**
  37067. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37068. */
  37069. keysRotationOffsetDecr: number[];
  37070. /**
  37071. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37072. */
  37073. keysRotationOffsetModifierAlt: boolean;
  37074. /**
  37075. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37076. */
  37077. keysRotationOffsetModifierCtrl: boolean;
  37078. /**
  37079. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37080. */
  37081. keysRotationOffsetModifierShift: boolean;
  37082. /**
  37083. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37084. */
  37085. keysRadiusIncr: number[];
  37086. /**
  37087. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37088. */
  37089. keysRadiusDecr: number[];
  37090. /**
  37091. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37092. */
  37093. keysRadiusModifierAlt: boolean;
  37094. /**
  37095. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37096. */
  37097. keysRadiusModifierCtrl: boolean;
  37098. /**
  37099. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37100. */
  37101. keysRadiusModifierShift: boolean;
  37102. /**
  37103. * Defines the rate of change of heightOffset.
  37104. */
  37105. heightSensibility: number;
  37106. /**
  37107. * Defines the rate of change of rotationOffset.
  37108. */
  37109. rotationSensibility: number;
  37110. /**
  37111. * Defines the rate of change of radius.
  37112. */
  37113. radiusSensibility: number;
  37114. private _keys;
  37115. private _ctrlPressed;
  37116. private _altPressed;
  37117. private _shiftPressed;
  37118. private _onCanvasBlurObserver;
  37119. private _onKeyboardObserver;
  37120. private _engine;
  37121. private _scene;
  37122. /**
  37123. * Attach the input controls to a specific dom element to get the input from.
  37124. * @param element Defines the element the controls should be listened from
  37125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37126. */
  37127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37128. /**
  37129. * Detach the current controls from the specified dom element.
  37130. * @param element Defines the element to stop listening the inputs from
  37131. */
  37132. detachControl(element: Nullable<HTMLElement>): void;
  37133. /**
  37134. * Update the current camera state depending on the inputs that have been used this frame.
  37135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37136. */
  37137. checkInputs(): void;
  37138. /**
  37139. * Gets the class name of the current input.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. /**
  37149. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37150. * allow modification of the heightOffset value.
  37151. */
  37152. private _modifierHeightOffset;
  37153. /**
  37154. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37155. * allow modification of the rotationOffset value.
  37156. */
  37157. private _modifierRotationOffset;
  37158. /**
  37159. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37160. * allow modification of the radius value.
  37161. */
  37162. private _modifierRadius;
  37163. }
  37164. }
  37165. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37166. import { Nullable } from "babylonjs/types";
  37167. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37169. module "babylonjs/Cameras/freeCameraInputsManager" {
  37170. interface FreeCameraInputsManager {
  37171. /**
  37172. * Add orientation input support to the input manager.
  37173. * @returns the current input manager
  37174. */
  37175. addDeviceOrientation(): FreeCameraInputsManager;
  37176. }
  37177. }
  37178. /**
  37179. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37180. * Screen rotation is taken into account.
  37181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37182. */
  37183. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37184. private _camera;
  37185. private _screenOrientationAngle;
  37186. private _constantTranform;
  37187. private _screenQuaternion;
  37188. private _alpha;
  37189. private _beta;
  37190. private _gamma;
  37191. /**
  37192. * Instantiates a new input
  37193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37194. */
  37195. constructor();
  37196. /**
  37197. * Define the camera controlled by the input.
  37198. */
  37199. camera: FreeCamera;
  37200. /**
  37201. * Attach the input controls to a specific dom element to get the input from.
  37202. * @param element Defines the element the controls should be listened from
  37203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37204. */
  37205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37206. private _orientationChanged;
  37207. private _deviceOrientation;
  37208. /**
  37209. * Detach the current controls from the specified dom element.
  37210. * @param element Defines the element to stop listening the inputs from
  37211. */
  37212. detachControl(element: Nullable<HTMLElement>): void;
  37213. /**
  37214. * Update the current camera state depending on the inputs that have been used this frame.
  37215. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37216. */
  37217. checkInputs(): void;
  37218. /**
  37219. * Gets the class name of the current intput.
  37220. * @returns the class name
  37221. */
  37222. getClassName(): string;
  37223. /**
  37224. * Get the friendly name associated with the input class.
  37225. * @returns the input friendly name
  37226. */
  37227. getSimpleName(): string;
  37228. }
  37229. }
  37230. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37231. import { Nullable } from "babylonjs/types";
  37232. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37233. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37234. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37235. /**
  37236. * Manage the gamepad inputs to control a free camera.
  37237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37238. */
  37239. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37240. /**
  37241. * Define the camera the input is attached to.
  37242. */
  37243. camera: FreeCamera;
  37244. /**
  37245. * Define the Gamepad controlling the input
  37246. */
  37247. gamepad: Nullable<Gamepad>;
  37248. /**
  37249. * Defines the gamepad rotation sensiblity.
  37250. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37251. */
  37252. gamepadAngularSensibility: number;
  37253. /**
  37254. * Defines the gamepad move sensiblity.
  37255. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37256. */
  37257. gamepadMoveSensibility: number;
  37258. private _onGamepadConnectedObserver;
  37259. private _onGamepadDisconnectedObserver;
  37260. private _cameraTransform;
  37261. private _deltaTransform;
  37262. private _vector3;
  37263. private _vector2;
  37264. /**
  37265. * Attach the input controls to a specific dom element to get the input from.
  37266. * @param element Defines the element the controls should be listened from
  37267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37268. */
  37269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37270. /**
  37271. * Detach the current controls from the specified dom element.
  37272. * @param element Defines the element to stop listening the inputs from
  37273. */
  37274. detachControl(element: Nullable<HTMLElement>): void;
  37275. /**
  37276. * Update the current camera state depending on the inputs that have been used this frame.
  37277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37278. */
  37279. checkInputs(): void;
  37280. /**
  37281. * Gets the class name of the current intput.
  37282. * @returns the class name
  37283. */
  37284. getClassName(): string;
  37285. /**
  37286. * Get the friendly name associated with the input class.
  37287. * @returns the input friendly name
  37288. */
  37289. getSimpleName(): string;
  37290. }
  37291. }
  37292. declare module "babylonjs/Misc/virtualJoystick" {
  37293. import { Nullable } from "babylonjs/types";
  37294. import { Vector3 } from "babylonjs/Maths/math";
  37295. /**
  37296. * Defines the potential axis of a Joystick
  37297. */
  37298. export enum JoystickAxis {
  37299. /** X axis */
  37300. X = 0,
  37301. /** Y axis */
  37302. Y = 1,
  37303. /** Z axis */
  37304. Z = 2
  37305. }
  37306. /**
  37307. * Class used to define virtual joystick (used in touch mode)
  37308. */
  37309. export class VirtualJoystick {
  37310. /**
  37311. * Gets or sets a boolean indicating that left and right values must be inverted
  37312. */
  37313. reverseLeftRight: boolean;
  37314. /**
  37315. * Gets or sets a boolean indicating that up and down values must be inverted
  37316. */
  37317. reverseUpDown: boolean;
  37318. /**
  37319. * Gets the offset value for the position (ie. the change of the position value)
  37320. */
  37321. deltaPosition: Vector3;
  37322. /**
  37323. * Gets a boolean indicating if the virtual joystick was pressed
  37324. */
  37325. pressed: boolean;
  37326. /**
  37327. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37328. */
  37329. static Canvas: Nullable<HTMLCanvasElement>;
  37330. private static _globalJoystickIndex;
  37331. private static vjCanvasContext;
  37332. private static vjCanvasWidth;
  37333. private static vjCanvasHeight;
  37334. private static halfWidth;
  37335. private _action;
  37336. private _axisTargetedByLeftAndRight;
  37337. private _axisTargetedByUpAndDown;
  37338. private _joystickSensibility;
  37339. private _inversedSensibility;
  37340. private _joystickPointerID;
  37341. private _joystickColor;
  37342. private _joystickPointerPos;
  37343. private _joystickPreviousPointerPos;
  37344. private _joystickPointerStartPos;
  37345. private _deltaJoystickVector;
  37346. private _leftJoystick;
  37347. private _touches;
  37348. private _onPointerDownHandlerRef;
  37349. private _onPointerMoveHandlerRef;
  37350. private _onPointerUpHandlerRef;
  37351. private _onResize;
  37352. /**
  37353. * Creates a new virtual joystick
  37354. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37355. */
  37356. constructor(leftJoystick?: boolean);
  37357. /**
  37358. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37359. * @param newJoystickSensibility defines the new sensibility
  37360. */
  37361. setJoystickSensibility(newJoystickSensibility: number): void;
  37362. private _onPointerDown;
  37363. private _onPointerMove;
  37364. private _onPointerUp;
  37365. /**
  37366. * Change the color of the virtual joystick
  37367. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37368. */
  37369. setJoystickColor(newColor: string): void;
  37370. /**
  37371. * Defines a callback to call when the joystick is touched
  37372. * @param action defines the callback
  37373. */
  37374. setActionOnTouch(action: () => any): void;
  37375. /**
  37376. * Defines which axis you'd like to control for left & right
  37377. * @param axis defines the axis to use
  37378. */
  37379. setAxisForLeftRight(axis: JoystickAxis): void;
  37380. /**
  37381. * Defines which axis you'd like to control for up & down
  37382. * @param axis defines the axis to use
  37383. */
  37384. setAxisForUpDown(axis: JoystickAxis): void;
  37385. private _drawVirtualJoystick;
  37386. /**
  37387. * Release internal HTML canvas
  37388. */
  37389. releaseCanvas(): void;
  37390. }
  37391. }
  37392. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37393. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37394. import { Nullable } from "babylonjs/types";
  37395. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37397. module "babylonjs/Cameras/freeCameraInputsManager" {
  37398. interface FreeCameraInputsManager {
  37399. /**
  37400. * Add virtual joystick input support to the input manager.
  37401. * @returns the current input manager
  37402. */
  37403. addVirtualJoystick(): FreeCameraInputsManager;
  37404. }
  37405. }
  37406. /**
  37407. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37409. */
  37410. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37411. /**
  37412. * Defines the camera the input is attached to.
  37413. */
  37414. camera: FreeCamera;
  37415. private _leftjoystick;
  37416. private _rightjoystick;
  37417. /**
  37418. * Gets the left stick of the virtual joystick.
  37419. * @returns The virtual Joystick
  37420. */
  37421. getLeftJoystick(): VirtualJoystick;
  37422. /**
  37423. * Gets the right stick of the virtual joystick.
  37424. * @returns The virtual Joystick
  37425. */
  37426. getRightJoystick(): VirtualJoystick;
  37427. /**
  37428. * Update the current camera state depending on the inputs that have been used this frame.
  37429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37430. */
  37431. checkInputs(): void;
  37432. /**
  37433. * Attach the input controls to a specific dom element to get the input from.
  37434. * @param element Defines the element the controls should be listened from
  37435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37436. */
  37437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37438. /**
  37439. * Detach the current controls from the specified dom element.
  37440. * @param element Defines the element to stop listening the inputs from
  37441. */
  37442. detachControl(element: Nullable<HTMLElement>): void;
  37443. /**
  37444. * Gets the class name of the current intput.
  37445. * @returns the class name
  37446. */
  37447. getClassName(): string;
  37448. /**
  37449. * Get the friendly name associated with the input class.
  37450. * @returns the input friendly name
  37451. */
  37452. getSimpleName(): string;
  37453. }
  37454. }
  37455. declare module "babylonjs/Cameras/Inputs/index" {
  37456. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37457. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37458. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37459. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37460. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37461. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37462. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37463. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37464. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37465. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37466. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37467. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37468. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37469. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37470. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37471. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37472. }
  37473. declare module "babylonjs/Cameras/touchCamera" {
  37474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37475. import { Scene } from "babylonjs/scene";
  37476. import { Vector3 } from "babylonjs/Maths/math";
  37477. /**
  37478. * This represents a FPS type of camera controlled by touch.
  37479. * This is like a universal camera minus the Gamepad controls.
  37480. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37481. */
  37482. export class TouchCamera extends FreeCamera {
  37483. /**
  37484. * Defines the touch sensibility for rotation.
  37485. * The higher the faster.
  37486. */
  37487. touchAngularSensibility: number;
  37488. /**
  37489. * Defines the touch sensibility for move.
  37490. * The higher the faster.
  37491. */
  37492. touchMoveSensibility: number;
  37493. /**
  37494. * Instantiates a new touch camera.
  37495. * This represents a FPS type of camera controlled by touch.
  37496. * This is like a universal camera minus the Gamepad controls.
  37497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37498. * @param name Define the name of the camera in the scene
  37499. * @param position Define the start position of the camera in the scene
  37500. * @param scene Define the scene the camera belongs to
  37501. */
  37502. constructor(name: string, position: Vector3, scene: Scene);
  37503. /**
  37504. * Gets the current object class name.
  37505. * @return the class name
  37506. */
  37507. getClassName(): string;
  37508. /** @hidden */
  37509. _setupInputs(): void;
  37510. }
  37511. }
  37512. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37514. import { Scene } from "babylonjs/scene";
  37515. import { Vector3, Axis } from "babylonjs/Maths/math";
  37516. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37517. /**
  37518. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37519. * being tilted forward or back and left or right.
  37520. */
  37521. export class DeviceOrientationCamera extends FreeCamera {
  37522. private _initialQuaternion;
  37523. private _quaternionCache;
  37524. /**
  37525. * Creates a new device orientation camera
  37526. * @param name The name of the camera
  37527. * @param position The start position camera
  37528. * @param scene The scene the camera belongs to
  37529. */
  37530. constructor(name: string, position: Vector3, scene: Scene);
  37531. /**
  37532. * Gets the current instance class name ("DeviceOrientationCamera").
  37533. * This helps avoiding instanceof at run time.
  37534. * @returns the class name
  37535. */
  37536. getClassName(): string;
  37537. /**
  37538. * @hidden
  37539. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37540. */
  37541. _checkInputs(): void;
  37542. /**
  37543. * Reset the camera to its default orientation on the specified axis only.
  37544. * @param axis The axis to reset
  37545. */
  37546. resetToCurrentRotation(axis?: Axis): void;
  37547. }
  37548. }
  37549. declare module "babylonjs/Cameras/universalCamera" {
  37550. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37551. import { Scene } from "babylonjs/scene";
  37552. import { Vector3 } from "babylonjs/Maths/math";
  37553. /**
  37554. * 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,
  37555. * which still works and will still be found in many Playgrounds.
  37556. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37557. */
  37558. export class UniversalCamera extends TouchCamera {
  37559. /**
  37560. * Defines the gamepad rotation sensiblity.
  37561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37562. */
  37563. gamepadAngularSensibility: number;
  37564. /**
  37565. * Defines the gamepad move sensiblity.
  37566. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37567. */
  37568. gamepadMoveSensibility: number;
  37569. /**
  37570. * 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,
  37571. * which still works and will still be found in many Playgrounds.
  37572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37573. * @param name Define the name of the camera in the scene
  37574. * @param position Define the start position of the camera in the scene
  37575. * @param scene Define the scene the camera belongs to
  37576. */
  37577. constructor(name: string, position: Vector3, scene: Scene);
  37578. /**
  37579. * Gets the current object class name.
  37580. * @return the class name
  37581. */
  37582. getClassName(): string;
  37583. }
  37584. }
  37585. declare module "babylonjs/Cameras/gamepadCamera" {
  37586. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37587. import { Scene } from "babylonjs/scene";
  37588. import { Vector3 } from "babylonjs/Maths/math";
  37589. /**
  37590. * This represents a FPS type of camera. This is only here for back compat purpose.
  37591. * Please use the UniversalCamera instead as both are identical.
  37592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37593. */
  37594. export class GamepadCamera extends UniversalCamera {
  37595. /**
  37596. * Instantiates a new Gamepad Camera
  37597. * This represents a FPS type of camera. This is only here for back compat purpose.
  37598. * Please use the UniversalCamera instead as both are identical.
  37599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37600. * @param name Define the name of the camera in the scene
  37601. * @param position Define the start position of the camera in the scene
  37602. * @param scene Define the scene the camera belongs to
  37603. */
  37604. constructor(name: string, position: Vector3, scene: Scene);
  37605. /**
  37606. * Gets the current object class name.
  37607. * @return the class name
  37608. */
  37609. getClassName(): string;
  37610. }
  37611. }
  37612. declare module "babylonjs/Shaders/pass.fragment" {
  37613. /** @hidden */
  37614. export var passPixelShader: {
  37615. name: string;
  37616. shader: string;
  37617. };
  37618. }
  37619. declare module "babylonjs/Shaders/passCube.fragment" {
  37620. /** @hidden */
  37621. export var passCubePixelShader: {
  37622. name: string;
  37623. shader: string;
  37624. };
  37625. }
  37626. declare module "babylonjs/PostProcesses/passPostProcess" {
  37627. import { Nullable } from "babylonjs/types";
  37628. import { Camera } from "babylonjs/Cameras/camera";
  37629. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37630. import { Engine } from "babylonjs/Engines/engine";
  37631. import "babylonjs/Shaders/pass.fragment";
  37632. import "babylonjs/Shaders/passCube.fragment";
  37633. /**
  37634. * PassPostProcess which produces an output the same as it's input
  37635. */
  37636. export class PassPostProcess extends PostProcess {
  37637. /**
  37638. * Creates the PassPostProcess
  37639. * @param name The name of the effect.
  37640. * @param options The required width/height ratio to downsize to before computing the render pass.
  37641. * @param camera The camera to apply the render pass to.
  37642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37643. * @param engine The engine which the post process will be applied. (default: current engine)
  37644. * @param reusable If the post process can be reused on the same frame. (default: false)
  37645. * @param textureType The type of texture to be used when performing the post processing.
  37646. * @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)
  37647. */
  37648. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37649. }
  37650. /**
  37651. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37652. */
  37653. export class PassCubePostProcess extends PostProcess {
  37654. private _face;
  37655. /**
  37656. * Gets or sets the cube face to display.
  37657. * * 0 is +X
  37658. * * 1 is -X
  37659. * * 2 is +Y
  37660. * * 3 is -Y
  37661. * * 4 is +Z
  37662. * * 5 is -Z
  37663. */
  37664. face: number;
  37665. /**
  37666. * Creates the PassCubePostProcess
  37667. * @param name The name of the effect.
  37668. * @param options The required width/height ratio to downsize to before computing the render pass.
  37669. * @param camera The camera to apply the render pass to.
  37670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37671. * @param engine The engine which the post process will be applied. (default: current engine)
  37672. * @param reusable If the post process can be reused on the same frame. (default: false)
  37673. * @param textureType The type of texture to be used when performing the post processing.
  37674. * @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)
  37675. */
  37676. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37677. }
  37678. }
  37679. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37680. /** @hidden */
  37681. export var anaglyphPixelShader: {
  37682. name: string;
  37683. shader: string;
  37684. };
  37685. }
  37686. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37687. import { Engine } from "babylonjs/Engines/engine";
  37688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37689. import { Camera } from "babylonjs/Cameras/camera";
  37690. import "babylonjs/Shaders/anaglyph.fragment";
  37691. /**
  37692. * Postprocess used to generate anaglyphic rendering
  37693. */
  37694. export class AnaglyphPostProcess extends PostProcess {
  37695. private _passedProcess;
  37696. /**
  37697. * Creates a new AnaglyphPostProcess
  37698. * @param name defines postprocess name
  37699. * @param options defines creation options or target ratio scale
  37700. * @param rigCameras defines cameras using this postprocess
  37701. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37702. * @param engine defines hosting engine
  37703. * @param reusable defines if the postprocess will be reused multiple times per frame
  37704. */
  37705. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37706. }
  37707. }
  37708. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37709. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37710. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37711. import { Scene } from "babylonjs/scene";
  37712. import { Vector3 } from "babylonjs/Maths/math";
  37713. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37714. /**
  37715. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37716. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37717. */
  37718. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37719. /**
  37720. * Creates a new AnaglyphArcRotateCamera
  37721. * @param name defines camera name
  37722. * @param alpha defines alpha angle (in radians)
  37723. * @param beta defines beta angle (in radians)
  37724. * @param radius defines radius
  37725. * @param target defines camera target
  37726. * @param interaxialDistance defines distance between each color axis
  37727. * @param scene defines the hosting scene
  37728. */
  37729. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37730. /**
  37731. * Gets camera class name
  37732. * @returns AnaglyphArcRotateCamera
  37733. */
  37734. getClassName(): string;
  37735. }
  37736. }
  37737. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37738. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37739. import { Scene } from "babylonjs/scene";
  37740. import { Vector3 } from "babylonjs/Maths/math";
  37741. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37742. /**
  37743. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37744. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37745. */
  37746. export class AnaglyphFreeCamera extends FreeCamera {
  37747. /**
  37748. * Creates a new AnaglyphFreeCamera
  37749. * @param name defines camera name
  37750. * @param position defines initial position
  37751. * @param interaxialDistance defines distance between each color axis
  37752. * @param scene defines the hosting scene
  37753. */
  37754. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37755. /**
  37756. * Gets camera class name
  37757. * @returns AnaglyphFreeCamera
  37758. */
  37759. getClassName(): string;
  37760. }
  37761. }
  37762. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37763. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37764. import { Scene } from "babylonjs/scene";
  37765. import { Vector3 } from "babylonjs/Maths/math";
  37766. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37767. /**
  37768. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37769. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37770. */
  37771. export class AnaglyphGamepadCamera extends GamepadCamera {
  37772. /**
  37773. * Creates a new AnaglyphGamepadCamera
  37774. * @param name defines camera name
  37775. * @param position defines initial position
  37776. * @param interaxialDistance defines distance between each color axis
  37777. * @param scene defines the hosting scene
  37778. */
  37779. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37780. /**
  37781. * Gets camera class name
  37782. * @returns AnaglyphGamepadCamera
  37783. */
  37784. getClassName(): string;
  37785. }
  37786. }
  37787. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37788. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37789. import { Scene } from "babylonjs/scene";
  37790. import { Vector3 } from "babylonjs/Maths/math";
  37791. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37792. /**
  37793. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37794. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37795. */
  37796. export class AnaglyphUniversalCamera extends UniversalCamera {
  37797. /**
  37798. * Creates a new AnaglyphUniversalCamera
  37799. * @param name defines camera name
  37800. * @param position defines initial position
  37801. * @param interaxialDistance defines distance between each color axis
  37802. * @param scene defines the hosting scene
  37803. */
  37804. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37805. /**
  37806. * Gets camera class name
  37807. * @returns AnaglyphUniversalCamera
  37808. */
  37809. getClassName(): string;
  37810. }
  37811. }
  37812. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37813. /** @hidden */
  37814. export var stereoscopicInterlacePixelShader: {
  37815. name: string;
  37816. shader: string;
  37817. };
  37818. }
  37819. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37820. import { Camera } from "babylonjs/Cameras/camera";
  37821. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37822. import { Engine } from "babylonjs/Engines/engine";
  37823. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37824. /**
  37825. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37826. */
  37827. export class StereoscopicInterlacePostProcess extends PostProcess {
  37828. private _stepSize;
  37829. private _passedProcess;
  37830. /**
  37831. * Initializes a StereoscopicInterlacePostProcess
  37832. * @param name The name of the effect.
  37833. * @param rigCameras The rig cameras to be appled to the post process
  37834. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37836. * @param engine The engine which the post process will be applied. (default: current engine)
  37837. * @param reusable If the post process can be reused on the same frame. (default: false)
  37838. */
  37839. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37840. }
  37841. }
  37842. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37843. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37844. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37845. import { Scene } from "babylonjs/scene";
  37846. import { Vector3 } from "babylonjs/Maths/math";
  37847. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37848. /**
  37849. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37850. * @see http://doc.babylonjs.com/features/cameras
  37851. */
  37852. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37853. /**
  37854. * Creates a new StereoscopicArcRotateCamera
  37855. * @param name defines camera name
  37856. * @param alpha defines alpha angle (in radians)
  37857. * @param beta defines beta angle (in radians)
  37858. * @param radius defines radius
  37859. * @param target defines camera target
  37860. * @param interaxialDistance defines distance between each color axis
  37861. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37862. * @param scene defines the hosting scene
  37863. */
  37864. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37865. /**
  37866. * Gets camera class name
  37867. * @returns StereoscopicArcRotateCamera
  37868. */
  37869. getClassName(): string;
  37870. }
  37871. }
  37872. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37873. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37874. import { Scene } from "babylonjs/scene";
  37875. import { Vector3 } from "babylonjs/Maths/math";
  37876. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37877. /**
  37878. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37879. * @see http://doc.babylonjs.com/features/cameras
  37880. */
  37881. export class StereoscopicFreeCamera extends FreeCamera {
  37882. /**
  37883. * Creates a new StereoscopicFreeCamera
  37884. * @param name defines camera name
  37885. * @param position defines initial position
  37886. * @param interaxialDistance defines distance between each color axis
  37887. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37888. * @param scene defines the hosting scene
  37889. */
  37890. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37891. /**
  37892. * Gets camera class name
  37893. * @returns StereoscopicFreeCamera
  37894. */
  37895. getClassName(): string;
  37896. }
  37897. }
  37898. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37899. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37900. import { Scene } from "babylonjs/scene";
  37901. import { Vector3 } from "babylonjs/Maths/math";
  37902. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37903. /**
  37904. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37905. * @see http://doc.babylonjs.com/features/cameras
  37906. */
  37907. export class StereoscopicGamepadCamera extends GamepadCamera {
  37908. /**
  37909. * Creates a new StereoscopicGamepadCamera
  37910. * @param name defines camera name
  37911. * @param position defines initial position
  37912. * @param interaxialDistance defines distance between each color axis
  37913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37914. * @param scene defines the hosting scene
  37915. */
  37916. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37917. /**
  37918. * Gets camera class name
  37919. * @returns StereoscopicGamepadCamera
  37920. */
  37921. getClassName(): string;
  37922. }
  37923. }
  37924. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37925. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37926. import { Scene } from "babylonjs/scene";
  37927. import { Vector3 } from "babylonjs/Maths/math";
  37928. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37929. /**
  37930. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37931. * @see http://doc.babylonjs.com/features/cameras
  37932. */
  37933. export class StereoscopicUniversalCamera extends UniversalCamera {
  37934. /**
  37935. * Creates a new StereoscopicUniversalCamera
  37936. * @param name defines camera name
  37937. * @param position defines initial position
  37938. * @param interaxialDistance defines distance between each color axis
  37939. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37940. * @param scene defines the hosting scene
  37941. */
  37942. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37943. /**
  37944. * Gets camera class name
  37945. * @returns StereoscopicUniversalCamera
  37946. */
  37947. getClassName(): string;
  37948. }
  37949. }
  37950. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37951. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37952. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37953. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37954. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37955. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37956. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37957. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37958. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37959. }
  37960. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37961. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37962. import { Scene } from "babylonjs/scene";
  37963. import { Vector3 } from "babylonjs/Maths/math";
  37964. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37965. /**
  37966. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37967. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37968. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37969. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37970. */
  37971. export class VirtualJoysticksCamera extends FreeCamera {
  37972. /**
  37973. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37974. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37975. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37976. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37977. * @param name Define the name of the camera in the scene
  37978. * @param position Define the start position of the camera in the scene
  37979. * @param scene Define the scene the camera belongs to
  37980. */
  37981. constructor(name: string, position: Vector3, scene: Scene);
  37982. /**
  37983. * Gets the current object class name.
  37984. * @return the class name
  37985. */
  37986. getClassName(): string;
  37987. }
  37988. }
  37989. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37990. import { Matrix } from "babylonjs/Maths/math";
  37991. /**
  37992. * This represents all the required metrics to create a VR camera.
  37993. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37994. */
  37995. export class VRCameraMetrics {
  37996. /**
  37997. * Define the horizontal resolution off the screen.
  37998. */
  37999. hResolution: number;
  38000. /**
  38001. * Define the vertical resolution off the screen.
  38002. */
  38003. vResolution: number;
  38004. /**
  38005. * Define the horizontal screen size.
  38006. */
  38007. hScreenSize: number;
  38008. /**
  38009. * Define the vertical screen size.
  38010. */
  38011. vScreenSize: number;
  38012. /**
  38013. * Define the vertical screen center position.
  38014. */
  38015. vScreenCenter: number;
  38016. /**
  38017. * Define the distance of the eyes to the screen.
  38018. */
  38019. eyeToScreenDistance: number;
  38020. /**
  38021. * Define the distance between both lenses
  38022. */
  38023. lensSeparationDistance: number;
  38024. /**
  38025. * Define the distance between both viewer's eyes.
  38026. */
  38027. interpupillaryDistance: number;
  38028. /**
  38029. * Define the distortion factor of the VR postprocess.
  38030. * Please, touch with care.
  38031. */
  38032. distortionK: number[];
  38033. /**
  38034. * Define the chromatic aberration correction factors for the VR post process.
  38035. */
  38036. chromaAbCorrection: number[];
  38037. /**
  38038. * Define the scale factor of the post process.
  38039. * The smaller the better but the slower.
  38040. */
  38041. postProcessScaleFactor: number;
  38042. /**
  38043. * Define an offset for the lens center.
  38044. */
  38045. lensCenterOffset: number;
  38046. /**
  38047. * Define if the current vr camera should compensate the distortion of the lense or not.
  38048. */
  38049. compensateDistortion: boolean;
  38050. /**
  38051. * Gets the rendering aspect ratio based on the provided resolutions.
  38052. */
  38053. readonly aspectRatio: number;
  38054. /**
  38055. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38056. */
  38057. readonly aspectRatioFov: number;
  38058. /**
  38059. * @hidden
  38060. */
  38061. readonly leftHMatrix: Matrix;
  38062. /**
  38063. * @hidden
  38064. */
  38065. readonly rightHMatrix: Matrix;
  38066. /**
  38067. * @hidden
  38068. */
  38069. readonly leftPreViewMatrix: Matrix;
  38070. /**
  38071. * @hidden
  38072. */
  38073. readonly rightPreViewMatrix: Matrix;
  38074. /**
  38075. * Get the default VRMetrics based on the most generic setup.
  38076. * @returns the default vr metrics
  38077. */
  38078. static GetDefault(): VRCameraMetrics;
  38079. }
  38080. }
  38081. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38082. /** @hidden */
  38083. export var vrDistortionCorrectionPixelShader: {
  38084. name: string;
  38085. shader: string;
  38086. };
  38087. }
  38088. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38089. import { Camera } from "babylonjs/Cameras/camera";
  38090. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38091. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38092. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38093. /**
  38094. * VRDistortionCorrectionPostProcess used for mobile VR
  38095. */
  38096. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38097. private _isRightEye;
  38098. private _distortionFactors;
  38099. private _postProcessScaleFactor;
  38100. private _lensCenterOffset;
  38101. private _scaleIn;
  38102. private _scaleFactor;
  38103. private _lensCenter;
  38104. /**
  38105. * Initializes the VRDistortionCorrectionPostProcess
  38106. * @param name The name of the effect.
  38107. * @param camera The camera to apply the render pass to.
  38108. * @param isRightEye If this is for the right eye distortion
  38109. * @param vrMetrics All the required metrics for the VR camera
  38110. */
  38111. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38112. }
  38113. }
  38114. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38115. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38116. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38117. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38118. import { Scene } from "babylonjs/scene";
  38119. import { Vector3 } from "babylonjs/Maths/math";
  38120. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38121. import "babylonjs/Cameras/RigModes/vrRigMode";
  38122. /**
  38123. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38124. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38125. */
  38126. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38127. /**
  38128. * Creates a new VRDeviceOrientationArcRotateCamera
  38129. * @param name defines camera name
  38130. * @param alpha defines the camera rotation along the logitudinal axis
  38131. * @param beta defines the camera rotation along the latitudinal axis
  38132. * @param radius defines the camera distance from its target
  38133. * @param target defines the camera target
  38134. * @param scene defines the scene the camera belongs to
  38135. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38136. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38137. */
  38138. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38139. /**
  38140. * Gets camera class name
  38141. * @returns VRDeviceOrientationArcRotateCamera
  38142. */
  38143. getClassName(): string;
  38144. }
  38145. }
  38146. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38147. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38148. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38149. import { Scene } from "babylonjs/scene";
  38150. import { Vector3 } from "babylonjs/Maths/math";
  38151. import "babylonjs/Cameras/RigModes/vrRigMode";
  38152. /**
  38153. * Camera used to simulate VR rendering (based on FreeCamera)
  38154. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38155. */
  38156. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38157. /**
  38158. * Creates a new VRDeviceOrientationFreeCamera
  38159. * @param name defines camera name
  38160. * @param position defines the start position of the camera
  38161. * @param scene defines the scene the camera belongs to
  38162. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38163. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38164. */
  38165. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38166. /**
  38167. * Gets camera class name
  38168. * @returns VRDeviceOrientationFreeCamera
  38169. */
  38170. getClassName(): string;
  38171. }
  38172. }
  38173. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38174. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38175. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38176. import { Scene } from "babylonjs/scene";
  38177. import { Vector3 } from "babylonjs/Maths/math";
  38178. /**
  38179. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38180. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38181. */
  38182. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38183. /**
  38184. * Creates a new VRDeviceOrientationGamepadCamera
  38185. * @param name defines camera name
  38186. * @param position defines the start position of the camera
  38187. * @param scene defines the scene the camera belongs to
  38188. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38189. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38190. */
  38191. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38192. /**
  38193. * Gets camera class name
  38194. * @returns VRDeviceOrientationGamepadCamera
  38195. */
  38196. getClassName(): string;
  38197. }
  38198. }
  38199. declare module "babylonjs/Gamepads/xboxGamepad" {
  38200. import { Observable } from "babylonjs/Misc/observable";
  38201. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38202. /**
  38203. * Defines supported buttons for XBox360 compatible gamepads
  38204. */
  38205. export enum Xbox360Button {
  38206. /** A */
  38207. A = 0,
  38208. /** B */
  38209. B = 1,
  38210. /** X */
  38211. X = 2,
  38212. /** Y */
  38213. Y = 3,
  38214. /** Start */
  38215. Start = 4,
  38216. /** Back */
  38217. Back = 5,
  38218. /** Left button */
  38219. LB = 6,
  38220. /** Right button */
  38221. RB = 7,
  38222. /** Left stick */
  38223. LeftStick = 8,
  38224. /** Right stick */
  38225. RightStick = 9
  38226. }
  38227. /** Defines values for XBox360 DPad */
  38228. export enum Xbox360Dpad {
  38229. /** Up */
  38230. Up = 0,
  38231. /** Down */
  38232. Down = 1,
  38233. /** Left */
  38234. Left = 2,
  38235. /** Right */
  38236. Right = 3
  38237. }
  38238. /**
  38239. * Defines a XBox360 gamepad
  38240. */
  38241. export class Xbox360Pad extends Gamepad {
  38242. private _leftTrigger;
  38243. private _rightTrigger;
  38244. private _onlefttriggerchanged;
  38245. private _onrighttriggerchanged;
  38246. private _onbuttondown;
  38247. private _onbuttonup;
  38248. private _ondpaddown;
  38249. private _ondpadup;
  38250. /** Observable raised when a button is pressed */
  38251. onButtonDownObservable: Observable<Xbox360Button>;
  38252. /** Observable raised when a button is released */
  38253. onButtonUpObservable: Observable<Xbox360Button>;
  38254. /** Observable raised when a pad is pressed */
  38255. onPadDownObservable: Observable<Xbox360Dpad>;
  38256. /** Observable raised when a pad is released */
  38257. onPadUpObservable: Observable<Xbox360Dpad>;
  38258. private _buttonA;
  38259. private _buttonB;
  38260. private _buttonX;
  38261. private _buttonY;
  38262. private _buttonBack;
  38263. private _buttonStart;
  38264. private _buttonLB;
  38265. private _buttonRB;
  38266. private _buttonLeftStick;
  38267. private _buttonRightStick;
  38268. private _dPadUp;
  38269. private _dPadDown;
  38270. private _dPadLeft;
  38271. private _dPadRight;
  38272. private _isXboxOnePad;
  38273. /**
  38274. * Creates a new XBox360 gamepad object
  38275. * @param id defines the id of this gamepad
  38276. * @param index defines its index
  38277. * @param gamepad defines the internal HTML gamepad object
  38278. * @param xboxOne defines if it is a XBox One gamepad
  38279. */
  38280. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38281. /**
  38282. * Defines the callback to call when left trigger is pressed
  38283. * @param callback defines the callback to use
  38284. */
  38285. onlefttriggerchanged(callback: (value: number) => void): void;
  38286. /**
  38287. * Defines the callback to call when right trigger is pressed
  38288. * @param callback defines the callback to use
  38289. */
  38290. onrighttriggerchanged(callback: (value: number) => void): void;
  38291. /**
  38292. * Gets the left trigger value
  38293. */
  38294. /**
  38295. * Sets the left trigger value
  38296. */
  38297. leftTrigger: number;
  38298. /**
  38299. * Gets the right trigger value
  38300. */
  38301. /**
  38302. * Sets the right trigger value
  38303. */
  38304. rightTrigger: number;
  38305. /**
  38306. * Defines the callback to call when a button is pressed
  38307. * @param callback defines the callback to use
  38308. */
  38309. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38310. /**
  38311. * Defines the callback to call when a button is released
  38312. * @param callback defines the callback to use
  38313. */
  38314. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38315. /**
  38316. * Defines the callback to call when a pad is pressed
  38317. * @param callback defines the callback to use
  38318. */
  38319. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38320. /**
  38321. * Defines the callback to call when a pad is released
  38322. * @param callback defines the callback to use
  38323. */
  38324. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38325. private _setButtonValue;
  38326. private _setDPadValue;
  38327. /**
  38328. * Gets the value of the `A` button
  38329. */
  38330. /**
  38331. * Sets the value of the `A` button
  38332. */
  38333. buttonA: number;
  38334. /**
  38335. * Gets the value of the `B` button
  38336. */
  38337. /**
  38338. * Sets the value of the `B` button
  38339. */
  38340. buttonB: number;
  38341. /**
  38342. * Gets the value of the `X` button
  38343. */
  38344. /**
  38345. * Sets the value of the `X` button
  38346. */
  38347. buttonX: number;
  38348. /**
  38349. * Gets the value of the `Y` button
  38350. */
  38351. /**
  38352. * Sets the value of the `Y` button
  38353. */
  38354. buttonY: number;
  38355. /**
  38356. * Gets the value of the `Start` button
  38357. */
  38358. /**
  38359. * Sets the value of the `Start` button
  38360. */
  38361. buttonStart: number;
  38362. /**
  38363. * Gets the value of the `Back` button
  38364. */
  38365. /**
  38366. * Sets the value of the `Back` button
  38367. */
  38368. buttonBack: number;
  38369. /**
  38370. * Gets the value of the `Left` button
  38371. */
  38372. /**
  38373. * Sets the value of the `Left` button
  38374. */
  38375. buttonLB: number;
  38376. /**
  38377. * Gets the value of the `Right` button
  38378. */
  38379. /**
  38380. * Sets the value of the `Right` button
  38381. */
  38382. buttonRB: number;
  38383. /**
  38384. * Gets the value of the Left joystick
  38385. */
  38386. /**
  38387. * Sets the value of the Left joystick
  38388. */
  38389. buttonLeftStick: number;
  38390. /**
  38391. * Gets the value of the Right joystick
  38392. */
  38393. /**
  38394. * Sets the value of the Right joystick
  38395. */
  38396. buttonRightStick: number;
  38397. /**
  38398. * Gets the value of D-pad up
  38399. */
  38400. /**
  38401. * Sets the value of D-pad up
  38402. */
  38403. dPadUp: number;
  38404. /**
  38405. * Gets the value of D-pad down
  38406. */
  38407. /**
  38408. * Sets the value of D-pad down
  38409. */
  38410. dPadDown: number;
  38411. /**
  38412. * Gets the value of D-pad left
  38413. */
  38414. /**
  38415. * Sets the value of D-pad left
  38416. */
  38417. dPadLeft: number;
  38418. /**
  38419. * Gets the value of D-pad right
  38420. */
  38421. /**
  38422. * Sets the value of D-pad right
  38423. */
  38424. dPadRight: number;
  38425. /**
  38426. * Force the gamepad to synchronize with device values
  38427. */
  38428. update(): void;
  38429. /**
  38430. * Disposes the gamepad
  38431. */
  38432. dispose(): void;
  38433. }
  38434. }
  38435. declare module "babylonjs/Materials/pushMaterial" {
  38436. import { Nullable } from "babylonjs/types";
  38437. import { Scene } from "babylonjs/scene";
  38438. import { Matrix } from "babylonjs/Maths/math";
  38439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38440. import { Mesh } from "babylonjs/Meshes/mesh";
  38441. import { Material } from "babylonjs/Materials/material";
  38442. import { Effect } from "babylonjs/Materials/effect";
  38443. /**
  38444. * Base class of materials working in push mode in babylon JS
  38445. * @hidden
  38446. */
  38447. export class PushMaterial extends Material {
  38448. protected _activeEffect: Effect;
  38449. protected _normalMatrix: Matrix;
  38450. /**
  38451. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38452. * This means that the material can keep using a previous shader while a new one is being compiled.
  38453. * This is mostly used when shader parallel compilation is supported (true by default)
  38454. */
  38455. allowShaderHotSwapping: boolean;
  38456. constructor(name: string, scene: Scene);
  38457. getEffect(): Effect;
  38458. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38459. /**
  38460. * Binds the given world matrix to the active effect
  38461. *
  38462. * @param world the matrix to bind
  38463. */
  38464. bindOnlyWorldMatrix(world: Matrix): void;
  38465. /**
  38466. * Binds the given normal matrix to the active effect
  38467. *
  38468. * @param normalMatrix the matrix to bind
  38469. */
  38470. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38471. bind(world: Matrix, mesh?: Mesh): void;
  38472. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38473. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38474. }
  38475. }
  38476. declare module "babylonjs/Materials/materialFlags" {
  38477. /**
  38478. * This groups all the flags used to control the materials channel.
  38479. */
  38480. export class MaterialFlags {
  38481. private static _DiffuseTextureEnabled;
  38482. /**
  38483. * Are diffuse textures enabled in the application.
  38484. */
  38485. static DiffuseTextureEnabled: boolean;
  38486. private static _AmbientTextureEnabled;
  38487. /**
  38488. * Are ambient textures enabled in the application.
  38489. */
  38490. static AmbientTextureEnabled: boolean;
  38491. private static _OpacityTextureEnabled;
  38492. /**
  38493. * Are opacity textures enabled in the application.
  38494. */
  38495. static OpacityTextureEnabled: boolean;
  38496. private static _ReflectionTextureEnabled;
  38497. /**
  38498. * Are reflection textures enabled in the application.
  38499. */
  38500. static ReflectionTextureEnabled: boolean;
  38501. private static _EmissiveTextureEnabled;
  38502. /**
  38503. * Are emissive textures enabled in the application.
  38504. */
  38505. static EmissiveTextureEnabled: boolean;
  38506. private static _SpecularTextureEnabled;
  38507. /**
  38508. * Are specular textures enabled in the application.
  38509. */
  38510. static SpecularTextureEnabled: boolean;
  38511. private static _BumpTextureEnabled;
  38512. /**
  38513. * Are bump textures enabled in the application.
  38514. */
  38515. static BumpTextureEnabled: boolean;
  38516. private static _LightmapTextureEnabled;
  38517. /**
  38518. * Are lightmap textures enabled in the application.
  38519. */
  38520. static LightmapTextureEnabled: boolean;
  38521. private static _RefractionTextureEnabled;
  38522. /**
  38523. * Are refraction textures enabled in the application.
  38524. */
  38525. static RefractionTextureEnabled: boolean;
  38526. private static _ColorGradingTextureEnabled;
  38527. /**
  38528. * Are color grading textures enabled in the application.
  38529. */
  38530. static ColorGradingTextureEnabled: boolean;
  38531. private static _FresnelEnabled;
  38532. /**
  38533. * Are fresnels enabled in the application.
  38534. */
  38535. static FresnelEnabled: boolean;
  38536. private static _ClearCoatTextureEnabled;
  38537. /**
  38538. * Are clear coat textures enabled in the application.
  38539. */
  38540. static ClearCoatTextureEnabled: boolean;
  38541. private static _ClearCoatBumpTextureEnabled;
  38542. /**
  38543. * Are clear coat bump textures enabled in the application.
  38544. */
  38545. static ClearCoatBumpTextureEnabled: boolean;
  38546. private static _ClearCoatTintTextureEnabled;
  38547. /**
  38548. * Are clear coat tint textures enabled in the application.
  38549. */
  38550. static ClearCoatTintTextureEnabled: boolean;
  38551. }
  38552. }
  38553. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38554. /** @hidden */
  38555. export var defaultFragmentDeclaration: {
  38556. name: string;
  38557. shader: string;
  38558. };
  38559. }
  38560. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38561. /** @hidden */
  38562. export var defaultUboDeclaration: {
  38563. name: string;
  38564. shader: string;
  38565. };
  38566. }
  38567. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38568. /** @hidden */
  38569. export var lightFragmentDeclaration: {
  38570. name: string;
  38571. shader: string;
  38572. };
  38573. }
  38574. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38575. /** @hidden */
  38576. export var lightUboDeclaration: {
  38577. name: string;
  38578. shader: string;
  38579. };
  38580. }
  38581. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38582. /** @hidden */
  38583. export var lightsFragmentFunctions: {
  38584. name: string;
  38585. shader: string;
  38586. };
  38587. }
  38588. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38589. /** @hidden */
  38590. export var shadowsFragmentFunctions: {
  38591. name: string;
  38592. shader: string;
  38593. };
  38594. }
  38595. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38596. /** @hidden */
  38597. export var fresnelFunction: {
  38598. name: string;
  38599. shader: string;
  38600. };
  38601. }
  38602. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38603. /** @hidden */
  38604. export var reflectionFunction: {
  38605. name: string;
  38606. shader: string;
  38607. };
  38608. }
  38609. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38610. /** @hidden */
  38611. export var bumpFragmentFunctions: {
  38612. name: string;
  38613. shader: string;
  38614. };
  38615. }
  38616. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38617. /** @hidden */
  38618. export var logDepthDeclaration: {
  38619. name: string;
  38620. shader: string;
  38621. };
  38622. }
  38623. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38624. /** @hidden */
  38625. export var bumpFragment: {
  38626. name: string;
  38627. shader: string;
  38628. };
  38629. }
  38630. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38631. /** @hidden */
  38632. export var depthPrePass: {
  38633. name: string;
  38634. shader: string;
  38635. };
  38636. }
  38637. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38638. /** @hidden */
  38639. export var lightFragment: {
  38640. name: string;
  38641. shader: string;
  38642. };
  38643. }
  38644. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38645. /** @hidden */
  38646. export var logDepthFragment: {
  38647. name: string;
  38648. shader: string;
  38649. };
  38650. }
  38651. declare module "babylonjs/Shaders/default.fragment" {
  38652. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38653. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38654. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38655. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38656. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38657. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38658. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38659. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38660. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38661. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38662. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38663. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38664. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38665. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38666. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38667. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38668. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38669. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38670. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38671. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38672. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38673. /** @hidden */
  38674. export var defaultPixelShader: {
  38675. name: string;
  38676. shader: string;
  38677. };
  38678. }
  38679. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38680. /** @hidden */
  38681. export var defaultVertexDeclaration: {
  38682. name: string;
  38683. shader: string;
  38684. };
  38685. }
  38686. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38687. /** @hidden */
  38688. export var bumpVertexDeclaration: {
  38689. name: string;
  38690. shader: string;
  38691. };
  38692. }
  38693. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38694. /** @hidden */
  38695. export var bumpVertex: {
  38696. name: string;
  38697. shader: string;
  38698. };
  38699. }
  38700. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38701. /** @hidden */
  38702. export var fogVertex: {
  38703. name: string;
  38704. shader: string;
  38705. };
  38706. }
  38707. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38708. /** @hidden */
  38709. export var shadowsVertex: {
  38710. name: string;
  38711. shader: string;
  38712. };
  38713. }
  38714. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38715. /** @hidden */
  38716. export var pointCloudVertex: {
  38717. name: string;
  38718. shader: string;
  38719. };
  38720. }
  38721. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38722. /** @hidden */
  38723. export var logDepthVertex: {
  38724. name: string;
  38725. shader: string;
  38726. };
  38727. }
  38728. declare module "babylonjs/Shaders/default.vertex" {
  38729. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38730. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38731. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38734. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38735. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38736. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38737. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38738. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38741. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38743. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38744. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38745. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38746. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38747. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38748. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38749. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38750. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38751. /** @hidden */
  38752. export var defaultVertexShader: {
  38753. name: string;
  38754. shader: string;
  38755. };
  38756. }
  38757. declare module "babylonjs/Materials/standardMaterial" {
  38758. import { SmartArray } from "babylonjs/Misc/smartArray";
  38759. import { IAnimatable } from "babylonjs/Misc/tools";
  38760. import { Nullable } from "babylonjs/types";
  38761. import { Scene } from "babylonjs/scene";
  38762. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38763. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38765. import { Mesh } from "babylonjs/Meshes/mesh";
  38766. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38767. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38768. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38769. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38770. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38773. import "babylonjs/Shaders/default.fragment";
  38774. import "babylonjs/Shaders/default.vertex";
  38775. /** @hidden */
  38776. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38777. MAINUV1: boolean;
  38778. MAINUV2: boolean;
  38779. DIFFUSE: boolean;
  38780. DIFFUSEDIRECTUV: number;
  38781. AMBIENT: boolean;
  38782. AMBIENTDIRECTUV: number;
  38783. OPACITY: boolean;
  38784. OPACITYDIRECTUV: number;
  38785. OPACITYRGB: boolean;
  38786. REFLECTION: boolean;
  38787. EMISSIVE: boolean;
  38788. EMISSIVEDIRECTUV: number;
  38789. SPECULAR: boolean;
  38790. SPECULARDIRECTUV: number;
  38791. BUMP: boolean;
  38792. BUMPDIRECTUV: number;
  38793. PARALLAX: boolean;
  38794. PARALLAXOCCLUSION: boolean;
  38795. SPECULAROVERALPHA: boolean;
  38796. CLIPPLANE: boolean;
  38797. CLIPPLANE2: boolean;
  38798. CLIPPLANE3: boolean;
  38799. CLIPPLANE4: boolean;
  38800. ALPHATEST: boolean;
  38801. DEPTHPREPASS: boolean;
  38802. ALPHAFROMDIFFUSE: boolean;
  38803. POINTSIZE: boolean;
  38804. FOG: boolean;
  38805. SPECULARTERM: boolean;
  38806. DIFFUSEFRESNEL: boolean;
  38807. OPACITYFRESNEL: boolean;
  38808. REFLECTIONFRESNEL: boolean;
  38809. REFRACTIONFRESNEL: boolean;
  38810. EMISSIVEFRESNEL: boolean;
  38811. FRESNEL: boolean;
  38812. NORMAL: boolean;
  38813. UV1: boolean;
  38814. UV2: boolean;
  38815. VERTEXCOLOR: boolean;
  38816. VERTEXALPHA: boolean;
  38817. NUM_BONE_INFLUENCERS: number;
  38818. BonesPerMesh: number;
  38819. BONETEXTURE: boolean;
  38820. INSTANCES: boolean;
  38821. GLOSSINESS: boolean;
  38822. ROUGHNESS: boolean;
  38823. EMISSIVEASILLUMINATION: boolean;
  38824. LINKEMISSIVEWITHDIFFUSE: boolean;
  38825. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38826. LIGHTMAP: boolean;
  38827. LIGHTMAPDIRECTUV: number;
  38828. OBJECTSPACE_NORMALMAP: boolean;
  38829. USELIGHTMAPASSHADOWMAP: boolean;
  38830. REFLECTIONMAP_3D: boolean;
  38831. REFLECTIONMAP_SPHERICAL: boolean;
  38832. REFLECTIONMAP_PLANAR: boolean;
  38833. REFLECTIONMAP_CUBIC: boolean;
  38834. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38835. REFLECTIONMAP_PROJECTION: boolean;
  38836. REFLECTIONMAP_SKYBOX: boolean;
  38837. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38838. REFLECTIONMAP_EXPLICIT: boolean;
  38839. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38840. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38841. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38842. INVERTCUBICMAP: boolean;
  38843. LOGARITHMICDEPTH: boolean;
  38844. REFRACTION: boolean;
  38845. REFRACTIONMAP_3D: boolean;
  38846. REFLECTIONOVERALPHA: boolean;
  38847. TWOSIDEDLIGHTING: boolean;
  38848. SHADOWFLOAT: boolean;
  38849. MORPHTARGETS: boolean;
  38850. MORPHTARGETS_NORMAL: boolean;
  38851. MORPHTARGETS_TANGENT: boolean;
  38852. NUM_MORPH_INFLUENCERS: number;
  38853. NONUNIFORMSCALING: boolean;
  38854. PREMULTIPLYALPHA: boolean;
  38855. IMAGEPROCESSING: boolean;
  38856. VIGNETTE: boolean;
  38857. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38858. VIGNETTEBLENDMODEOPAQUE: boolean;
  38859. TONEMAPPING: boolean;
  38860. TONEMAPPING_ACES: boolean;
  38861. CONTRAST: boolean;
  38862. COLORCURVES: boolean;
  38863. COLORGRADING: boolean;
  38864. COLORGRADING3D: boolean;
  38865. SAMPLER3DGREENDEPTH: boolean;
  38866. SAMPLER3DBGRMAP: boolean;
  38867. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38868. /**
  38869. * If the reflection texture on this material is in linear color space
  38870. * @hidden
  38871. */
  38872. IS_REFLECTION_LINEAR: boolean;
  38873. /**
  38874. * If the refraction texture on this material is in linear color space
  38875. * @hidden
  38876. */
  38877. IS_REFRACTION_LINEAR: boolean;
  38878. EXPOSURE: boolean;
  38879. constructor();
  38880. setReflectionMode(modeToEnable: string): void;
  38881. }
  38882. /**
  38883. * This is the default material used in Babylon. It is the best trade off between quality
  38884. * and performances.
  38885. * @see http://doc.babylonjs.com/babylon101/materials
  38886. */
  38887. export class StandardMaterial extends PushMaterial {
  38888. private _diffuseTexture;
  38889. /**
  38890. * The basic texture of the material as viewed under a light.
  38891. */
  38892. diffuseTexture: Nullable<BaseTexture>;
  38893. private _ambientTexture;
  38894. /**
  38895. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38896. */
  38897. ambientTexture: Nullable<BaseTexture>;
  38898. private _opacityTexture;
  38899. /**
  38900. * Define the transparency of the material from a texture.
  38901. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38902. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38903. */
  38904. opacityTexture: Nullable<BaseTexture>;
  38905. private _reflectionTexture;
  38906. /**
  38907. * Define the texture used to display the reflection.
  38908. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38909. */
  38910. reflectionTexture: Nullable<BaseTexture>;
  38911. private _emissiveTexture;
  38912. /**
  38913. * Define texture of the material as if self lit.
  38914. * This will be mixed in the final result even in the absence of light.
  38915. */
  38916. emissiveTexture: Nullable<BaseTexture>;
  38917. private _specularTexture;
  38918. /**
  38919. * Define how the color and intensity of the highlight given by the light in the material.
  38920. */
  38921. specularTexture: Nullable<BaseTexture>;
  38922. private _bumpTexture;
  38923. /**
  38924. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38925. * 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.
  38926. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38927. */
  38928. bumpTexture: Nullable<BaseTexture>;
  38929. private _lightmapTexture;
  38930. /**
  38931. * Complex lighting can be computationally expensive to compute at runtime.
  38932. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38933. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38934. */
  38935. lightmapTexture: Nullable<BaseTexture>;
  38936. private _refractionTexture;
  38937. /**
  38938. * Define the texture used to display the refraction.
  38939. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38940. */
  38941. refractionTexture: Nullable<BaseTexture>;
  38942. /**
  38943. * The color of the material lit by the environmental background lighting.
  38944. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38945. */
  38946. ambientColor: Color3;
  38947. /**
  38948. * The basic color of the material as viewed under a light.
  38949. */
  38950. diffuseColor: Color3;
  38951. /**
  38952. * Define how the color and intensity of the highlight given by the light in the material.
  38953. */
  38954. specularColor: Color3;
  38955. /**
  38956. * Define the color of the material as if self lit.
  38957. * This will be mixed in the final result even in the absence of light.
  38958. */
  38959. emissiveColor: Color3;
  38960. /**
  38961. * Defines how sharp are the highlights in the material.
  38962. * The bigger the value the sharper giving a more glossy feeling to the result.
  38963. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38964. */
  38965. specularPower: number;
  38966. private _useAlphaFromDiffuseTexture;
  38967. /**
  38968. * Does the transparency come from the diffuse texture alpha channel.
  38969. */
  38970. useAlphaFromDiffuseTexture: boolean;
  38971. private _useEmissiveAsIllumination;
  38972. /**
  38973. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38974. */
  38975. useEmissiveAsIllumination: boolean;
  38976. private _linkEmissiveWithDiffuse;
  38977. /**
  38978. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38979. * the emissive level when the final color is close to one.
  38980. */
  38981. linkEmissiveWithDiffuse: boolean;
  38982. private _useSpecularOverAlpha;
  38983. /**
  38984. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38985. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38986. */
  38987. useSpecularOverAlpha: boolean;
  38988. private _useReflectionOverAlpha;
  38989. /**
  38990. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38991. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38992. */
  38993. useReflectionOverAlpha: boolean;
  38994. private _disableLighting;
  38995. /**
  38996. * Does lights from the scene impacts this material.
  38997. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38998. */
  38999. disableLighting: boolean;
  39000. private _useObjectSpaceNormalMap;
  39001. /**
  39002. * Allows using an object space normal map (instead of tangent space).
  39003. */
  39004. useObjectSpaceNormalMap: boolean;
  39005. private _useParallax;
  39006. /**
  39007. * Is parallax enabled or not.
  39008. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39009. */
  39010. useParallax: boolean;
  39011. private _useParallaxOcclusion;
  39012. /**
  39013. * Is parallax occlusion enabled or not.
  39014. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39015. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39016. */
  39017. useParallaxOcclusion: boolean;
  39018. /**
  39019. * 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.
  39020. */
  39021. parallaxScaleBias: number;
  39022. private _roughness;
  39023. /**
  39024. * Helps to define how blurry the reflections should appears in the material.
  39025. */
  39026. roughness: number;
  39027. /**
  39028. * In case of refraction, define the value of the indice of refraction.
  39029. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39030. */
  39031. indexOfRefraction: number;
  39032. /**
  39033. * Invert the refraction texture alongside the y axis.
  39034. * It can be useful with procedural textures or probe for instance.
  39035. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39036. */
  39037. invertRefractionY: boolean;
  39038. /**
  39039. * Defines the alpha limits in alpha test mode.
  39040. */
  39041. alphaCutOff: number;
  39042. private _useLightmapAsShadowmap;
  39043. /**
  39044. * In case of light mapping, define whether the map contains light or shadow informations.
  39045. */
  39046. useLightmapAsShadowmap: boolean;
  39047. private _diffuseFresnelParameters;
  39048. /**
  39049. * Define the diffuse fresnel parameters of the material.
  39050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39051. */
  39052. diffuseFresnelParameters: FresnelParameters;
  39053. private _opacityFresnelParameters;
  39054. /**
  39055. * Define the opacity fresnel parameters of the material.
  39056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39057. */
  39058. opacityFresnelParameters: FresnelParameters;
  39059. private _reflectionFresnelParameters;
  39060. /**
  39061. * Define the reflection fresnel parameters of the material.
  39062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39063. */
  39064. reflectionFresnelParameters: FresnelParameters;
  39065. private _refractionFresnelParameters;
  39066. /**
  39067. * Define the refraction fresnel parameters of the material.
  39068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39069. */
  39070. refractionFresnelParameters: FresnelParameters;
  39071. private _emissiveFresnelParameters;
  39072. /**
  39073. * Define the emissive fresnel parameters of the material.
  39074. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39075. */
  39076. emissiveFresnelParameters: FresnelParameters;
  39077. private _useReflectionFresnelFromSpecular;
  39078. /**
  39079. * If true automatically deducts the fresnels values from the material specularity.
  39080. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39081. */
  39082. useReflectionFresnelFromSpecular: boolean;
  39083. private _useGlossinessFromSpecularMapAlpha;
  39084. /**
  39085. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39086. */
  39087. useGlossinessFromSpecularMapAlpha: boolean;
  39088. private _maxSimultaneousLights;
  39089. /**
  39090. * Defines the maximum number of lights that can be used in the material
  39091. */
  39092. maxSimultaneousLights: number;
  39093. private _invertNormalMapX;
  39094. /**
  39095. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39096. */
  39097. invertNormalMapX: boolean;
  39098. private _invertNormalMapY;
  39099. /**
  39100. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39101. */
  39102. invertNormalMapY: boolean;
  39103. private _twoSidedLighting;
  39104. /**
  39105. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39106. */
  39107. twoSidedLighting: boolean;
  39108. /**
  39109. * Default configuration related to image processing available in the standard Material.
  39110. */
  39111. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39112. /**
  39113. * Gets the image processing configuration used either in this material.
  39114. */
  39115. /**
  39116. * Sets the Default image processing configuration used either in the this material.
  39117. *
  39118. * If sets to null, the scene one is in use.
  39119. */
  39120. imageProcessingConfiguration: ImageProcessingConfiguration;
  39121. /**
  39122. * Keep track of the image processing observer to allow dispose and replace.
  39123. */
  39124. private _imageProcessingObserver;
  39125. /**
  39126. * Attaches a new image processing configuration to the Standard Material.
  39127. * @param configuration
  39128. */
  39129. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39130. /**
  39131. * Gets wether the color curves effect is enabled.
  39132. */
  39133. /**
  39134. * Sets wether the color curves effect is enabled.
  39135. */
  39136. cameraColorCurvesEnabled: boolean;
  39137. /**
  39138. * Gets wether the color grading effect is enabled.
  39139. */
  39140. /**
  39141. * Gets wether the color grading effect is enabled.
  39142. */
  39143. cameraColorGradingEnabled: boolean;
  39144. /**
  39145. * Gets wether tonemapping is enabled or not.
  39146. */
  39147. /**
  39148. * Sets wether tonemapping is enabled or not
  39149. */
  39150. cameraToneMappingEnabled: boolean;
  39151. /**
  39152. * The camera exposure used on this material.
  39153. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39154. * This corresponds to a photographic exposure.
  39155. */
  39156. /**
  39157. * The camera exposure used on this material.
  39158. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39159. * This corresponds to a photographic exposure.
  39160. */
  39161. cameraExposure: number;
  39162. /**
  39163. * Gets The camera contrast used on this material.
  39164. */
  39165. /**
  39166. * Sets The camera contrast used on this material.
  39167. */
  39168. cameraContrast: number;
  39169. /**
  39170. * Gets the Color Grading 2D Lookup Texture.
  39171. */
  39172. /**
  39173. * Sets the Color Grading 2D Lookup Texture.
  39174. */
  39175. cameraColorGradingTexture: Nullable<BaseTexture>;
  39176. /**
  39177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39179. * 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;
  39180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39181. */
  39182. /**
  39183. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39184. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39185. * 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;
  39186. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39187. */
  39188. cameraColorCurves: Nullable<ColorCurves>;
  39189. /**
  39190. * Custom callback helping to override the default shader used in the material.
  39191. */
  39192. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39193. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39194. protected _worldViewProjectionMatrix: Matrix;
  39195. protected _globalAmbientColor: Color3;
  39196. protected _useLogarithmicDepth: boolean;
  39197. /**
  39198. * Instantiates a new standard material.
  39199. * This is the default material used in Babylon. It is the best trade off between quality
  39200. * and performances.
  39201. * @see http://doc.babylonjs.com/babylon101/materials
  39202. * @param name Define the name of the material in the scene
  39203. * @param scene Define the scene the material belong to
  39204. */
  39205. constructor(name: string, scene: Scene);
  39206. /**
  39207. * Gets a boolean indicating that current material needs to register RTT
  39208. */
  39209. readonly hasRenderTargetTextures: boolean;
  39210. /**
  39211. * Gets the current class name of the material e.g. "StandardMaterial"
  39212. * Mainly use in serialization.
  39213. * @returns the class name
  39214. */
  39215. getClassName(): string;
  39216. /**
  39217. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39218. * You can try switching to logarithmic depth.
  39219. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39220. */
  39221. useLogarithmicDepth: boolean;
  39222. /**
  39223. * Specifies if the material will require alpha blending
  39224. * @returns a boolean specifying if alpha blending is needed
  39225. */
  39226. needAlphaBlending(): boolean;
  39227. /**
  39228. * Specifies if this material should be rendered in alpha test mode
  39229. * @returns a boolean specifying if an alpha test is needed.
  39230. */
  39231. needAlphaTesting(): boolean;
  39232. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39233. /**
  39234. * Get the texture used for alpha test purpose.
  39235. * @returns the diffuse texture in case of the standard material.
  39236. */
  39237. getAlphaTestTexture(): Nullable<BaseTexture>;
  39238. /**
  39239. * Get if the submesh is ready to be used and all its information available.
  39240. * Child classes can use it to update shaders
  39241. * @param mesh defines the mesh to check
  39242. * @param subMesh defines which submesh to check
  39243. * @param useInstances specifies that instances should be used
  39244. * @returns a boolean indicating that the submesh is ready or not
  39245. */
  39246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39247. /**
  39248. * Builds the material UBO layouts.
  39249. * Used internally during the effect preparation.
  39250. */
  39251. buildUniformLayout(): void;
  39252. /**
  39253. * Unbinds the material from the mesh
  39254. */
  39255. unbind(): void;
  39256. /**
  39257. * Binds the submesh to this material by preparing the effect and shader to draw
  39258. * @param world defines the world transformation matrix
  39259. * @param mesh defines the mesh containing the submesh
  39260. * @param subMesh defines the submesh to bind the material to
  39261. */
  39262. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39263. /**
  39264. * Get the list of animatables in the material.
  39265. * @returns the list of animatables object used in the material
  39266. */
  39267. getAnimatables(): IAnimatable[];
  39268. /**
  39269. * Gets the active textures from the material
  39270. * @returns an array of textures
  39271. */
  39272. getActiveTextures(): BaseTexture[];
  39273. /**
  39274. * Specifies if the material uses a texture
  39275. * @param texture defines the texture to check against the material
  39276. * @returns a boolean specifying if the material uses the texture
  39277. */
  39278. hasTexture(texture: BaseTexture): boolean;
  39279. /**
  39280. * Disposes the material
  39281. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39282. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39283. */
  39284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39285. /**
  39286. * Makes a duplicate of the material, and gives it a new name
  39287. * @param name defines the new name for the duplicated material
  39288. * @returns the cloned material
  39289. */
  39290. clone(name: string): StandardMaterial;
  39291. /**
  39292. * Serializes this material in a JSON representation
  39293. * @returns the serialized material object
  39294. */
  39295. serialize(): any;
  39296. /**
  39297. * Creates a standard material from parsed material data
  39298. * @param source defines the JSON representation of the material
  39299. * @param scene defines the hosting scene
  39300. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39301. * @returns a new standard material
  39302. */
  39303. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39304. /**
  39305. * Are diffuse textures enabled in the application.
  39306. */
  39307. static DiffuseTextureEnabled: boolean;
  39308. /**
  39309. * Are ambient textures enabled in the application.
  39310. */
  39311. static AmbientTextureEnabled: boolean;
  39312. /**
  39313. * Are opacity textures enabled in the application.
  39314. */
  39315. static OpacityTextureEnabled: boolean;
  39316. /**
  39317. * Are reflection textures enabled in the application.
  39318. */
  39319. static ReflectionTextureEnabled: boolean;
  39320. /**
  39321. * Are emissive textures enabled in the application.
  39322. */
  39323. static EmissiveTextureEnabled: boolean;
  39324. /**
  39325. * Are specular textures enabled in the application.
  39326. */
  39327. static SpecularTextureEnabled: boolean;
  39328. /**
  39329. * Are bump textures enabled in the application.
  39330. */
  39331. static BumpTextureEnabled: boolean;
  39332. /**
  39333. * Are lightmap textures enabled in the application.
  39334. */
  39335. static LightmapTextureEnabled: boolean;
  39336. /**
  39337. * Are refraction textures enabled in the application.
  39338. */
  39339. static RefractionTextureEnabled: boolean;
  39340. /**
  39341. * Are color grading textures enabled in the application.
  39342. */
  39343. static ColorGradingTextureEnabled: boolean;
  39344. /**
  39345. * Are fresnels enabled in the application.
  39346. */
  39347. static FresnelEnabled: boolean;
  39348. }
  39349. }
  39350. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39351. import { Scene } from "babylonjs/scene";
  39352. import { Texture } from "babylonjs/Materials/Textures/texture";
  39353. /**
  39354. * A class extending Texture allowing drawing on a texture
  39355. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39356. */
  39357. export class DynamicTexture extends Texture {
  39358. private _generateMipMaps;
  39359. private _canvas;
  39360. private _context;
  39361. private _engine;
  39362. /**
  39363. * Creates a DynamicTexture
  39364. * @param name defines the name of the texture
  39365. * @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
  39366. * @param scene defines the scene where you want the texture
  39367. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39368. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39369. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39370. */
  39371. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39372. /**
  39373. * Get the current class name of the texture useful for serialization or dynamic coding.
  39374. * @returns "DynamicTexture"
  39375. */
  39376. getClassName(): string;
  39377. /**
  39378. * Gets the current state of canRescale
  39379. */
  39380. readonly canRescale: boolean;
  39381. private _recreate;
  39382. /**
  39383. * Scales the texture
  39384. * @param ratio the scale factor to apply to both width and height
  39385. */
  39386. scale(ratio: number): void;
  39387. /**
  39388. * Resizes the texture
  39389. * @param width the new width
  39390. * @param height the new height
  39391. */
  39392. scaleTo(width: number, height: number): void;
  39393. /**
  39394. * Gets the context of the canvas used by the texture
  39395. * @returns the canvas context of the dynamic texture
  39396. */
  39397. getContext(): CanvasRenderingContext2D;
  39398. /**
  39399. * Clears the texture
  39400. */
  39401. clear(): void;
  39402. /**
  39403. * Updates the texture
  39404. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39405. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39406. */
  39407. update(invertY?: boolean, premulAlpha?: boolean): void;
  39408. /**
  39409. * Draws text onto the texture
  39410. * @param text defines the text to be drawn
  39411. * @param x defines the placement of the text from the left
  39412. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39413. * @param font defines the font to be used with font-style, font-size, font-name
  39414. * @param color defines the color used for the text
  39415. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39416. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39417. * @param update defines whether texture is immediately update (default is true)
  39418. */
  39419. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39420. /**
  39421. * Clones the texture
  39422. * @returns the clone of the texture.
  39423. */
  39424. clone(): DynamicTexture;
  39425. /**
  39426. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39427. * @returns a serialized dynamic texture object
  39428. */
  39429. serialize(): any;
  39430. /** @hidden */
  39431. _rebuild(): void;
  39432. }
  39433. }
  39434. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39435. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39436. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39437. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39438. /** @hidden */
  39439. export var imageProcessingPixelShader: {
  39440. name: string;
  39441. shader: string;
  39442. };
  39443. }
  39444. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39445. import { Nullable } from "babylonjs/types";
  39446. import { Color4 } from "babylonjs/Maths/math";
  39447. import { Camera } from "babylonjs/Cameras/camera";
  39448. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39449. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39450. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39451. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39452. import { Engine } from "babylonjs/Engines/engine";
  39453. import "babylonjs/Shaders/imageProcessing.fragment";
  39454. import "babylonjs/Shaders/postprocess.vertex";
  39455. /**
  39456. * ImageProcessingPostProcess
  39457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39458. */
  39459. export class ImageProcessingPostProcess extends PostProcess {
  39460. /**
  39461. * Default configuration related to image processing available in the PBR Material.
  39462. */
  39463. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39464. /**
  39465. * Gets the image processing configuration used either in this material.
  39466. */
  39467. /**
  39468. * Sets the Default image processing configuration used either in the this material.
  39469. *
  39470. * If sets to null, the scene one is in use.
  39471. */
  39472. imageProcessingConfiguration: ImageProcessingConfiguration;
  39473. /**
  39474. * Keep track of the image processing observer to allow dispose and replace.
  39475. */
  39476. private _imageProcessingObserver;
  39477. /**
  39478. * Attaches a new image processing configuration to the PBR Material.
  39479. * @param configuration
  39480. */
  39481. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39482. /**
  39483. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39484. */
  39485. /**
  39486. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39487. */
  39488. colorCurves: Nullable<ColorCurves>;
  39489. /**
  39490. * Gets wether the color curves effect is enabled.
  39491. */
  39492. /**
  39493. * Sets wether the color curves effect is enabled.
  39494. */
  39495. colorCurvesEnabled: boolean;
  39496. /**
  39497. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39498. */
  39499. /**
  39500. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39501. */
  39502. colorGradingTexture: Nullable<BaseTexture>;
  39503. /**
  39504. * Gets wether the color grading effect is enabled.
  39505. */
  39506. /**
  39507. * Gets wether the color grading effect is enabled.
  39508. */
  39509. colorGradingEnabled: boolean;
  39510. /**
  39511. * Gets exposure used in the effect.
  39512. */
  39513. /**
  39514. * Sets exposure used in the effect.
  39515. */
  39516. exposure: number;
  39517. /**
  39518. * Gets wether tonemapping is enabled or not.
  39519. */
  39520. /**
  39521. * Sets wether tonemapping is enabled or not
  39522. */
  39523. toneMappingEnabled: boolean;
  39524. /**
  39525. * Gets the type of tone mapping effect.
  39526. */
  39527. /**
  39528. * Sets the type of tone mapping effect.
  39529. */
  39530. toneMappingType: number;
  39531. /**
  39532. * Gets contrast used in the effect.
  39533. */
  39534. /**
  39535. * Sets contrast used in the effect.
  39536. */
  39537. contrast: number;
  39538. /**
  39539. * Gets Vignette stretch size.
  39540. */
  39541. /**
  39542. * Sets Vignette stretch size.
  39543. */
  39544. vignetteStretch: number;
  39545. /**
  39546. * Gets Vignette centre X Offset.
  39547. */
  39548. /**
  39549. * Sets Vignette centre X Offset.
  39550. */
  39551. vignetteCentreX: number;
  39552. /**
  39553. * Gets Vignette centre Y Offset.
  39554. */
  39555. /**
  39556. * Sets Vignette centre Y Offset.
  39557. */
  39558. vignetteCentreY: number;
  39559. /**
  39560. * Gets Vignette weight or intensity of the vignette effect.
  39561. */
  39562. /**
  39563. * Sets Vignette weight or intensity of the vignette effect.
  39564. */
  39565. vignetteWeight: number;
  39566. /**
  39567. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39568. * if vignetteEnabled is set to true.
  39569. */
  39570. /**
  39571. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39572. * if vignetteEnabled is set to true.
  39573. */
  39574. vignetteColor: Color4;
  39575. /**
  39576. * Gets Camera field of view used by the Vignette effect.
  39577. */
  39578. /**
  39579. * Sets Camera field of view used by the Vignette effect.
  39580. */
  39581. vignetteCameraFov: number;
  39582. /**
  39583. * Gets the vignette blend mode allowing different kind of effect.
  39584. */
  39585. /**
  39586. * Sets the vignette blend mode allowing different kind of effect.
  39587. */
  39588. vignetteBlendMode: number;
  39589. /**
  39590. * Gets wether the vignette effect is enabled.
  39591. */
  39592. /**
  39593. * Sets wether the vignette effect is enabled.
  39594. */
  39595. vignetteEnabled: boolean;
  39596. private _fromLinearSpace;
  39597. /**
  39598. * Gets wether the input of the processing is in Gamma or Linear Space.
  39599. */
  39600. /**
  39601. * Sets wether the input of the processing is in Gamma or Linear Space.
  39602. */
  39603. fromLinearSpace: boolean;
  39604. /**
  39605. * Defines cache preventing GC.
  39606. */
  39607. private _defines;
  39608. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39609. /**
  39610. * "ImageProcessingPostProcess"
  39611. * @returns "ImageProcessingPostProcess"
  39612. */
  39613. getClassName(): string;
  39614. protected _updateParameters(): void;
  39615. dispose(camera?: Camera): void;
  39616. }
  39617. }
  39618. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39619. import { Scene } from "babylonjs/scene";
  39620. import { Color3 } from "babylonjs/Maths/math";
  39621. import { Mesh } from "babylonjs/Meshes/mesh";
  39622. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39623. /**
  39624. * Class containing static functions to help procedurally build meshes
  39625. */
  39626. export class GroundBuilder {
  39627. /**
  39628. * Creates a ground mesh
  39629. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39630. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39632. * @param name defines the name of the mesh
  39633. * @param options defines the options used to create the mesh
  39634. * @param scene defines the hosting scene
  39635. * @returns the ground mesh
  39636. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39637. */
  39638. static CreateGround(name: string, options: {
  39639. width?: number;
  39640. height?: number;
  39641. subdivisions?: number;
  39642. subdivisionsX?: number;
  39643. subdivisionsY?: number;
  39644. updatable?: boolean;
  39645. }, scene: any): Mesh;
  39646. /**
  39647. * Creates a tiled ground mesh
  39648. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39649. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39650. * * 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
  39651. * * 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
  39652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39653. * @param name defines the name of the mesh
  39654. * @param options defines the options used to create the mesh
  39655. * @param scene defines the hosting scene
  39656. * @returns the tiled ground mesh
  39657. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39658. */
  39659. static CreateTiledGround(name: string, options: {
  39660. xmin: number;
  39661. zmin: number;
  39662. xmax: number;
  39663. zmax: number;
  39664. subdivisions?: {
  39665. w: number;
  39666. h: number;
  39667. };
  39668. precision?: {
  39669. w: number;
  39670. h: number;
  39671. };
  39672. updatable?: boolean;
  39673. }, scene: Scene): Mesh;
  39674. /**
  39675. * Creates a ground mesh from a height map
  39676. * * The parameter `url` sets the URL of the height map image resource.
  39677. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39678. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39679. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39680. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39681. * * 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.
  39682. * * 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).
  39683. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39685. * @param name defines the name of the mesh
  39686. * @param url defines the url to the height map
  39687. * @param options defines the options used to create the mesh
  39688. * @param scene defines the hosting scene
  39689. * @returns the ground mesh
  39690. * @see https://doc.babylonjs.com/babylon101/height_map
  39691. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39692. */
  39693. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39694. width?: number;
  39695. height?: number;
  39696. subdivisions?: number;
  39697. minHeight?: number;
  39698. maxHeight?: number;
  39699. colorFilter?: Color3;
  39700. alphaFilter?: number;
  39701. updatable?: boolean;
  39702. onReady?: (mesh: GroundMesh) => void;
  39703. }, scene: Scene): GroundMesh;
  39704. }
  39705. }
  39706. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39707. import { Vector4 } from "babylonjs/Maths/math";
  39708. import { Mesh } from "babylonjs/Meshes/mesh";
  39709. /**
  39710. * Class containing static functions to help procedurally build meshes
  39711. */
  39712. export class TorusBuilder {
  39713. /**
  39714. * Creates a torus mesh
  39715. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39716. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39717. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39721. * @param name defines the name of the mesh
  39722. * @param options defines the options used to create the mesh
  39723. * @param scene defines the hosting scene
  39724. * @returns the torus mesh
  39725. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39726. */
  39727. static CreateTorus(name: string, options: {
  39728. diameter?: number;
  39729. thickness?: number;
  39730. tessellation?: number;
  39731. updatable?: boolean;
  39732. sideOrientation?: number;
  39733. frontUVs?: Vector4;
  39734. backUVs?: Vector4;
  39735. }, scene: any): Mesh;
  39736. }
  39737. }
  39738. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39739. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39740. import { Mesh } from "babylonjs/Meshes/mesh";
  39741. /**
  39742. * Class containing static functions to help procedurally build meshes
  39743. */
  39744. export class CylinderBuilder {
  39745. /**
  39746. * Creates a cylinder or a cone mesh
  39747. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39748. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39749. * * 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.
  39750. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39751. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39752. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39753. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39754. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39755. * * 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).
  39756. * * 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
  39757. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39758. * * 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
  39759. * * 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.
  39760. * * If `enclose` is false, a ring surface is one element.
  39761. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39762. * * 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
  39763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39766. * @param name defines the name of the mesh
  39767. * @param options defines the options used to create the mesh
  39768. * @param scene defines the hosting scene
  39769. * @returns the cylinder mesh
  39770. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39771. */
  39772. static CreateCylinder(name: string, options: {
  39773. height?: number;
  39774. diameterTop?: number;
  39775. diameterBottom?: number;
  39776. diameter?: number;
  39777. tessellation?: number;
  39778. subdivisions?: number;
  39779. arc?: number;
  39780. faceColors?: Color4[];
  39781. faceUV?: Vector4[];
  39782. updatable?: boolean;
  39783. hasRings?: boolean;
  39784. enclose?: boolean;
  39785. sideOrientation?: number;
  39786. frontUVs?: Vector4;
  39787. backUVs?: Vector4;
  39788. }, scene: any): Mesh;
  39789. }
  39790. }
  39791. declare module "babylonjs/Gamepads/gamepadManager" {
  39792. import { Observable } from "babylonjs/Misc/observable";
  39793. import { Nullable } from "babylonjs/types";
  39794. import { Scene } from "babylonjs/scene";
  39795. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39796. /**
  39797. * Manager for handling gamepads
  39798. */
  39799. export class GamepadManager {
  39800. private _scene?;
  39801. private _babylonGamepads;
  39802. private _oneGamepadConnected;
  39803. /** @hidden */
  39804. _isMonitoring: boolean;
  39805. private _gamepadEventSupported;
  39806. private _gamepadSupport;
  39807. /**
  39808. * observable to be triggered when the gamepad controller has been connected
  39809. */
  39810. onGamepadConnectedObservable: Observable<Gamepad>;
  39811. /**
  39812. * observable to be triggered when the gamepad controller has been disconnected
  39813. */
  39814. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39815. private _onGamepadConnectedEvent;
  39816. private _onGamepadDisconnectedEvent;
  39817. /**
  39818. * Initializes the gamepad manager
  39819. * @param _scene BabylonJS scene
  39820. */
  39821. constructor(_scene?: Scene | undefined);
  39822. /**
  39823. * The gamepads in the game pad manager
  39824. */
  39825. readonly gamepads: Gamepad[];
  39826. /**
  39827. * Get the gamepad controllers based on type
  39828. * @param type The type of gamepad controller
  39829. * @returns Nullable gamepad
  39830. */
  39831. getGamepadByType(type?: number): Nullable<Gamepad>;
  39832. /**
  39833. * Disposes the gamepad manager
  39834. */
  39835. dispose(): void;
  39836. private _addNewGamepad;
  39837. private _startMonitoringGamepads;
  39838. private _stopMonitoringGamepads;
  39839. /** @hidden */
  39840. _checkGamepadsStatus(): void;
  39841. private _updateGamepadObjects;
  39842. }
  39843. }
  39844. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39845. import { Nullable } from "babylonjs/types";
  39846. import { Scene } from "babylonjs/scene";
  39847. import { ISceneComponent } from "babylonjs/sceneComponent";
  39848. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39849. module "babylonjs/scene" {
  39850. interface Scene {
  39851. /** @hidden */
  39852. _gamepadManager: Nullable<GamepadManager>;
  39853. /**
  39854. * Gets the gamepad manager associated with the scene
  39855. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39856. */
  39857. gamepadManager: GamepadManager;
  39858. }
  39859. }
  39860. module "babylonjs/Cameras/freeCameraInputsManager" {
  39861. /**
  39862. * Interface representing a free camera inputs manager
  39863. */
  39864. interface FreeCameraInputsManager {
  39865. /**
  39866. * Adds gamepad input support to the FreeCameraInputsManager.
  39867. * @returns the FreeCameraInputsManager
  39868. */
  39869. addGamepad(): FreeCameraInputsManager;
  39870. }
  39871. }
  39872. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39873. /**
  39874. * Interface representing an arc rotate camera inputs manager
  39875. */
  39876. interface ArcRotateCameraInputsManager {
  39877. /**
  39878. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39879. * @returns the camera inputs manager
  39880. */
  39881. addGamepad(): ArcRotateCameraInputsManager;
  39882. }
  39883. }
  39884. /**
  39885. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39886. */
  39887. export class GamepadSystemSceneComponent implements ISceneComponent {
  39888. /**
  39889. * The component name helpfull to identify the component in the list of scene components.
  39890. */
  39891. readonly name: string;
  39892. /**
  39893. * The scene the component belongs to.
  39894. */
  39895. scene: Scene;
  39896. /**
  39897. * Creates a new instance of the component for the given scene
  39898. * @param scene Defines the scene to register the component in
  39899. */
  39900. constructor(scene: Scene);
  39901. /**
  39902. * Registers the component in a given scene
  39903. */
  39904. register(): void;
  39905. /**
  39906. * Rebuilds the elements related to this component in case of
  39907. * context lost for instance.
  39908. */
  39909. rebuild(): void;
  39910. /**
  39911. * Disposes the component and the associated ressources
  39912. */
  39913. dispose(): void;
  39914. private _beforeCameraUpdate;
  39915. }
  39916. }
  39917. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39918. import { Observable } from "babylonjs/Misc/observable";
  39919. import { Nullable } from "babylonjs/types";
  39920. import { Camera } from "babylonjs/Cameras/camera";
  39921. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39922. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39923. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39924. import { Scene } from "babylonjs/scene";
  39925. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39926. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39928. import { Mesh } from "babylonjs/Meshes/mesh";
  39929. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39930. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39931. import "babylonjs/Meshes/Builders/groundBuilder";
  39932. import "babylonjs/Meshes/Builders/torusBuilder";
  39933. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39934. import "babylonjs/Gamepads/gamepadSceneComponent";
  39935. import "babylonjs/Animations/animatable";
  39936. /**
  39937. * Options to modify the vr teleportation behavior.
  39938. */
  39939. export interface VRTeleportationOptions {
  39940. /**
  39941. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39942. */
  39943. floorMeshName?: string;
  39944. /**
  39945. * A list of meshes to be used as the teleportation floor. (default: empty)
  39946. */
  39947. floorMeshes?: Mesh[];
  39948. }
  39949. /**
  39950. * Options to modify the vr experience helper's behavior.
  39951. */
  39952. export interface VRExperienceHelperOptions extends WebVROptions {
  39953. /**
  39954. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39955. */
  39956. createDeviceOrientationCamera?: boolean;
  39957. /**
  39958. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39959. */
  39960. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39961. /**
  39962. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39963. */
  39964. laserToggle?: boolean;
  39965. /**
  39966. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39967. */
  39968. floorMeshes?: Mesh[];
  39969. /**
  39970. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39971. */
  39972. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39973. }
  39974. /**
  39975. * Event containing information after VR has been entered
  39976. */
  39977. export class OnAfterEnteringVRObservableEvent {
  39978. /**
  39979. * If entering vr was successful
  39980. */
  39981. success: boolean;
  39982. }
  39983. /**
  39984. * Helps to quickly add VR support to an existing scene.
  39985. * See http://doc.babylonjs.com/how_to/webvr_helper
  39986. */
  39987. export class VRExperienceHelper {
  39988. /** Options to modify the vr experience helper's behavior. */
  39989. webVROptions: VRExperienceHelperOptions;
  39990. private _scene;
  39991. private _position;
  39992. private _btnVR;
  39993. private _btnVRDisplayed;
  39994. private _webVRsupported;
  39995. private _webVRready;
  39996. private _webVRrequesting;
  39997. private _webVRpresenting;
  39998. private _hasEnteredVR;
  39999. private _fullscreenVRpresenting;
  40000. private _canvas;
  40001. private _webVRCamera;
  40002. private _vrDeviceOrientationCamera;
  40003. private _deviceOrientationCamera;
  40004. private _existingCamera;
  40005. private _onKeyDown;
  40006. private _onVrDisplayPresentChange;
  40007. private _onVRDisplayChanged;
  40008. private _onVRRequestPresentStart;
  40009. private _onVRRequestPresentComplete;
  40010. /**
  40011. * Observable raised right before entering VR.
  40012. */
  40013. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40014. /**
  40015. * Observable raised when entering VR has completed.
  40016. */
  40017. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40018. /**
  40019. * Observable raised when exiting VR.
  40020. */
  40021. onExitingVRObservable: Observable<VRExperienceHelper>;
  40022. /**
  40023. * Observable raised when controller mesh is loaded.
  40024. */
  40025. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40026. /** Return this.onEnteringVRObservable
  40027. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40028. */
  40029. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40030. /** Return this.onExitingVRObservable
  40031. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40032. */
  40033. readonly onExitingVR: Observable<VRExperienceHelper>;
  40034. /** Return this.onControllerMeshLoadedObservable
  40035. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40036. */
  40037. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40038. private _rayLength;
  40039. private _useCustomVRButton;
  40040. private _teleportationRequested;
  40041. private _teleportActive;
  40042. private _floorMeshName;
  40043. private _floorMeshesCollection;
  40044. private _rotationAllowed;
  40045. private _teleportBackwardsVector;
  40046. private _teleportationTarget;
  40047. private _isDefaultTeleportationTarget;
  40048. private _postProcessMove;
  40049. private _teleportationFillColor;
  40050. private _teleportationBorderColor;
  40051. private _rotationAngle;
  40052. private _haloCenter;
  40053. private _cameraGazer;
  40054. private _padSensibilityUp;
  40055. private _padSensibilityDown;
  40056. private _leftController;
  40057. private _rightController;
  40058. /**
  40059. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40060. */
  40061. onNewMeshSelected: Observable<AbstractMesh>;
  40062. /**
  40063. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40064. */
  40065. onNewMeshPicked: Observable<PickingInfo>;
  40066. private _circleEase;
  40067. /**
  40068. * Observable raised before camera teleportation
  40069. */
  40070. onBeforeCameraTeleport: Observable<Vector3>;
  40071. /**
  40072. * Observable raised after camera teleportation
  40073. */
  40074. onAfterCameraTeleport: Observable<Vector3>;
  40075. /**
  40076. * Observable raised when current selected mesh gets unselected
  40077. */
  40078. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40079. private _raySelectionPredicate;
  40080. /**
  40081. * To be optionaly changed by user to define custom ray selection
  40082. */
  40083. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40084. /**
  40085. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40086. */
  40087. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40088. /**
  40089. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40090. */
  40091. teleportationEnabled: boolean;
  40092. private _defaultHeight;
  40093. private _teleportationInitialized;
  40094. private _interactionsEnabled;
  40095. private _interactionsRequested;
  40096. private _displayGaze;
  40097. private _displayLaserPointer;
  40098. /**
  40099. * The mesh used to display where the user is going to teleport.
  40100. */
  40101. /**
  40102. * Sets the mesh to be used to display where the user is going to teleport.
  40103. */
  40104. teleportationTarget: Mesh;
  40105. /**
  40106. * 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
  40107. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40108. * See http://doc.babylonjs.com/resources/baking_transformations
  40109. */
  40110. gazeTrackerMesh: Mesh;
  40111. /**
  40112. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40113. */
  40114. updateGazeTrackerScale: boolean;
  40115. /**
  40116. * If the gaze trackers color should be updated when selecting meshes
  40117. */
  40118. updateGazeTrackerColor: boolean;
  40119. /**
  40120. * The gaze tracking mesh corresponding to the left controller
  40121. */
  40122. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40123. /**
  40124. * The gaze tracking mesh corresponding to the right controller
  40125. */
  40126. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40127. /**
  40128. * If the ray of the gaze should be displayed.
  40129. */
  40130. /**
  40131. * Sets if the ray of the gaze should be displayed.
  40132. */
  40133. displayGaze: boolean;
  40134. /**
  40135. * If the ray of the LaserPointer should be displayed.
  40136. */
  40137. /**
  40138. * Sets if the ray of the LaserPointer should be displayed.
  40139. */
  40140. displayLaserPointer: boolean;
  40141. /**
  40142. * The deviceOrientationCamera used as the camera when not in VR.
  40143. */
  40144. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40145. /**
  40146. * Based on the current WebVR support, returns the current VR camera used.
  40147. */
  40148. readonly currentVRCamera: Nullable<Camera>;
  40149. /**
  40150. * The webVRCamera which is used when in VR.
  40151. */
  40152. readonly webVRCamera: WebVRFreeCamera;
  40153. /**
  40154. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40155. */
  40156. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40157. private readonly _teleportationRequestInitiated;
  40158. /**
  40159. * Defines wether or not Pointer lock should be requested when switching to
  40160. * full screen.
  40161. */
  40162. requestPointerLockOnFullScreen: boolean;
  40163. /**
  40164. * Instantiates a VRExperienceHelper.
  40165. * Helps to quickly add VR support to an existing scene.
  40166. * @param scene The scene the VRExperienceHelper belongs to.
  40167. * @param webVROptions Options to modify the vr experience helper's behavior.
  40168. */
  40169. constructor(scene: Scene,
  40170. /** Options to modify the vr experience helper's behavior. */
  40171. webVROptions?: VRExperienceHelperOptions);
  40172. private _onDefaultMeshLoaded;
  40173. private _onResize;
  40174. private _onFullscreenChange;
  40175. /**
  40176. * Gets a value indicating if we are currently in VR mode.
  40177. */
  40178. readonly isInVRMode: boolean;
  40179. private onVrDisplayPresentChange;
  40180. private onVRDisplayChanged;
  40181. private moveButtonToBottomRight;
  40182. private displayVRButton;
  40183. private updateButtonVisibility;
  40184. private _cachedAngularSensibility;
  40185. /**
  40186. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40187. * Otherwise, will use the fullscreen API.
  40188. */
  40189. enterVR(): void;
  40190. /**
  40191. * Attempt to exit VR, or fullscreen.
  40192. */
  40193. exitVR(): void;
  40194. /**
  40195. * The position of the vr experience helper.
  40196. */
  40197. /**
  40198. * Sets the position of the vr experience helper.
  40199. */
  40200. position: Vector3;
  40201. /**
  40202. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40203. */
  40204. enableInteractions(): void;
  40205. private readonly _noControllerIsActive;
  40206. private beforeRender;
  40207. private _isTeleportationFloor;
  40208. /**
  40209. * Adds a floor mesh to be used for teleportation.
  40210. * @param floorMesh the mesh to be used for teleportation.
  40211. */
  40212. addFloorMesh(floorMesh: Mesh): void;
  40213. /**
  40214. * Removes a floor mesh from being used for teleportation.
  40215. * @param floorMesh the mesh to be removed.
  40216. */
  40217. removeFloorMesh(floorMesh: Mesh): void;
  40218. /**
  40219. * Enables interactions and teleportation using the VR controllers and gaze.
  40220. * @param vrTeleportationOptions options to modify teleportation behavior.
  40221. */
  40222. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40223. private _onNewGamepadConnected;
  40224. private _tryEnableInteractionOnController;
  40225. private _onNewGamepadDisconnected;
  40226. private _enableInteractionOnController;
  40227. private _checkTeleportWithRay;
  40228. private _checkRotate;
  40229. private _checkTeleportBackwards;
  40230. private _enableTeleportationOnController;
  40231. private _createTeleportationCircles;
  40232. private _displayTeleportationTarget;
  40233. private _hideTeleportationTarget;
  40234. private _rotateCamera;
  40235. private _moveTeleportationSelectorTo;
  40236. private _workingVector;
  40237. private _workingQuaternion;
  40238. private _workingMatrix;
  40239. /**
  40240. * Teleports the users feet to the desired location
  40241. * @param location The location where the user's feet should be placed
  40242. */
  40243. teleportCamera(location: Vector3): void;
  40244. private _convertNormalToDirectionOfRay;
  40245. private _castRayAndSelectObject;
  40246. private _notifySelectedMeshUnselected;
  40247. /**
  40248. * Sets the color of the laser ray from the vr controllers.
  40249. * @param color new color for the ray.
  40250. */
  40251. changeLaserColor(color: Color3): void;
  40252. /**
  40253. * Sets the color of the ray from the vr headsets gaze.
  40254. * @param color new color for the ray.
  40255. */
  40256. changeGazeColor(color: Color3): void;
  40257. /**
  40258. * Exits VR and disposes of the vr experience helper
  40259. */
  40260. dispose(): void;
  40261. /**
  40262. * Gets the name of the VRExperienceHelper class
  40263. * @returns "VRExperienceHelper"
  40264. */
  40265. getClassName(): string;
  40266. }
  40267. }
  40268. declare module "babylonjs/Cameras/VR/index" {
  40269. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40270. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40271. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40272. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40273. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40274. export * from "babylonjs/Cameras/VR/webVRCamera";
  40275. }
  40276. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40277. import { Observable } from "babylonjs/Misc/observable";
  40278. import { Nullable } from "babylonjs/types";
  40279. import { IDisposable, Scene } from "babylonjs/scene";
  40280. import { Vector3 } from "babylonjs/Maths/math";
  40281. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40282. import { Ray } from "babylonjs/Culling/ray";
  40283. /**
  40284. * Manages an XRSession
  40285. * @see https://doc.babylonjs.com/how_to/webxr
  40286. */
  40287. export class WebXRSessionManager implements IDisposable {
  40288. private scene;
  40289. /**
  40290. * Fires every time a new xrFrame arrives which can be used to update the camera
  40291. */
  40292. onXRFrameObservable: Observable<any>;
  40293. /**
  40294. * Fires when the xr session is ended either by the device or manually done
  40295. */
  40296. onXRSessionEnded: Observable<any>;
  40297. /** @hidden */
  40298. _xrSession: XRSession;
  40299. /** @hidden */
  40300. _frameOfReference: XRFrameOfReference;
  40301. /** @hidden */
  40302. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40303. /** @hidden */
  40304. _currentXRFrame: Nullable<XRFrame>;
  40305. private _xrNavigator;
  40306. private _xrDevice;
  40307. private _tmpMatrix;
  40308. /**
  40309. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40310. * @param scene The scene which the session should be created for
  40311. */
  40312. constructor(scene: Scene);
  40313. /**
  40314. * Initializes the manager
  40315. * After initialization enterXR can be called to start an XR session
  40316. * @returns Promise which resolves after it is initialized
  40317. */
  40318. initializeAsync(): Promise<void>;
  40319. /**
  40320. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40321. * @param sessionCreationOptions xr options to create the session with
  40322. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40323. * @returns Promise which resolves after it enters XR
  40324. */
  40325. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40326. /**
  40327. * Stops the xrSession and restores the renderloop
  40328. * @returns Promise which resolves after it exits XR
  40329. */
  40330. exitXRAsync(): Promise<void>;
  40331. /**
  40332. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40333. * @param ray ray to cast into the environment
  40334. * @returns Promise which resolves with a collision point in the environment if it exists
  40335. */
  40336. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40337. /**
  40338. * Checks if a session would be supported for the creation options specified
  40339. * @param options creation options to check if they are supported
  40340. * @returns true if supported
  40341. */
  40342. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40343. /**
  40344. * @hidden
  40345. * Converts the render layer of xrSession to a render target
  40346. * @param session session to create render target for
  40347. * @param scene scene the new render target should be created for
  40348. */
  40349. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40350. /**
  40351. * Disposes of the session manager
  40352. */
  40353. dispose(): void;
  40354. }
  40355. }
  40356. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40357. import { Scene } from "babylonjs/scene";
  40358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40359. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40360. /**
  40361. * WebXR Camera which holds the views for the xrSession
  40362. * @see https://doc.babylonjs.com/how_to/webxr
  40363. */
  40364. export class WebXRCamera extends FreeCamera {
  40365. private static _TmpMatrix;
  40366. /**
  40367. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40368. * @param name the name of the camera
  40369. * @param scene the scene to add the camera to
  40370. */
  40371. constructor(name: string, scene: Scene);
  40372. private _updateNumberOfRigCameras;
  40373. /** @hidden */
  40374. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40375. /**
  40376. * Updates the cameras position from the current pose information of the XR session
  40377. * @param xrSessionManager the session containing pose information
  40378. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40379. */
  40380. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40381. }
  40382. }
  40383. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40384. import { Nullable } from "babylonjs/types";
  40385. import { Observable } from "babylonjs/Misc/observable";
  40386. import { IDisposable, Scene } from "babylonjs/scene";
  40387. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40389. import { Ray } from "babylonjs/Culling/ray";
  40390. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40391. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40392. /**
  40393. * States of the webXR experience
  40394. */
  40395. export enum WebXRState {
  40396. /**
  40397. * Transitioning to being in XR mode
  40398. */
  40399. ENTERING_XR = 0,
  40400. /**
  40401. * Transitioning to non XR mode
  40402. */
  40403. EXITING_XR = 1,
  40404. /**
  40405. * In XR mode and presenting
  40406. */
  40407. IN_XR = 2,
  40408. /**
  40409. * Not entered XR mode
  40410. */
  40411. NOT_IN_XR = 3
  40412. }
  40413. /**
  40414. * Helper class used to enable XR
  40415. * @see https://doc.babylonjs.com/how_to/webxr
  40416. */
  40417. export class WebXRExperienceHelper implements IDisposable {
  40418. private scene;
  40419. /**
  40420. * 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
  40421. */
  40422. container: AbstractMesh;
  40423. /**
  40424. * Camera used to render xr content
  40425. */
  40426. camera: WebXRCamera;
  40427. /**
  40428. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40429. */
  40430. state: WebXRState;
  40431. private _setState;
  40432. private static _TmpVector;
  40433. /**
  40434. * Fires when the state of the experience helper has changed
  40435. */
  40436. onStateChangedObservable: Observable<WebXRState>;
  40437. /** @hidden */
  40438. _sessionManager: WebXRSessionManager;
  40439. private _nonVRCamera;
  40440. private _originalSceneAutoClear;
  40441. private _supported;
  40442. /**
  40443. * Creates the experience helper
  40444. * @param scene the scene to attach the experience helper to
  40445. * @returns a promise for the experience helper
  40446. */
  40447. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40448. /**
  40449. * Creates a WebXRExperienceHelper
  40450. * @param scene The scene the helper should be created in
  40451. */
  40452. private constructor();
  40453. /**
  40454. * Exits XR mode and returns the scene to its original state
  40455. * @returns promise that resolves after xr mode has exited
  40456. */
  40457. exitXRAsync(): Promise<void>;
  40458. /**
  40459. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40460. * @param sessionCreationOptions options for the XR session
  40461. * @param frameOfReference frame of reference of the XR session
  40462. * @returns promise that resolves after xr mode has entered
  40463. */
  40464. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40465. /**
  40466. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40467. * @param ray ray to cast into the environment
  40468. * @returns Promise which resolves with a collision point in the environment if it exists
  40469. */
  40470. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40471. /**
  40472. * Updates the global position of the camera by moving the camera's container
  40473. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40474. * @param position The desired global position of the camera
  40475. */
  40476. setPositionOfCameraUsingContainer(position: Vector3): void;
  40477. /**
  40478. * Rotates the xr camera by rotating the camera's container around the camera's position
  40479. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40480. * @param rotation the desired quaternion rotation to apply to the camera
  40481. */
  40482. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40483. /**
  40484. * Checks if the creation options are supported by the xr session
  40485. * @param options creation options
  40486. * @returns true if supported
  40487. */
  40488. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40489. /**
  40490. * Disposes of the experience helper
  40491. */
  40492. dispose(): void;
  40493. }
  40494. }
  40495. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40496. import { Nullable } from "babylonjs/types";
  40497. import { Observable } from "babylonjs/Misc/observable";
  40498. import { IDisposable, Scene } from "babylonjs/scene";
  40499. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40500. /**
  40501. * Button which can be used to enter a different mode of XR
  40502. */
  40503. export class WebXREnterExitUIButton {
  40504. /** button element */
  40505. element: HTMLElement;
  40506. /** XR initialization options for the button */
  40507. initializationOptions: XRSessionCreationOptions;
  40508. /**
  40509. * Creates a WebXREnterExitUIButton
  40510. * @param element button element
  40511. * @param initializationOptions XR initialization options for the button
  40512. */
  40513. constructor(
  40514. /** button element */
  40515. element: HTMLElement,
  40516. /** XR initialization options for the button */
  40517. initializationOptions: XRSessionCreationOptions);
  40518. /**
  40519. * Overwritable function which can be used to update the button's visuals when the state changes
  40520. * @param activeButton the current active button in the UI
  40521. */
  40522. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40523. }
  40524. /**
  40525. * Options to create the webXR UI
  40526. */
  40527. export class WebXREnterExitUIOptions {
  40528. /**
  40529. * Context to enter xr with
  40530. */
  40531. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40532. /**
  40533. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40534. */
  40535. customButtons?: Array<WebXREnterExitUIButton>;
  40536. }
  40537. /**
  40538. * UI to allow the user to enter/exit XR mode
  40539. */
  40540. export class WebXREnterExitUI implements IDisposable {
  40541. private scene;
  40542. private _overlay;
  40543. private _buttons;
  40544. private _activeButton;
  40545. /**
  40546. * Fired every time the active button is changed.
  40547. *
  40548. * When xr is entered via a button that launches xr that button will be the callback parameter
  40549. *
  40550. * When exiting xr the callback parameter will be null)
  40551. */
  40552. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40553. /**
  40554. * Creates UI to allow the user to enter/exit XR mode
  40555. * @param scene the scene to add the ui to
  40556. * @param helper the xr experience helper to enter/exit xr with
  40557. * @param options options to configure the UI
  40558. * @returns the created ui
  40559. */
  40560. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40561. private constructor();
  40562. private _updateButtons;
  40563. /**
  40564. * Disposes of the object
  40565. */
  40566. dispose(): void;
  40567. }
  40568. }
  40569. declare module "babylonjs/Cameras/XR/webXRInput" {
  40570. import { IDisposable, Scene } from "babylonjs/scene";
  40571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40572. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40573. /**
  40574. * Represents an XR input
  40575. */
  40576. export class WebXRController {
  40577. /**
  40578. * 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
  40579. */
  40580. grip?: AbstractMesh;
  40581. /**
  40582. * Pointer which can be used to select objects or attach a visible laser to
  40583. */
  40584. pointer: AbstractMesh;
  40585. /**
  40586. * Creates the controller
  40587. * @see https://doc.babylonjs.com/how_to/webxr
  40588. * @param scene the scene which the controller should be associated to
  40589. */
  40590. constructor(scene: Scene);
  40591. /**
  40592. * Disposes of the object
  40593. */
  40594. dispose(): void;
  40595. }
  40596. /**
  40597. * XR input used to track XR inputs such as controllers/rays
  40598. */
  40599. export class WebXRInput implements IDisposable {
  40600. private helper;
  40601. /**
  40602. * XR controllers being tracked
  40603. */
  40604. controllers: Array<WebXRController>;
  40605. private _tmpMatrix;
  40606. private _frameObserver;
  40607. /**
  40608. * Initializes the WebXRInput
  40609. * @param helper experience helper which the input should be created for
  40610. */
  40611. constructor(helper: WebXRExperienceHelper);
  40612. /**
  40613. * Disposes of the object
  40614. */
  40615. dispose(): void;
  40616. }
  40617. }
  40618. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40619. import { Nullable } from "babylonjs/types";
  40620. import { IDisposable } from "babylonjs/scene";
  40621. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40622. /**
  40623. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40624. */
  40625. export class WebXRManagedOutputCanvas implements IDisposable {
  40626. private _canvas;
  40627. /**
  40628. * xrpresent context of the canvas which can be used to display/mirror xr content
  40629. */
  40630. canvasContext: Nullable<WebGLRenderingContext>;
  40631. /**
  40632. * Initializes the canvas to be added/removed upon entering/exiting xr
  40633. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40634. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40635. */
  40636. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40637. /**
  40638. * Disposes of the object
  40639. */
  40640. dispose(): void;
  40641. private _setManagedOutputCanvas;
  40642. private _addCanvas;
  40643. private _removeCanvas;
  40644. }
  40645. }
  40646. declare module "babylonjs/Cameras/XR/index" {
  40647. export * from "babylonjs/Cameras/XR/webXRCamera";
  40648. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40649. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40650. export * from "babylonjs/Cameras/XR/webXRInput";
  40651. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40652. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40653. }
  40654. declare module "babylonjs/Cameras/RigModes/index" {
  40655. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40656. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40657. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40658. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40659. }
  40660. declare module "babylonjs/Cameras/index" {
  40661. export * from "babylonjs/Cameras/Inputs/index";
  40662. export * from "babylonjs/Cameras/cameraInputsManager";
  40663. export * from "babylonjs/Cameras/camera";
  40664. export * from "babylonjs/Cameras/targetCamera";
  40665. export * from "babylonjs/Cameras/freeCamera";
  40666. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40667. export * from "babylonjs/Cameras/touchCamera";
  40668. export * from "babylonjs/Cameras/arcRotateCamera";
  40669. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40670. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40671. export * from "babylonjs/Cameras/flyCamera";
  40672. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40673. export * from "babylonjs/Cameras/followCamera";
  40674. export * from "babylonjs/Cameras/gamepadCamera";
  40675. export * from "babylonjs/Cameras/Stereoscopic/index";
  40676. export * from "babylonjs/Cameras/universalCamera";
  40677. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40678. export * from "babylonjs/Cameras/VR/index";
  40679. export * from "babylonjs/Cameras/XR/index";
  40680. export * from "babylonjs/Cameras/RigModes/index";
  40681. }
  40682. declare module "babylonjs/Collisions/index" {
  40683. export * from "babylonjs/Collisions/collider";
  40684. export * from "babylonjs/Collisions/collisionCoordinator";
  40685. export * from "babylonjs/Collisions/pickingInfo";
  40686. export * from "babylonjs/Collisions/intersectionInfo";
  40687. }
  40688. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40689. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40690. import { Vector3, Plane } from "babylonjs/Maths/math";
  40691. import { Ray } from "babylonjs/Culling/ray";
  40692. /**
  40693. * Contains an array of blocks representing the octree
  40694. */
  40695. export interface IOctreeContainer<T> {
  40696. /**
  40697. * Blocks within the octree
  40698. */
  40699. blocks: Array<OctreeBlock<T>>;
  40700. }
  40701. /**
  40702. * Class used to store a cell in an octree
  40703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40704. */
  40705. export class OctreeBlock<T> {
  40706. /**
  40707. * Gets the content of the current block
  40708. */
  40709. entries: T[];
  40710. /**
  40711. * Gets the list of block children
  40712. */
  40713. blocks: Array<OctreeBlock<T>>;
  40714. private _depth;
  40715. private _maxDepth;
  40716. private _capacity;
  40717. private _minPoint;
  40718. private _maxPoint;
  40719. private _boundingVectors;
  40720. private _creationFunc;
  40721. /**
  40722. * Creates a new block
  40723. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40724. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40725. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40726. * @param depth defines the current depth of this block in the octree
  40727. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40728. * @param creationFunc defines a callback to call when an element is added to the block
  40729. */
  40730. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40731. /**
  40732. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40733. */
  40734. readonly capacity: number;
  40735. /**
  40736. * Gets the minimum vector (in world space) of the block's bounding box
  40737. */
  40738. readonly minPoint: Vector3;
  40739. /**
  40740. * Gets the maximum vector (in world space) of the block's bounding box
  40741. */
  40742. readonly maxPoint: Vector3;
  40743. /**
  40744. * Add a new element to this block
  40745. * @param entry defines the element to add
  40746. */
  40747. addEntry(entry: T): void;
  40748. /**
  40749. * Remove an element from this block
  40750. * @param entry defines the element to remove
  40751. */
  40752. removeEntry(entry: T): void;
  40753. /**
  40754. * Add an array of elements to this block
  40755. * @param entries defines the array of elements to add
  40756. */
  40757. addEntries(entries: T[]): void;
  40758. /**
  40759. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40760. * @param frustumPlanes defines the frustum planes to test
  40761. * @param selection defines the array to store current content if selection is positive
  40762. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40763. */
  40764. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40765. /**
  40766. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40767. * @param sphereCenter defines the bounding sphere center
  40768. * @param sphereRadius defines the bounding sphere radius
  40769. * @param selection defines the array to store current content if selection is positive
  40770. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40771. */
  40772. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40773. /**
  40774. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40775. * @param ray defines the ray to test with
  40776. * @param selection defines the array to store current content if selection is positive
  40777. */
  40778. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40779. /**
  40780. * Subdivide the content into child blocks (this block will then be empty)
  40781. */
  40782. createInnerBlocks(): void;
  40783. /**
  40784. * @hidden
  40785. */
  40786. 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;
  40787. }
  40788. }
  40789. declare module "babylonjs/Culling/Octrees/octree" {
  40790. import { SmartArray } from "babylonjs/Misc/smartArray";
  40791. import { Vector3, Plane } from "babylonjs/Maths/math";
  40792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40794. import { Ray } from "babylonjs/Culling/ray";
  40795. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40796. /**
  40797. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40798. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40799. */
  40800. export class Octree<T> {
  40801. /** 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.) */
  40802. maxDepth: number;
  40803. /**
  40804. * Blocks within the octree containing objects
  40805. */
  40806. blocks: Array<OctreeBlock<T>>;
  40807. /**
  40808. * Content stored in the octree
  40809. */
  40810. dynamicContent: T[];
  40811. private _maxBlockCapacity;
  40812. private _selectionContent;
  40813. private _creationFunc;
  40814. /**
  40815. * Creates a octree
  40816. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40817. * @param creationFunc function to be used to instatiate the octree
  40818. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40819. * @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.)
  40820. */
  40821. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40822. /** 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.) */
  40823. maxDepth?: number);
  40824. /**
  40825. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40826. * @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);
  40827. * @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);
  40828. * @param entries meshes to be added to the octree blocks
  40829. */
  40830. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40831. /**
  40832. * Adds a mesh to the octree
  40833. * @param entry Mesh to add to the octree
  40834. */
  40835. addMesh(entry: T): void;
  40836. /**
  40837. * Remove an element from the octree
  40838. * @param entry defines the element to remove
  40839. */
  40840. removeMesh(entry: T): void;
  40841. /**
  40842. * Selects an array of meshes within the frustum
  40843. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40844. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40845. * @returns array of meshes within the frustum
  40846. */
  40847. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40848. /**
  40849. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40850. * @param sphereCenter defines the bounding sphere center
  40851. * @param sphereRadius defines the bounding sphere radius
  40852. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40853. * @returns an array of objects that intersect the sphere
  40854. */
  40855. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40856. /**
  40857. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40858. * @param ray defines the ray to test with
  40859. * @returns array of intersected objects
  40860. */
  40861. intersectsRay(ray: Ray): SmartArray<T>;
  40862. /**
  40863. * Adds a mesh into the octree block if it intersects the block
  40864. */
  40865. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40866. /**
  40867. * Adds a submesh into the octree block if it intersects the block
  40868. */
  40869. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40870. }
  40871. }
  40872. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40873. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40874. import { Scene } from "babylonjs/scene";
  40875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40877. import { Ray } from "babylonjs/Culling/ray";
  40878. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40879. import { Collider } from "babylonjs/Collisions/collider";
  40880. module "babylonjs/scene" {
  40881. interface Scene {
  40882. /**
  40883. * @hidden
  40884. * Backing Filed
  40885. */
  40886. _selectionOctree: Octree<AbstractMesh>;
  40887. /**
  40888. * Gets the octree used to boost mesh selection (picking)
  40889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40890. */
  40891. selectionOctree: Octree<AbstractMesh>;
  40892. /**
  40893. * Creates or updates the octree used to boost selection (picking)
  40894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40895. * @param maxCapacity defines the maximum capacity per leaf
  40896. * @param maxDepth defines the maximum depth of the octree
  40897. * @returns an octree of AbstractMesh
  40898. */
  40899. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40900. }
  40901. }
  40902. module "babylonjs/Meshes/abstractMesh" {
  40903. interface AbstractMesh {
  40904. /**
  40905. * @hidden
  40906. * Backing Field
  40907. */
  40908. _submeshesOctree: Octree<SubMesh>;
  40909. /**
  40910. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40911. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40912. * @param maxCapacity defines the maximum size of each block (64 by default)
  40913. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40914. * @returns the new octree
  40915. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40917. */
  40918. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40919. }
  40920. }
  40921. /**
  40922. * Defines the octree scene component responsible to manage any octrees
  40923. * in a given scene.
  40924. */
  40925. export class OctreeSceneComponent {
  40926. /**
  40927. * The component name helpfull to identify the component in the list of scene components.
  40928. */
  40929. readonly name: string;
  40930. /**
  40931. * The scene the component belongs to.
  40932. */
  40933. scene: Scene;
  40934. /**
  40935. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40936. */
  40937. readonly checksIsEnabled: boolean;
  40938. /**
  40939. * Creates a new instance of the component for the given scene
  40940. * @param scene Defines the scene to register the component in
  40941. */
  40942. constructor(scene: Scene);
  40943. /**
  40944. * Registers the component in a given scene
  40945. */
  40946. register(): void;
  40947. /**
  40948. * Return the list of active meshes
  40949. * @returns the list of active meshes
  40950. */
  40951. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40952. /**
  40953. * Return the list of active sub meshes
  40954. * @param mesh The mesh to get the candidates sub meshes from
  40955. * @returns the list of active sub meshes
  40956. */
  40957. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40958. private _tempRay;
  40959. /**
  40960. * Return the list of sub meshes intersecting with a given local ray
  40961. * @param mesh defines the mesh to find the submesh for
  40962. * @param localRay defines the ray in local space
  40963. * @returns the list of intersecting sub meshes
  40964. */
  40965. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40966. /**
  40967. * Return the list of sub meshes colliding with a collider
  40968. * @param mesh defines the mesh to find the submesh for
  40969. * @param collider defines the collider to evaluate the collision against
  40970. * @returns the list of colliding sub meshes
  40971. */
  40972. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40973. /**
  40974. * Rebuilds the elements related to this component in case of
  40975. * context lost for instance.
  40976. */
  40977. rebuild(): void;
  40978. /**
  40979. * Disposes the component and the associated ressources.
  40980. */
  40981. dispose(): void;
  40982. }
  40983. }
  40984. declare module "babylonjs/Culling/Octrees/index" {
  40985. export * from "babylonjs/Culling/Octrees/octree";
  40986. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40987. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40988. }
  40989. declare module "babylonjs/Culling/index" {
  40990. export * from "babylonjs/Culling/boundingBox";
  40991. export * from "babylonjs/Culling/boundingInfo";
  40992. export * from "babylonjs/Culling/boundingSphere";
  40993. export * from "babylonjs/Culling/Octrees/index";
  40994. export * from "babylonjs/Culling/ray";
  40995. }
  40996. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40997. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40998. import { Nullable } from "babylonjs/types";
  40999. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41000. import { Scene } from "babylonjs/scene";
  41001. /**
  41002. * Class containing static functions to help procedurally build meshes
  41003. */
  41004. export class LinesBuilder {
  41005. /**
  41006. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41007. * * 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
  41008. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41009. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41010. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41011. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41012. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41013. * * 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
  41014. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41017. * @param name defines the name of the new line system
  41018. * @param options defines the options used to create the line system
  41019. * @param scene defines the hosting scene
  41020. * @returns a new line system mesh
  41021. */
  41022. static CreateLineSystem(name: string, options: {
  41023. lines: Vector3[][];
  41024. updatable?: boolean;
  41025. instance?: Nullable<LinesMesh>;
  41026. colors?: Nullable<Color4[][]>;
  41027. useVertexAlpha?: boolean;
  41028. }, scene: Nullable<Scene>): LinesMesh;
  41029. /**
  41030. * Creates a line mesh
  41031. * 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
  41032. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41033. * * The parameter `points` is an array successive Vector3
  41034. * * 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
  41035. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41036. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41037. * * When updating an instance, remember that only point positions can change, not the number of points
  41038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41040. * @param name defines the name of the new line system
  41041. * @param options defines the options used to create the line system
  41042. * @param scene defines the hosting scene
  41043. * @returns a new line mesh
  41044. */
  41045. static CreateLines(name: string, options: {
  41046. points: Vector3[];
  41047. updatable?: boolean;
  41048. instance?: Nullable<LinesMesh>;
  41049. colors?: Color4[];
  41050. useVertexAlpha?: boolean;
  41051. }, scene?: Nullable<Scene>): LinesMesh;
  41052. /**
  41053. * Creates a dashed line mesh
  41054. * * 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
  41055. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41056. * * The parameter `points` is an array successive Vector3
  41057. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41058. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41059. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41060. * * 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
  41061. * * When updating an instance, remember that only point positions can change, not the number of points
  41062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41063. * @param name defines the name of the mesh
  41064. * @param options defines the options used to create the mesh
  41065. * @param scene defines the hosting scene
  41066. * @returns the dashed line mesh
  41067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41068. */
  41069. static CreateDashedLines(name: string, options: {
  41070. points: Vector3[];
  41071. dashSize?: number;
  41072. gapSize?: number;
  41073. dashNb?: number;
  41074. updatable?: boolean;
  41075. instance?: LinesMesh;
  41076. }, scene?: Nullable<Scene>): LinesMesh;
  41077. }
  41078. }
  41079. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41080. import { IDisposable, Scene } from "babylonjs/scene";
  41081. import { Nullable } from "babylonjs/types";
  41082. import { Observable } from "babylonjs/Misc/observable";
  41083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41084. /**
  41085. * Renders a layer on top of an existing scene
  41086. */
  41087. export class UtilityLayerRenderer implements IDisposable {
  41088. /** the original scene that will be rendered on top of */
  41089. originalScene: Scene;
  41090. private _pointerCaptures;
  41091. private _lastPointerEvents;
  41092. private static _DefaultUtilityLayer;
  41093. private static _DefaultKeepDepthUtilityLayer;
  41094. /**
  41095. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41096. */
  41097. pickUtilitySceneFirst: boolean;
  41098. /**
  41099. * 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)
  41100. */
  41101. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41102. /**
  41103. * 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)
  41104. */
  41105. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41106. /**
  41107. * The scene that is rendered on top of the original scene
  41108. */
  41109. utilityLayerScene: Scene;
  41110. /**
  41111. * If the utility layer should automatically be rendered on top of existing scene
  41112. */
  41113. shouldRender: boolean;
  41114. /**
  41115. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41116. */
  41117. onlyCheckPointerDownEvents: boolean;
  41118. /**
  41119. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41120. */
  41121. processAllEvents: boolean;
  41122. /**
  41123. * Observable raised when the pointer move from the utility layer scene to the main scene
  41124. */
  41125. onPointerOutObservable: Observable<number>;
  41126. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41127. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41128. private _afterRenderObserver;
  41129. private _sceneDisposeObserver;
  41130. private _originalPointerObserver;
  41131. /**
  41132. * Instantiates a UtilityLayerRenderer
  41133. * @param originalScene the original scene that will be rendered on top of
  41134. * @param handleEvents boolean indicating if the utility layer should handle events
  41135. */
  41136. constructor(
  41137. /** the original scene that will be rendered on top of */
  41138. originalScene: Scene, handleEvents?: boolean);
  41139. private _notifyObservers;
  41140. /**
  41141. * Renders the utility layers scene on top of the original scene
  41142. */
  41143. render(): void;
  41144. /**
  41145. * Disposes of the renderer
  41146. */
  41147. dispose(): void;
  41148. private _updateCamera;
  41149. }
  41150. }
  41151. declare module "babylonjs/Gizmos/gizmo" {
  41152. import { Nullable } from "babylonjs/types";
  41153. import { IDisposable } from "babylonjs/scene";
  41154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41155. import { Mesh } from "babylonjs/Meshes/mesh";
  41156. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41157. /**
  41158. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41159. */
  41160. export class Gizmo implements IDisposable {
  41161. /** The utility layer the gizmo will be added to */
  41162. gizmoLayer: UtilityLayerRenderer;
  41163. /**
  41164. * The root mesh of the gizmo
  41165. */
  41166. _rootMesh: Mesh;
  41167. private _attachedMesh;
  41168. /**
  41169. * Ratio for the scale of the gizmo (Default: 1)
  41170. */
  41171. scaleRatio: number;
  41172. private _tmpMatrix;
  41173. /**
  41174. * If a custom mesh has been set (Default: false)
  41175. */
  41176. protected _customMeshSet: boolean;
  41177. /**
  41178. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41179. * * When set, interactions will be enabled
  41180. */
  41181. attachedMesh: Nullable<AbstractMesh>;
  41182. /**
  41183. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41184. * @param mesh The mesh to replace the default mesh of the gizmo
  41185. */
  41186. setCustomMesh(mesh: Mesh): void;
  41187. /**
  41188. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41189. */
  41190. updateGizmoRotationToMatchAttachedMesh: boolean;
  41191. /**
  41192. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41193. */
  41194. updateGizmoPositionToMatchAttachedMesh: boolean;
  41195. /**
  41196. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41197. */
  41198. protected _updateScale: boolean;
  41199. protected _interactionsEnabled: boolean;
  41200. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41201. private _beforeRenderObserver;
  41202. /**
  41203. * Creates a gizmo
  41204. * @param gizmoLayer The utility layer the gizmo will be added to
  41205. */
  41206. constructor(
  41207. /** The utility layer the gizmo will be added to */
  41208. gizmoLayer?: UtilityLayerRenderer);
  41209. private _tempVector;
  41210. /**
  41211. * @hidden
  41212. * Updates the gizmo to match the attached mesh's position/rotation
  41213. */
  41214. protected _update(): void;
  41215. /**
  41216. * Disposes of the gizmo
  41217. */
  41218. dispose(): void;
  41219. }
  41220. }
  41221. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41222. import { Observable } from "babylonjs/Misc/observable";
  41223. import { Nullable } from "babylonjs/types";
  41224. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41227. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41228. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41229. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41230. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41231. import { Scene } from "babylonjs/scene";
  41232. /**
  41233. * Single axis drag gizmo
  41234. */
  41235. export class AxisDragGizmo extends Gizmo {
  41236. /**
  41237. * Drag behavior responsible for the gizmos dragging interactions
  41238. */
  41239. dragBehavior: PointerDragBehavior;
  41240. private _pointerObserver;
  41241. /**
  41242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41243. */
  41244. snapDistance: number;
  41245. /**
  41246. * Event that fires each time the gizmo snaps to a new location.
  41247. * * snapDistance is the the change in distance
  41248. */
  41249. onSnapObservable: Observable<{
  41250. snapDistance: number;
  41251. }>;
  41252. /** @hidden */
  41253. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41254. /** @hidden */
  41255. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41256. /**
  41257. * Creates an AxisDragGizmo
  41258. * @param gizmoLayer The utility layer the gizmo will be added to
  41259. * @param dragAxis The axis which the gizmo will be able to drag on
  41260. * @param color The color of the gizmo
  41261. */
  41262. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41263. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41264. /**
  41265. * Disposes of the gizmo
  41266. */
  41267. dispose(): void;
  41268. }
  41269. }
  41270. declare module "babylonjs/Debug/axesViewer" {
  41271. import { Vector3 } from "babylonjs/Maths/math";
  41272. import { Nullable } from "babylonjs/types";
  41273. import { Scene } from "babylonjs/scene";
  41274. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41275. /**
  41276. * The Axes viewer will show 3 axes in a specific point in space
  41277. */
  41278. export class AxesViewer {
  41279. private _xAxis;
  41280. private _yAxis;
  41281. private _zAxis;
  41282. private _scaleLinesFactor;
  41283. private _instanced;
  41284. /**
  41285. * Gets the hosting scene
  41286. */
  41287. scene: Scene;
  41288. /**
  41289. * Gets or sets a number used to scale line length
  41290. */
  41291. scaleLines: number;
  41292. /** Gets the node hierarchy used to render x-axis */
  41293. readonly xAxis: TransformNode;
  41294. /** Gets the node hierarchy used to render y-axis */
  41295. readonly yAxis: TransformNode;
  41296. /** Gets the node hierarchy used to render z-axis */
  41297. readonly zAxis: TransformNode;
  41298. /**
  41299. * Creates a new AxesViewer
  41300. * @param scene defines the hosting scene
  41301. * @param scaleLines defines a number used to scale line length (1 by default)
  41302. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41303. * @param xAxis defines the node hierarchy used to render the x-axis
  41304. * @param yAxis defines the node hierarchy used to render the y-axis
  41305. * @param zAxis defines the node hierarchy used to render the z-axis
  41306. */
  41307. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41308. /**
  41309. * Force the viewer to update
  41310. * @param position defines the position of the viewer
  41311. * @param xaxis defines the x axis of the viewer
  41312. * @param yaxis defines the y axis of the viewer
  41313. * @param zaxis defines the z axis of the viewer
  41314. */
  41315. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41316. /**
  41317. * Creates an instance of this axes viewer.
  41318. * @returns a new axes viewer with instanced meshes
  41319. */
  41320. createInstance(): AxesViewer;
  41321. /** Releases resources */
  41322. dispose(): void;
  41323. private static _SetRenderingGroupId;
  41324. }
  41325. }
  41326. declare module "babylonjs/Debug/boneAxesViewer" {
  41327. import { Nullable } from "babylonjs/types";
  41328. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41329. import { Vector3 } from "babylonjs/Maths/math";
  41330. import { Mesh } from "babylonjs/Meshes/mesh";
  41331. import { Bone } from "babylonjs/Bones/bone";
  41332. import { Scene } from "babylonjs/scene";
  41333. /**
  41334. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41335. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41336. */
  41337. export class BoneAxesViewer extends AxesViewer {
  41338. /**
  41339. * Gets or sets the target mesh where to display the axes viewer
  41340. */
  41341. mesh: Nullable<Mesh>;
  41342. /**
  41343. * Gets or sets the target bone where to display the axes viewer
  41344. */
  41345. bone: Nullable<Bone>;
  41346. /** Gets current position */
  41347. pos: Vector3;
  41348. /** Gets direction of X axis */
  41349. xaxis: Vector3;
  41350. /** Gets direction of Y axis */
  41351. yaxis: Vector3;
  41352. /** Gets direction of Z axis */
  41353. zaxis: Vector3;
  41354. /**
  41355. * Creates a new BoneAxesViewer
  41356. * @param scene defines the hosting scene
  41357. * @param bone defines the target bone
  41358. * @param mesh defines the target mesh
  41359. * @param scaleLines defines a scaling factor for line length (1 by default)
  41360. */
  41361. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41362. /**
  41363. * Force the viewer to update
  41364. */
  41365. update(): void;
  41366. /** Releases resources */
  41367. dispose(): void;
  41368. }
  41369. }
  41370. declare module "babylonjs/Debug/debugLayer" {
  41371. import { Observable } from "babylonjs/Misc/observable";
  41372. import { Scene } from "babylonjs/scene";
  41373. /**
  41374. * Interface used to define scene explorer extensibility option
  41375. */
  41376. export interface IExplorerExtensibilityOption {
  41377. /**
  41378. * Define the option label
  41379. */
  41380. label: string;
  41381. /**
  41382. * Defines the action to execute on click
  41383. */
  41384. action: (entity: any) => void;
  41385. }
  41386. /**
  41387. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41388. */
  41389. export interface IExplorerExtensibilityGroup {
  41390. /**
  41391. * Defines a predicate to test if a given type mut be extended
  41392. */
  41393. predicate: (entity: any) => boolean;
  41394. /**
  41395. * Gets the list of options added to a type
  41396. */
  41397. entries: IExplorerExtensibilityOption[];
  41398. }
  41399. /**
  41400. * Interface used to define the options to use to create the Inspector
  41401. */
  41402. export interface IInspectorOptions {
  41403. /**
  41404. * Display in overlay mode (default: false)
  41405. */
  41406. overlay?: boolean;
  41407. /**
  41408. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41409. */
  41410. globalRoot?: HTMLElement;
  41411. /**
  41412. * Display the Scene explorer
  41413. */
  41414. showExplorer?: boolean;
  41415. /**
  41416. * Display the property inspector
  41417. */
  41418. showInspector?: boolean;
  41419. /**
  41420. * Display in embed mode (both panes on the right)
  41421. */
  41422. embedMode?: boolean;
  41423. /**
  41424. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41425. */
  41426. handleResize?: boolean;
  41427. /**
  41428. * Allow the panes to popup (default: true)
  41429. */
  41430. enablePopup?: boolean;
  41431. /**
  41432. * Allow the panes to be closed by users (default: true)
  41433. */
  41434. enableClose?: boolean;
  41435. /**
  41436. * Optional list of extensibility entries
  41437. */
  41438. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41439. /**
  41440. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41441. */
  41442. inspectorURL?: string;
  41443. }
  41444. module "babylonjs/scene" {
  41445. interface Scene {
  41446. /**
  41447. * @hidden
  41448. * Backing field
  41449. */
  41450. _debugLayer: DebugLayer;
  41451. /**
  41452. * Gets the debug layer (aka Inspector) associated with the scene
  41453. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41454. */
  41455. debugLayer: DebugLayer;
  41456. }
  41457. }
  41458. /**
  41459. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41460. * what is happening in your scene
  41461. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41462. */
  41463. export class DebugLayer {
  41464. /**
  41465. * Define the url to get the inspector script from.
  41466. * By default it uses the babylonjs CDN.
  41467. * @ignoreNaming
  41468. */
  41469. static InspectorURL: string;
  41470. private _scene;
  41471. private BJSINSPECTOR;
  41472. /**
  41473. * Observable triggered when a property is changed through the inspector.
  41474. */
  41475. onPropertyChangedObservable: Observable<{
  41476. object: any;
  41477. property: string;
  41478. value: any;
  41479. initialValue: any;
  41480. }>;
  41481. /**
  41482. * Instantiates a new debug layer.
  41483. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41484. * what is happening in your scene
  41485. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41486. * @param scene Defines the scene to inspect
  41487. */
  41488. constructor(scene: Scene);
  41489. /** Creates the inspector window. */
  41490. private _createInspector;
  41491. /**
  41492. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41493. * @param entity defines the entity to select
  41494. * @param lineContainerTitle defines the specific block to highlight
  41495. */
  41496. select(entity: any, lineContainerTitle?: string): void;
  41497. /** Get the inspector from bundle or global */
  41498. private _getGlobalInspector;
  41499. /**
  41500. * Get if the inspector is visible or not.
  41501. * @returns true if visible otherwise, false
  41502. */
  41503. isVisible(): boolean;
  41504. /**
  41505. * Hide the inspector and close its window.
  41506. */
  41507. hide(): void;
  41508. /**
  41509. * Launch the debugLayer.
  41510. * @param config Define the configuration of the inspector
  41511. * @return a promise fulfilled when the debug layer is visible
  41512. */
  41513. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41514. }
  41515. }
  41516. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41517. import { Nullable } from "babylonjs/types";
  41518. import { Scene } from "babylonjs/scene";
  41519. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41520. import { Mesh } from "babylonjs/Meshes/mesh";
  41521. /**
  41522. * Class containing static functions to help procedurally build meshes
  41523. */
  41524. export class BoxBuilder {
  41525. /**
  41526. * Creates a box mesh
  41527. * * The parameter `size` sets the size (float) of each box side (default 1)
  41528. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41529. * * 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)
  41530. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41534. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41535. * @param name defines the name of the mesh
  41536. * @param options defines the options used to create the mesh
  41537. * @param scene defines the hosting scene
  41538. * @returns the box mesh
  41539. */
  41540. static CreateBox(name: string, options: {
  41541. size?: number;
  41542. width?: number;
  41543. height?: number;
  41544. depth?: number;
  41545. faceUV?: Vector4[];
  41546. faceColors?: Color4[];
  41547. sideOrientation?: number;
  41548. frontUVs?: Vector4;
  41549. backUVs?: Vector4;
  41550. updatable?: boolean;
  41551. }, scene?: Nullable<Scene>): Mesh;
  41552. }
  41553. }
  41554. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41555. import { Vector4 } from "babylonjs/Maths/math";
  41556. import { Mesh } from "babylonjs/Meshes/mesh";
  41557. /**
  41558. * Class containing static functions to help procedurally build meshes
  41559. */
  41560. export class SphereBuilder {
  41561. /**
  41562. * Creates a sphere mesh
  41563. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41564. * * 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`)
  41565. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41566. * * 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
  41567. * * 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)
  41568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41571. * @param name defines the name of the mesh
  41572. * @param options defines the options used to create the mesh
  41573. * @param scene defines the hosting scene
  41574. * @returns the sphere mesh
  41575. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41576. */
  41577. static CreateSphere(name: string, options: {
  41578. segments?: number;
  41579. diameter?: number;
  41580. diameterX?: number;
  41581. diameterY?: number;
  41582. diameterZ?: number;
  41583. arc?: number;
  41584. slice?: number;
  41585. sideOrientation?: number;
  41586. frontUVs?: Vector4;
  41587. backUVs?: Vector4;
  41588. updatable?: boolean;
  41589. }, scene: any): Mesh;
  41590. }
  41591. }
  41592. declare module "babylonjs/Debug/physicsViewer" {
  41593. import { Nullable } from "babylonjs/types";
  41594. import { Scene } from "babylonjs/scene";
  41595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41596. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41597. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41598. /**
  41599. * Used to show the physics impostor around the specific mesh
  41600. */
  41601. export class PhysicsViewer {
  41602. /** @hidden */
  41603. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41604. /** @hidden */
  41605. protected _meshes: Array<Nullable<AbstractMesh>>;
  41606. /** @hidden */
  41607. protected _scene: Nullable<Scene>;
  41608. /** @hidden */
  41609. protected _numMeshes: number;
  41610. /** @hidden */
  41611. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41612. private _renderFunction;
  41613. private _utilityLayer;
  41614. private _debugBoxMesh;
  41615. private _debugSphereMesh;
  41616. private _debugMaterial;
  41617. /**
  41618. * Creates a new PhysicsViewer
  41619. * @param scene defines the hosting scene
  41620. */
  41621. constructor(scene: Scene);
  41622. /** @hidden */
  41623. protected _updateDebugMeshes(): void;
  41624. /**
  41625. * Renders a specified physic impostor
  41626. * @param impostor defines the impostor to render
  41627. * @returns the new debug mesh used to render the impostor
  41628. */
  41629. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41630. /**
  41631. * Hides a specified physic impostor
  41632. * @param impostor defines the impostor to hide
  41633. */
  41634. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41635. private _getDebugMaterial;
  41636. private _getDebugBoxMesh;
  41637. private _getDebugSphereMesh;
  41638. private _getDebugMesh;
  41639. /** Releases all resources */
  41640. dispose(): void;
  41641. }
  41642. }
  41643. declare module "babylonjs/Debug/rayHelper" {
  41644. import { Nullable } from "babylonjs/types";
  41645. import { Ray } from "babylonjs/Culling/ray";
  41646. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41647. import { Scene } from "babylonjs/scene";
  41648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41649. import "babylonjs/Meshes/Builders/linesBuilder";
  41650. /**
  41651. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41652. * in order to better appreciate the issue one might have.
  41653. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41654. */
  41655. export class RayHelper {
  41656. /**
  41657. * Defines the ray we are currently tryin to visualize.
  41658. */
  41659. ray: Nullable<Ray>;
  41660. private _renderPoints;
  41661. private _renderLine;
  41662. private _renderFunction;
  41663. private _scene;
  41664. private _updateToMeshFunction;
  41665. private _attachedToMesh;
  41666. private _meshSpaceDirection;
  41667. private _meshSpaceOrigin;
  41668. /**
  41669. * Helper function to create a colored helper in a scene in one line.
  41670. * @param ray Defines the ray we are currently tryin to visualize
  41671. * @param scene Defines the scene the ray is used in
  41672. * @param color Defines the color we want to see the ray in
  41673. * @returns The newly created ray helper.
  41674. */
  41675. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41676. /**
  41677. * Instantiate a new ray helper.
  41678. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41679. * in order to better appreciate the issue one might have.
  41680. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41681. * @param ray Defines the ray we are currently tryin to visualize
  41682. */
  41683. constructor(ray: Ray);
  41684. /**
  41685. * Shows the ray we are willing to debug.
  41686. * @param scene Defines the scene the ray needs to be rendered in
  41687. * @param color Defines the color the ray needs to be rendered in
  41688. */
  41689. show(scene: Scene, color?: Color3): void;
  41690. /**
  41691. * Hides the ray we are debugging.
  41692. */
  41693. hide(): void;
  41694. private _render;
  41695. /**
  41696. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41697. * @param mesh Defines the mesh we want the helper attached to
  41698. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41699. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41700. * @param length Defines the length of the ray
  41701. */
  41702. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41703. /**
  41704. * Detach the ray helper from the mesh it has previously been attached to.
  41705. */
  41706. detachFromMesh(): void;
  41707. private _updateToMesh;
  41708. /**
  41709. * Dispose the helper and release its associated resources.
  41710. */
  41711. dispose(): void;
  41712. }
  41713. }
  41714. declare module "babylonjs/Debug/skeletonViewer" {
  41715. import { Color3 } from "babylonjs/Maths/math";
  41716. import { Scene } from "babylonjs/scene";
  41717. import { Nullable } from "babylonjs/types";
  41718. import { Skeleton } from "babylonjs/Bones/skeleton";
  41719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41720. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41721. /**
  41722. * Class used to render a debug view of a given skeleton
  41723. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41724. */
  41725. export class SkeletonViewer {
  41726. /** defines the skeleton to render */
  41727. skeleton: Skeleton;
  41728. /** defines the mesh attached to the skeleton */
  41729. mesh: AbstractMesh;
  41730. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41731. autoUpdateBonesMatrices: boolean;
  41732. /** defines the rendering group id to use with the viewer */
  41733. renderingGroupId: number;
  41734. /** Gets or sets the color used to render the skeleton */
  41735. color: Color3;
  41736. private _scene;
  41737. private _debugLines;
  41738. private _debugMesh;
  41739. private _isEnabled;
  41740. private _renderFunction;
  41741. private _utilityLayer;
  41742. /**
  41743. * Returns the mesh used to render the bones
  41744. */
  41745. readonly debugMesh: Nullable<LinesMesh>;
  41746. /**
  41747. * Creates a new SkeletonViewer
  41748. * @param skeleton defines the skeleton to render
  41749. * @param mesh defines the mesh attached to the skeleton
  41750. * @param scene defines the hosting scene
  41751. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41752. * @param renderingGroupId defines the rendering group id to use with the viewer
  41753. */
  41754. constructor(
  41755. /** defines the skeleton to render */
  41756. skeleton: Skeleton,
  41757. /** defines the mesh attached to the skeleton */
  41758. mesh: AbstractMesh, scene: Scene,
  41759. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41760. autoUpdateBonesMatrices?: boolean,
  41761. /** defines the rendering group id to use with the viewer */
  41762. renderingGroupId?: number);
  41763. /** Gets or sets a boolean indicating if the viewer is enabled */
  41764. isEnabled: boolean;
  41765. private _getBonePosition;
  41766. private _getLinesForBonesWithLength;
  41767. private _getLinesForBonesNoLength;
  41768. /** Update the viewer to sync with current skeleton state */
  41769. update(): void;
  41770. /** Release associated resources */
  41771. dispose(): void;
  41772. }
  41773. }
  41774. declare module "babylonjs/Debug/index" {
  41775. export * from "babylonjs/Debug/axesViewer";
  41776. export * from "babylonjs/Debug/boneAxesViewer";
  41777. export * from "babylonjs/Debug/debugLayer";
  41778. export * from "babylonjs/Debug/physicsViewer";
  41779. export * from "babylonjs/Debug/rayHelper";
  41780. export * from "babylonjs/Debug/skeletonViewer";
  41781. }
  41782. declare module "babylonjs/Engines/nullEngine" {
  41783. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41784. import { Scene } from "babylonjs/scene";
  41785. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41786. import { Engine } from "babylonjs/Engines/engine";
  41787. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41788. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41789. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41790. import { Effect } from "babylonjs/Materials/effect";
  41791. /**
  41792. * Options to create the null engine
  41793. */
  41794. export class NullEngineOptions {
  41795. /**
  41796. * Render width (Default: 512)
  41797. */
  41798. renderWidth: number;
  41799. /**
  41800. * Render height (Default: 256)
  41801. */
  41802. renderHeight: number;
  41803. /**
  41804. * Texture size (Default: 512)
  41805. */
  41806. textureSize: number;
  41807. /**
  41808. * If delta time between frames should be constant
  41809. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41810. */
  41811. deterministicLockstep: boolean;
  41812. /**
  41813. * Maximum about of steps between frames (Default: 4)
  41814. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41815. */
  41816. lockstepMaxSteps: number;
  41817. }
  41818. /**
  41819. * The null engine class provides support for headless version of babylon.js.
  41820. * This can be used in server side scenario or for testing purposes
  41821. */
  41822. export class NullEngine extends Engine {
  41823. private _options;
  41824. /**
  41825. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41826. */
  41827. isDeterministicLockStep(): boolean;
  41828. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41829. getLockstepMaxSteps(): number;
  41830. /**
  41831. * Sets hardware scaling, used to save performance if needed
  41832. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41833. */
  41834. getHardwareScalingLevel(): number;
  41835. constructor(options?: NullEngineOptions);
  41836. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41837. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41838. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41839. getRenderWidth(useScreen?: boolean): number;
  41840. getRenderHeight(useScreen?: boolean): number;
  41841. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41842. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41843. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41844. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41845. bindSamplers(effect: Effect): void;
  41846. enableEffect(effect: Effect): void;
  41847. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41848. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41849. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41850. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41851. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41852. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41853. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41854. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41855. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41856. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41857. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41858. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41859. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41860. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41861. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41862. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41863. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41864. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41865. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41866. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41867. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41868. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41869. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41870. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41871. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41872. bindBuffers(vertexBuffers: {
  41873. [key: string]: VertexBuffer;
  41874. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41875. wipeCaches(bruteForce?: boolean): void;
  41876. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41877. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41878. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41879. /** @hidden */
  41880. _createTexture(): WebGLTexture;
  41881. /** @hidden */
  41882. _releaseTexture(texture: InternalTexture): void;
  41883. 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;
  41884. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41885. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41886. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41887. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41888. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41889. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41890. areAllEffectsReady(): boolean;
  41891. /**
  41892. * @hidden
  41893. * Get the current error code of the webGL context
  41894. * @returns the error code
  41895. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41896. */
  41897. getError(): number;
  41898. /** @hidden */
  41899. _getUnpackAlignement(): number;
  41900. /** @hidden */
  41901. _unpackFlipY(value: boolean): void;
  41902. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41903. /**
  41904. * Updates a dynamic vertex buffer.
  41905. * @param vertexBuffer the vertex buffer to update
  41906. * @param data the data used to update the vertex buffer
  41907. * @param byteOffset the byte offset of the data (optional)
  41908. * @param byteLength the byte length of the data (optional)
  41909. */
  41910. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41911. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41912. /** @hidden */
  41913. _bindTexture(channel: number, texture: InternalTexture): void;
  41914. /** @hidden */
  41915. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41916. releaseEffects(): void;
  41917. displayLoadingUI(): void;
  41918. hideLoadingUI(): void;
  41919. /** @hidden */
  41920. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41921. /** @hidden */
  41922. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41923. /** @hidden */
  41924. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41925. /** @hidden */
  41926. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41927. }
  41928. }
  41929. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41930. import { Nullable, int } from "babylonjs/types";
  41931. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41932. /** @hidden */
  41933. export class _OcclusionDataStorage {
  41934. /** @hidden */
  41935. occlusionInternalRetryCounter: number;
  41936. /** @hidden */
  41937. isOcclusionQueryInProgress: boolean;
  41938. /** @hidden */
  41939. isOccluded: boolean;
  41940. /** @hidden */
  41941. occlusionRetryCount: number;
  41942. /** @hidden */
  41943. occlusionType: number;
  41944. /** @hidden */
  41945. occlusionQueryAlgorithmType: number;
  41946. }
  41947. module "babylonjs/Engines/engine" {
  41948. interface Engine {
  41949. /**
  41950. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41951. * @return the new query
  41952. */
  41953. createQuery(): WebGLQuery;
  41954. /**
  41955. * Delete and release a webGL query
  41956. * @param query defines the query to delete
  41957. * @return the current engine
  41958. */
  41959. deleteQuery(query: WebGLQuery): Engine;
  41960. /**
  41961. * Check if a given query has resolved and got its value
  41962. * @param query defines the query to check
  41963. * @returns true if the query got its value
  41964. */
  41965. isQueryResultAvailable(query: WebGLQuery): boolean;
  41966. /**
  41967. * Gets the value of a given query
  41968. * @param query defines the query to check
  41969. * @returns the value of the query
  41970. */
  41971. getQueryResult(query: WebGLQuery): number;
  41972. /**
  41973. * Initiates an occlusion query
  41974. * @param algorithmType defines the algorithm to use
  41975. * @param query defines the query to use
  41976. * @returns the current engine
  41977. * @see http://doc.babylonjs.com/features/occlusionquery
  41978. */
  41979. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41980. /**
  41981. * Ends an occlusion query
  41982. * @see http://doc.babylonjs.com/features/occlusionquery
  41983. * @param algorithmType defines the algorithm to use
  41984. * @returns the current engine
  41985. */
  41986. endOcclusionQuery(algorithmType: number): Engine;
  41987. /**
  41988. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41989. * Please note that only one query can be issued at a time
  41990. * @returns a time token used to track the time span
  41991. */
  41992. startTimeQuery(): Nullable<_TimeToken>;
  41993. /**
  41994. * Ends a time query
  41995. * @param token defines the token used to measure the time span
  41996. * @returns the time spent (in ns)
  41997. */
  41998. endTimeQuery(token: _TimeToken): int;
  41999. /** @hidden */
  42000. _currentNonTimestampToken: Nullable<_TimeToken>;
  42001. /** @hidden */
  42002. _createTimeQuery(): WebGLQuery;
  42003. /** @hidden */
  42004. _deleteTimeQuery(query: WebGLQuery): void;
  42005. /** @hidden */
  42006. _getGlAlgorithmType(algorithmType: number): number;
  42007. /** @hidden */
  42008. _getTimeQueryResult(query: WebGLQuery): any;
  42009. /** @hidden */
  42010. _getTimeQueryAvailability(query: WebGLQuery): any;
  42011. }
  42012. }
  42013. module "babylonjs/Meshes/abstractMesh" {
  42014. interface AbstractMesh {
  42015. /**
  42016. * Backing filed
  42017. * @hidden
  42018. */
  42019. __occlusionDataStorage: _OcclusionDataStorage;
  42020. /**
  42021. * Access property
  42022. * @hidden
  42023. */
  42024. _occlusionDataStorage: _OcclusionDataStorage;
  42025. /**
  42026. * 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.
  42027. * The default value is -1 which means don't break the query and wait till the result
  42028. * @see http://doc.babylonjs.com/features/occlusionquery
  42029. */
  42030. occlusionRetryCount: number;
  42031. /**
  42032. * 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:
  42033. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42034. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42035. * * 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.
  42036. * @see http://doc.babylonjs.com/features/occlusionquery
  42037. */
  42038. occlusionType: number;
  42039. /**
  42040. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42041. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42042. * * 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.
  42043. * @see http://doc.babylonjs.com/features/occlusionquery
  42044. */
  42045. occlusionQueryAlgorithmType: number;
  42046. /**
  42047. * 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
  42048. * @see http://doc.babylonjs.com/features/occlusionquery
  42049. */
  42050. isOccluded: boolean;
  42051. /**
  42052. * Flag to check the progress status of the query
  42053. * @see http://doc.babylonjs.com/features/occlusionquery
  42054. */
  42055. isOcclusionQueryInProgress: boolean;
  42056. }
  42057. }
  42058. }
  42059. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42060. import { Nullable } from "babylonjs/types";
  42061. /** @hidden */
  42062. export var _forceTransformFeedbackToBundle: boolean;
  42063. module "babylonjs/Engines/engine" {
  42064. interface Engine {
  42065. /**
  42066. * Creates a webGL transform feedback object
  42067. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42068. * @returns the webGL transform feedback object
  42069. */
  42070. createTransformFeedback(): WebGLTransformFeedback;
  42071. /**
  42072. * Delete a webGL transform feedback object
  42073. * @param value defines the webGL transform feedback object to delete
  42074. */
  42075. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42076. /**
  42077. * Bind a webGL transform feedback object to the webgl context
  42078. * @param value defines the webGL transform feedback object to bind
  42079. */
  42080. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42081. /**
  42082. * Begins a transform feedback operation
  42083. * @param usePoints defines if points or triangles must be used
  42084. */
  42085. beginTransformFeedback(usePoints: boolean): void;
  42086. /**
  42087. * Ends a transform feedback operation
  42088. */
  42089. endTransformFeedback(): void;
  42090. /**
  42091. * Specify the varyings to use with transform feedback
  42092. * @param program defines the associated webGL program
  42093. * @param value defines the list of strings representing the varying names
  42094. */
  42095. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42096. /**
  42097. * Bind a webGL buffer for a transform feedback operation
  42098. * @param value defines the webGL buffer to bind
  42099. */
  42100. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42101. }
  42102. }
  42103. }
  42104. declare module "babylonjs/Engines/Extensions/index" {
  42105. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42106. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42107. }
  42108. declare module "babylonjs/Engines/index" {
  42109. export * from "babylonjs/Engines/constants";
  42110. export * from "babylonjs/Engines/engine";
  42111. export * from "babylonjs/Engines/engineStore";
  42112. export * from "babylonjs/Engines/nullEngine";
  42113. export * from "babylonjs/Engines/Extensions/index";
  42114. }
  42115. declare module "babylonjs/Events/clipboardEvents" {
  42116. /**
  42117. * Gather the list of clipboard event types as constants.
  42118. */
  42119. export class ClipboardEventTypes {
  42120. /**
  42121. * The clipboard event is fired when a copy command is active (pressed).
  42122. */
  42123. static readonly COPY: number;
  42124. /**
  42125. * The clipboard event is fired when a cut command is active (pressed).
  42126. */
  42127. static readonly CUT: number;
  42128. /**
  42129. * The clipboard event is fired when a paste command is active (pressed).
  42130. */
  42131. static readonly PASTE: number;
  42132. }
  42133. /**
  42134. * This class is used to store clipboard related info for the onClipboardObservable event.
  42135. */
  42136. export class ClipboardInfo {
  42137. /**
  42138. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42139. */
  42140. type: number;
  42141. /**
  42142. * Defines the related dom event
  42143. */
  42144. event: ClipboardEvent;
  42145. /**
  42146. *Creates an instance of ClipboardInfo.
  42147. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42148. * @param event Defines the related dom event
  42149. */
  42150. constructor(
  42151. /**
  42152. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42153. */
  42154. type: number,
  42155. /**
  42156. * Defines the related dom event
  42157. */
  42158. event: ClipboardEvent);
  42159. /**
  42160. * Get the clipboard event's type from the keycode.
  42161. * @param keyCode Defines the keyCode for the current keyboard event.
  42162. * @return {number}
  42163. */
  42164. static GetTypeFromCharacter(keyCode: number): number;
  42165. }
  42166. }
  42167. declare module "babylonjs/Events/index" {
  42168. export * from "babylonjs/Events/keyboardEvents";
  42169. export * from "babylonjs/Events/pointerEvents";
  42170. export * from "babylonjs/Events/clipboardEvents";
  42171. }
  42172. declare module "babylonjs/Loading/sceneLoader" {
  42173. import { Observable } from "babylonjs/Misc/observable";
  42174. import { Nullable } from "babylonjs/types";
  42175. import { Scene } from "babylonjs/scene";
  42176. import { Engine } from "babylonjs/Engines/engine";
  42177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42178. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42179. import { AssetContainer } from "babylonjs/assetContainer";
  42180. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42181. import { Skeleton } from "babylonjs/Bones/skeleton";
  42182. /**
  42183. * Class used to represent data loading progression
  42184. */
  42185. export class SceneLoaderProgressEvent {
  42186. /** defines if data length to load can be evaluated */
  42187. readonly lengthComputable: boolean;
  42188. /** defines the loaded data length */
  42189. readonly loaded: number;
  42190. /** defines the data length to load */
  42191. readonly total: number;
  42192. /**
  42193. * Create a new progress event
  42194. * @param lengthComputable defines if data length to load can be evaluated
  42195. * @param loaded defines the loaded data length
  42196. * @param total defines the data length to load
  42197. */
  42198. constructor(
  42199. /** defines if data length to load can be evaluated */
  42200. lengthComputable: boolean,
  42201. /** defines the loaded data length */
  42202. loaded: number,
  42203. /** defines the data length to load */
  42204. total: number);
  42205. /**
  42206. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42207. * @param event defines the source event
  42208. * @returns a new SceneLoaderProgressEvent
  42209. */
  42210. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42211. }
  42212. /**
  42213. * Interface used by SceneLoader plugins to define supported file extensions
  42214. */
  42215. export interface ISceneLoaderPluginExtensions {
  42216. /**
  42217. * Defines the list of supported extensions
  42218. */
  42219. [extension: string]: {
  42220. isBinary: boolean;
  42221. };
  42222. }
  42223. /**
  42224. * Interface used by SceneLoader plugin factory
  42225. */
  42226. export interface ISceneLoaderPluginFactory {
  42227. /**
  42228. * Defines the name of the factory
  42229. */
  42230. name: string;
  42231. /**
  42232. * Function called to create a new plugin
  42233. * @return the new plugin
  42234. */
  42235. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42236. /**
  42237. * Boolean indicating if the plugin can direct load specific data
  42238. */
  42239. canDirectLoad?: (data: string) => boolean;
  42240. }
  42241. /**
  42242. * Interface used to define a SceneLoader plugin
  42243. */
  42244. export interface ISceneLoaderPlugin {
  42245. /**
  42246. * The friendly name of this plugin.
  42247. */
  42248. name: string;
  42249. /**
  42250. * The file extensions supported by this plugin.
  42251. */
  42252. extensions: string | ISceneLoaderPluginExtensions;
  42253. /**
  42254. * Import meshes into a scene.
  42255. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42256. * @param scene The scene to import into
  42257. * @param data The data to import
  42258. * @param rootUrl The root url for scene and resources
  42259. * @param meshes The meshes array to import into
  42260. * @param particleSystems The particle systems array to import into
  42261. * @param skeletons The skeletons array to import into
  42262. * @param onError The callback when import fails
  42263. * @returns True if successful or false otherwise
  42264. */
  42265. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42266. /**
  42267. * Load into a scene.
  42268. * @param scene The scene to load into
  42269. * @param data The data to import
  42270. * @param rootUrl The root url for scene and resources
  42271. * @param onError The callback when import fails
  42272. * @returns true if successful or false otherwise
  42273. */
  42274. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42275. /**
  42276. * The callback that returns true if the data can be directly loaded.
  42277. */
  42278. canDirectLoad?: (data: string) => boolean;
  42279. /**
  42280. * The callback that allows custom handling of the root url based on the response url.
  42281. */
  42282. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42283. /**
  42284. * Load into an asset container.
  42285. * @param scene The scene to load into
  42286. * @param data The data to import
  42287. * @param rootUrl The root url for scene and resources
  42288. * @param onError The callback when import fails
  42289. * @returns The loaded asset container
  42290. */
  42291. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42292. }
  42293. /**
  42294. * Interface used to define an async SceneLoader plugin
  42295. */
  42296. export interface ISceneLoaderPluginAsync {
  42297. /**
  42298. * The friendly name of this plugin.
  42299. */
  42300. name: string;
  42301. /**
  42302. * The file extensions supported by this plugin.
  42303. */
  42304. extensions: string | ISceneLoaderPluginExtensions;
  42305. /**
  42306. * Import meshes into a scene.
  42307. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42308. * @param scene The scene to import into
  42309. * @param data The data to import
  42310. * @param rootUrl The root url for scene and resources
  42311. * @param onProgress The callback when the load progresses
  42312. * @param fileName Defines the name of the file to load
  42313. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42314. */
  42315. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42316. meshes: AbstractMesh[];
  42317. particleSystems: IParticleSystem[];
  42318. skeletons: Skeleton[];
  42319. animationGroups: AnimationGroup[];
  42320. }>;
  42321. /**
  42322. * Load into a scene.
  42323. * @param scene The scene to load into
  42324. * @param data The data to import
  42325. * @param rootUrl The root url for scene and resources
  42326. * @param onProgress The callback when the load progresses
  42327. * @param fileName Defines the name of the file to load
  42328. * @returns Nothing
  42329. */
  42330. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42331. /**
  42332. * The callback that returns true if the data can be directly loaded.
  42333. */
  42334. canDirectLoad?: (data: string) => boolean;
  42335. /**
  42336. * The callback that allows custom handling of the root url based on the response url.
  42337. */
  42338. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42339. /**
  42340. * Load into an asset container.
  42341. * @param scene The scene to load into
  42342. * @param data The data to import
  42343. * @param rootUrl The root url for scene and resources
  42344. * @param onProgress The callback when the load progresses
  42345. * @param fileName Defines the name of the file to load
  42346. * @returns The loaded asset container
  42347. */
  42348. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42349. }
  42350. /**
  42351. * Class used to load scene from various file formats using registered plugins
  42352. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42353. */
  42354. export class SceneLoader {
  42355. /**
  42356. * No logging while loading
  42357. */
  42358. static readonly NO_LOGGING: number;
  42359. /**
  42360. * Minimal logging while loading
  42361. */
  42362. static readonly MINIMAL_LOGGING: number;
  42363. /**
  42364. * Summary logging while loading
  42365. */
  42366. static readonly SUMMARY_LOGGING: number;
  42367. /**
  42368. * Detailled logging while loading
  42369. */
  42370. static readonly DETAILED_LOGGING: number;
  42371. /**
  42372. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42373. */
  42374. static ForceFullSceneLoadingForIncremental: boolean;
  42375. /**
  42376. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42377. */
  42378. static ShowLoadingScreen: boolean;
  42379. /**
  42380. * Defines the current logging level (while loading the scene)
  42381. * @ignorenaming
  42382. */
  42383. static loggingLevel: number;
  42384. /**
  42385. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42386. */
  42387. static CleanBoneMatrixWeights: boolean;
  42388. /**
  42389. * Event raised when a plugin is used to load a scene
  42390. */
  42391. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42392. private static _registeredPlugins;
  42393. private static _getDefaultPlugin;
  42394. private static _getPluginForExtension;
  42395. private static _getPluginForDirectLoad;
  42396. private static _getPluginForFilename;
  42397. private static _getDirectLoad;
  42398. private static _loadData;
  42399. private static _getFileInfo;
  42400. /**
  42401. * Gets a plugin that can load the given extension
  42402. * @param extension defines the extension to load
  42403. * @returns a plugin or null if none works
  42404. */
  42405. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42406. /**
  42407. * Gets a boolean indicating that the given extension can be loaded
  42408. * @param extension defines the extension to load
  42409. * @returns true if the extension is supported
  42410. */
  42411. static IsPluginForExtensionAvailable(extension: string): boolean;
  42412. /**
  42413. * Adds a new plugin to the list of registered plugins
  42414. * @param plugin defines the plugin to add
  42415. */
  42416. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42417. /**
  42418. * Import meshes into a scene
  42419. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42420. * @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)
  42421. * @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)
  42422. * @param scene the instance of BABYLON.Scene to append to
  42423. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42424. * @param onProgress a callback with a progress event for each file being loaded
  42425. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42426. * @param pluginExtension the extension used to determine the plugin
  42427. * @returns The loaded plugin
  42428. */
  42429. 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>;
  42430. /**
  42431. * Import meshes into a scene
  42432. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42433. * @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)
  42434. * @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)
  42435. * @param scene the instance of BABYLON.Scene to append to
  42436. * @param onProgress a callback with a progress event for each file being loaded
  42437. * @param pluginExtension the extension used to determine the plugin
  42438. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42439. */
  42440. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42441. meshes: AbstractMesh[];
  42442. particleSystems: IParticleSystem[];
  42443. skeletons: Skeleton[];
  42444. animationGroups: AnimationGroup[];
  42445. }>;
  42446. /**
  42447. * Load a scene
  42448. * @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)
  42449. * @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)
  42450. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42451. * @param onSuccess a callback with the scene when import succeeds
  42452. * @param onProgress a callback with a progress event for each file being loaded
  42453. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42454. * @param pluginExtension the extension used to determine the plugin
  42455. * @returns The loaded plugin
  42456. */
  42457. 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>;
  42458. /**
  42459. * Load a scene
  42460. * @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)
  42461. * @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)
  42462. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42463. * @param onProgress a callback with a progress event for each file being loaded
  42464. * @param pluginExtension the extension used to determine the plugin
  42465. * @returns The loaded scene
  42466. */
  42467. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42468. /**
  42469. * Append a scene
  42470. * @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)
  42471. * @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)
  42472. * @param scene is the instance of BABYLON.Scene to append to
  42473. * @param onSuccess a callback with the scene when import succeeds
  42474. * @param onProgress a callback with a progress event for each file being loaded
  42475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42476. * @param pluginExtension the extension used to determine the plugin
  42477. * @returns The loaded plugin
  42478. */
  42479. 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>;
  42480. /**
  42481. * Append a scene
  42482. * @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)
  42483. * @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)
  42484. * @param scene is the instance of BABYLON.Scene to append to
  42485. * @param onProgress a callback with a progress event for each file being loaded
  42486. * @param pluginExtension the extension used to determine the plugin
  42487. * @returns The given scene
  42488. */
  42489. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42490. /**
  42491. * Load a scene into an asset container
  42492. * @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)
  42493. * @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)
  42494. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42495. * @param onSuccess a callback with the scene when import succeeds
  42496. * @param onProgress a callback with a progress event for each file being loaded
  42497. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42498. * @param pluginExtension the extension used to determine the plugin
  42499. * @returns The loaded plugin
  42500. */
  42501. 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>;
  42502. /**
  42503. * Load a scene into an asset container
  42504. * @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)
  42505. * @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)
  42506. * @param scene is the instance of Scene to append to
  42507. * @param onProgress a callback with a progress event for each file being loaded
  42508. * @param pluginExtension the extension used to determine the plugin
  42509. * @returns The loaded asset container
  42510. */
  42511. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42512. }
  42513. }
  42514. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42515. import { Scene } from "babylonjs/scene";
  42516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42517. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42518. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42519. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42520. /**
  42521. * Google Daydream controller
  42522. */
  42523. export class DaydreamController extends WebVRController {
  42524. /**
  42525. * Base Url for the controller model.
  42526. */
  42527. static MODEL_BASE_URL: string;
  42528. /**
  42529. * File name for the controller model.
  42530. */
  42531. static MODEL_FILENAME: string;
  42532. /**
  42533. * Gamepad Id prefix used to identify Daydream Controller.
  42534. */
  42535. static readonly GAMEPAD_ID_PREFIX: string;
  42536. /**
  42537. * Creates a new DaydreamController from a gamepad
  42538. * @param vrGamepad the gamepad that the controller should be created from
  42539. */
  42540. constructor(vrGamepad: any);
  42541. /**
  42542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42543. * @param scene scene in which to add meshes
  42544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42545. */
  42546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42547. /**
  42548. * Called once for each button that changed state since the last frame
  42549. * @param buttonIdx Which button index changed
  42550. * @param state New state of the button
  42551. * @param changes Which properties on the state changed since last frame
  42552. */
  42553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42554. }
  42555. }
  42556. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42557. import { Scene } from "babylonjs/scene";
  42558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42559. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42560. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42561. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42562. /**
  42563. * Gear VR Controller
  42564. */
  42565. export class GearVRController extends WebVRController {
  42566. /**
  42567. * Base Url for the controller model.
  42568. */
  42569. static MODEL_BASE_URL: string;
  42570. /**
  42571. * File name for the controller model.
  42572. */
  42573. static MODEL_FILENAME: string;
  42574. /**
  42575. * Gamepad Id prefix used to identify this controller.
  42576. */
  42577. static readonly GAMEPAD_ID_PREFIX: string;
  42578. private readonly _buttonIndexToObservableNameMap;
  42579. /**
  42580. * Creates a new GearVRController from a gamepad
  42581. * @param vrGamepad the gamepad that the controller should be created from
  42582. */
  42583. constructor(vrGamepad: any);
  42584. /**
  42585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42586. * @param scene scene in which to add meshes
  42587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42588. */
  42589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42590. /**
  42591. * Called once for each button that changed state since the last frame
  42592. * @param buttonIdx Which button index changed
  42593. * @param state New state of the button
  42594. * @param changes Which properties on the state changed since last frame
  42595. */
  42596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42597. }
  42598. }
  42599. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42600. import { Scene } from "babylonjs/scene";
  42601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42602. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42603. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42604. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42605. /**
  42606. * Generic Controller
  42607. */
  42608. export class GenericController extends WebVRController {
  42609. /**
  42610. * Base Url for the controller model.
  42611. */
  42612. static readonly MODEL_BASE_URL: string;
  42613. /**
  42614. * File name for the controller model.
  42615. */
  42616. static readonly MODEL_FILENAME: string;
  42617. /**
  42618. * Creates a new GenericController from a gamepad
  42619. * @param vrGamepad the gamepad that the controller should be created from
  42620. */
  42621. constructor(vrGamepad: any);
  42622. /**
  42623. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42624. * @param scene scene in which to add meshes
  42625. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42626. */
  42627. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42628. /**
  42629. * Called once for each button that changed state since the last frame
  42630. * @param buttonIdx Which button index changed
  42631. * @param state New state of the button
  42632. * @param changes Which properties on the state changed since last frame
  42633. */
  42634. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42635. }
  42636. }
  42637. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42638. import { Observable } from "babylonjs/Misc/observable";
  42639. import { Scene } from "babylonjs/scene";
  42640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42641. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42642. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42643. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42644. /**
  42645. * Oculus Touch Controller
  42646. */
  42647. export class OculusTouchController extends WebVRController {
  42648. /**
  42649. * Base Url for the controller model.
  42650. */
  42651. static MODEL_BASE_URL: string;
  42652. /**
  42653. * File name for the left controller model.
  42654. */
  42655. static MODEL_LEFT_FILENAME: string;
  42656. /**
  42657. * File name for the right controller model.
  42658. */
  42659. static MODEL_RIGHT_FILENAME: string;
  42660. /**
  42661. * Fired when the secondary trigger on this controller is modified
  42662. */
  42663. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42664. /**
  42665. * Fired when the thumb rest on this controller is modified
  42666. */
  42667. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42668. /**
  42669. * Creates a new OculusTouchController from a gamepad
  42670. * @param vrGamepad the gamepad that the controller should be created from
  42671. */
  42672. constructor(vrGamepad: any);
  42673. /**
  42674. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42675. * @param scene scene in which to add meshes
  42676. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42677. */
  42678. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42679. /**
  42680. * Fired when the A button on this controller is modified
  42681. */
  42682. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42683. /**
  42684. * Fired when the B button on this controller is modified
  42685. */
  42686. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42687. /**
  42688. * Fired when the X button on this controller is modified
  42689. */
  42690. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42691. /**
  42692. * Fired when the Y button on this controller is modified
  42693. */
  42694. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42695. /**
  42696. * Called once for each button that changed state since the last frame
  42697. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42698. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42699. * 2) secondary trigger (same)
  42700. * 3) A (right) X (left), touch, pressed = value
  42701. * 4) B / Y
  42702. * 5) thumb rest
  42703. * @param buttonIdx Which button index changed
  42704. * @param state New state of the button
  42705. * @param changes Which properties on the state changed since last frame
  42706. */
  42707. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42708. }
  42709. }
  42710. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42711. import { Scene } from "babylonjs/scene";
  42712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42713. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42714. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42715. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42716. import { Observable } from "babylonjs/Misc/observable";
  42717. /**
  42718. * Vive Controller
  42719. */
  42720. export class ViveController extends WebVRController {
  42721. /**
  42722. * Base Url for the controller model.
  42723. */
  42724. static MODEL_BASE_URL: string;
  42725. /**
  42726. * File name for the controller model.
  42727. */
  42728. static MODEL_FILENAME: string;
  42729. /**
  42730. * Creates a new ViveController from a gamepad
  42731. * @param vrGamepad the gamepad that the controller should be created from
  42732. */
  42733. constructor(vrGamepad: any);
  42734. /**
  42735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42736. * @param scene scene in which to add meshes
  42737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42738. */
  42739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42740. /**
  42741. * Fired when the left button on this controller is modified
  42742. */
  42743. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42744. /**
  42745. * Fired when the right button on this controller is modified
  42746. */
  42747. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42748. /**
  42749. * Fired when the menu button on this controller is modified
  42750. */
  42751. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42752. /**
  42753. * Called once for each button that changed state since the last frame
  42754. * Vive mapping:
  42755. * 0: touchpad
  42756. * 1: trigger
  42757. * 2: left AND right buttons
  42758. * 3: menu button
  42759. * @param buttonIdx Which button index changed
  42760. * @param state New state of the button
  42761. * @param changes Which properties on the state changed since last frame
  42762. */
  42763. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42764. }
  42765. }
  42766. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42767. import { Observable } from "babylonjs/Misc/observable";
  42768. import { Scene } from "babylonjs/scene";
  42769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42770. import { Ray } from "babylonjs/Culling/ray";
  42771. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42772. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42773. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42774. /**
  42775. * Defines the WindowsMotionController object that the state of the windows motion controller
  42776. */
  42777. export class WindowsMotionController extends WebVRController {
  42778. /**
  42779. * The base url used to load the left and right controller models
  42780. */
  42781. static MODEL_BASE_URL: string;
  42782. /**
  42783. * The name of the left controller model file
  42784. */
  42785. static MODEL_LEFT_FILENAME: string;
  42786. /**
  42787. * The name of the right controller model file
  42788. */
  42789. static MODEL_RIGHT_FILENAME: string;
  42790. /**
  42791. * The controller name prefix for this controller type
  42792. */
  42793. static readonly GAMEPAD_ID_PREFIX: string;
  42794. /**
  42795. * The controller id pattern for this controller type
  42796. */
  42797. private static readonly GAMEPAD_ID_PATTERN;
  42798. private _loadedMeshInfo;
  42799. private readonly _mapping;
  42800. /**
  42801. * Fired when the trackpad on this controller is clicked
  42802. */
  42803. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42804. /**
  42805. * Fired when the trackpad on this controller is modified
  42806. */
  42807. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42808. /**
  42809. * The current x and y values of this controller's trackpad
  42810. */
  42811. trackpad: StickValues;
  42812. /**
  42813. * Creates a new WindowsMotionController from a gamepad
  42814. * @param vrGamepad the gamepad that the controller should be created from
  42815. */
  42816. constructor(vrGamepad: any);
  42817. /**
  42818. * Fired when the trigger on this controller is modified
  42819. */
  42820. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42821. /**
  42822. * Fired when the menu button on this controller is modified
  42823. */
  42824. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42825. /**
  42826. * Fired when the grip button on this controller is modified
  42827. */
  42828. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42829. /**
  42830. * Fired when the thumbstick button on this controller is modified
  42831. */
  42832. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42833. /**
  42834. * Fired when the touchpad button on this controller is modified
  42835. */
  42836. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42837. /**
  42838. * Fired when the touchpad values on this controller are modified
  42839. */
  42840. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42841. private _updateTrackpad;
  42842. /**
  42843. * Called once per frame by the engine.
  42844. */
  42845. update(): void;
  42846. /**
  42847. * Called once for each button that changed state since the last frame
  42848. * @param buttonIdx Which button index changed
  42849. * @param state New state of the button
  42850. * @param changes Which properties on the state changed since last frame
  42851. */
  42852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42853. /**
  42854. * Moves the buttons on the controller mesh based on their current state
  42855. * @param buttonName the name of the button to move
  42856. * @param buttonValue the value of the button which determines the buttons new position
  42857. */
  42858. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42859. /**
  42860. * Moves the axis on the controller mesh based on its current state
  42861. * @param axis the index of the axis
  42862. * @param axisValue the value of the axis which determines the meshes new position
  42863. * @hidden
  42864. */
  42865. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42866. /**
  42867. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42868. * @param scene scene in which to add meshes
  42869. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42870. */
  42871. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42872. /**
  42873. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42874. * can be transformed by button presses and axes values, based on this._mapping.
  42875. *
  42876. * @param scene scene in which the meshes exist
  42877. * @param meshes list of meshes that make up the controller model to process
  42878. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42879. */
  42880. private processModel;
  42881. private createMeshInfo;
  42882. /**
  42883. * Gets the ray of the controller in the direction the controller is pointing
  42884. * @param length the length the resulting ray should be
  42885. * @returns a ray in the direction the controller is pointing
  42886. */
  42887. getForwardRay(length?: number): Ray;
  42888. /**
  42889. * Disposes of the controller
  42890. */
  42891. dispose(): void;
  42892. }
  42893. }
  42894. declare module "babylonjs/Gamepads/Controllers/index" {
  42895. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42896. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42897. export * from "babylonjs/Gamepads/Controllers/genericController";
  42898. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42899. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42900. export * from "babylonjs/Gamepads/Controllers/viveController";
  42901. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42902. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42903. }
  42904. declare module "babylonjs/Gamepads/index" {
  42905. export * from "babylonjs/Gamepads/Controllers/index";
  42906. export * from "babylonjs/Gamepads/gamepad";
  42907. export * from "babylonjs/Gamepads/gamepadManager";
  42908. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42909. export * from "babylonjs/Gamepads/xboxGamepad";
  42910. }
  42911. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42912. import { Observable } from "babylonjs/Misc/observable";
  42913. import { Nullable } from "babylonjs/types";
  42914. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42916. import { Mesh } from "babylonjs/Meshes/mesh";
  42917. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42918. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42919. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42920. /**
  42921. * Single axis scale gizmo
  42922. */
  42923. export class AxisScaleGizmo extends Gizmo {
  42924. private _coloredMaterial;
  42925. /**
  42926. * Drag behavior responsible for the gizmos dragging interactions
  42927. */
  42928. dragBehavior: PointerDragBehavior;
  42929. private _pointerObserver;
  42930. /**
  42931. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42932. */
  42933. snapDistance: number;
  42934. /**
  42935. * Event that fires each time the gizmo snaps to a new location.
  42936. * * snapDistance is the the change in distance
  42937. */
  42938. onSnapObservable: Observable<{
  42939. snapDistance: number;
  42940. }>;
  42941. /**
  42942. * If the scaling operation should be done on all axis (default: false)
  42943. */
  42944. uniformScaling: boolean;
  42945. /**
  42946. * Creates an AxisScaleGizmo
  42947. * @param gizmoLayer The utility layer the gizmo will be added to
  42948. * @param dragAxis The axis which the gizmo will be able to scale on
  42949. * @param color The color of the gizmo
  42950. */
  42951. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42952. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42953. /**
  42954. * Disposes of the gizmo
  42955. */
  42956. dispose(): void;
  42957. /**
  42958. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42959. * @param mesh The mesh to replace the default mesh of the gizmo
  42960. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42961. */
  42962. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42963. }
  42964. }
  42965. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42966. import { Observable } from "babylonjs/Misc/observable";
  42967. import { Nullable } from "babylonjs/types";
  42968. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42970. import { Mesh } from "babylonjs/Meshes/mesh";
  42971. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42972. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42973. import "babylonjs/Meshes/Builders/boxBuilder";
  42974. /**
  42975. * Bounding box gizmo
  42976. */
  42977. export class BoundingBoxGizmo extends Gizmo {
  42978. private _lineBoundingBox;
  42979. private _rotateSpheresParent;
  42980. private _scaleBoxesParent;
  42981. private _boundingDimensions;
  42982. private _renderObserver;
  42983. private _pointerObserver;
  42984. private _scaleDragSpeed;
  42985. private _tmpQuaternion;
  42986. private _tmpVector;
  42987. private _tmpRotationMatrix;
  42988. /**
  42989. * 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)
  42990. */
  42991. ignoreChildren: boolean;
  42992. /**
  42993. * 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)
  42994. */
  42995. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42996. /**
  42997. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42998. */
  42999. rotationSphereSize: number;
  43000. /**
  43001. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43002. */
  43003. scaleBoxSize: number;
  43004. /**
  43005. * 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)
  43006. */
  43007. fixedDragMeshScreenSize: boolean;
  43008. /**
  43009. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43010. */
  43011. fixedDragMeshScreenSizeDistanceFactor: number;
  43012. /**
  43013. * Fired when a rotation sphere or scale box is dragged
  43014. */
  43015. onDragStartObservable: Observable<{}>;
  43016. /**
  43017. * Fired when a scale box is dragged
  43018. */
  43019. onScaleBoxDragObservable: Observable<{}>;
  43020. /**
  43021. * Fired when a scale box drag is ended
  43022. */
  43023. onScaleBoxDragEndObservable: Observable<{}>;
  43024. /**
  43025. * Fired when a rotation sphere is dragged
  43026. */
  43027. onRotationSphereDragObservable: Observable<{}>;
  43028. /**
  43029. * Fired when a rotation sphere drag is ended
  43030. */
  43031. onRotationSphereDragEndObservable: Observable<{}>;
  43032. /**
  43033. * 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)
  43034. */
  43035. scalePivot: Nullable<Vector3>;
  43036. private _anchorMesh;
  43037. private _existingMeshScale;
  43038. private _dragMesh;
  43039. private pointerDragBehavior;
  43040. private coloredMaterial;
  43041. private hoverColoredMaterial;
  43042. /**
  43043. * Sets the color of the bounding box gizmo
  43044. * @param color the color to set
  43045. */
  43046. setColor(color: Color3): void;
  43047. /**
  43048. * Creates an BoundingBoxGizmo
  43049. * @param gizmoLayer The utility layer the gizmo will be added to
  43050. * @param color The color of the gizmo
  43051. */
  43052. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43053. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43054. private _selectNode;
  43055. /**
  43056. * Updates the bounding box information for the Gizmo
  43057. */
  43058. updateBoundingBox(): void;
  43059. private _updateRotationSpheres;
  43060. private _updateScaleBoxes;
  43061. /**
  43062. * Enables rotation on the specified axis and disables rotation on the others
  43063. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43064. */
  43065. setEnabledRotationAxis(axis: string): void;
  43066. /**
  43067. * Enables/disables scaling
  43068. * @param enable if scaling should be enabled
  43069. */
  43070. setEnabledScaling(enable: boolean): void;
  43071. private _updateDummy;
  43072. /**
  43073. * Enables a pointer drag behavior on the bounding box of the gizmo
  43074. */
  43075. enableDragBehavior(): void;
  43076. /**
  43077. * Disposes of the gizmo
  43078. */
  43079. dispose(): void;
  43080. /**
  43081. * 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)
  43082. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43083. * @returns the bounding box mesh with the passed in mesh as a child
  43084. */
  43085. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43086. /**
  43087. * CustomMeshes are not supported by this gizmo
  43088. * @param mesh The mesh to replace the default mesh of the gizmo
  43089. */
  43090. setCustomMesh(mesh: Mesh): void;
  43091. }
  43092. }
  43093. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43094. import { Observable } from "babylonjs/Misc/observable";
  43095. import { Nullable } from "babylonjs/types";
  43096. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43098. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43099. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43100. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43101. import "babylonjs/Meshes/Builders/linesBuilder";
  43102. /**
  43103. * Single plane rotation gizmo
  43104. */
  43105. export class PlaneRotationGizmo extends Gizmo {
  43106. /**
  43107. * Drag behavior responsible for the gizmos dragging interactions
  43108. */
  43109. dragBehavior: PointerDragBehavior;
  43110. private _pointerObserver;
  43111. /**
  43112. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43113. */
  43114. snapDistance: number;
  43115. /**
  43116. * Event that fires each time the gizmo snaps to a new location.
  43117. * * snapDistance is the the change in distance
  43118. */
  43119. onSnapObservable: Observable<{
  43120. snapDistance: number;
  43121. }>;
  43122. /**
  43123. * Creates a PlaneRotationGizmo
  43124. * @param gizmoLayer The utility layer the gizmo will be added to
  43125. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43126. * @param color The color of the gizmo
  43127. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43128. */
  43129. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43130. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43131. /**
  43132. * Disposes of the gizmo
  43133. */
  43134. dispose(): void;
  43135. }
  43136. }
  43137. declare module "babylonjs/Gizmos/rotationGizmo" {
  43138. import { Observable } from "babylonjs/Misc/observable";
  43139. import { Nullable } from "babylonjs/types";
  43140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43141. import { Mesh } from "babylonjs/Meshes/mesh";
  43142. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43143. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43144. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43145. /**
  43146. * Gizmo that enables rotating a mesh along 3 axis
  43147. */
  43148. export class RotationGizmo extends Gizmo {
  43149. /**
  43150. * Internal gizmo used for interactions on the x axis
  43151. */
  43152. xGizmo: PlaneRotationGizmo;
  43153. /**
  43154. * Internal gizmo used for interactions on the y axis
  43155. */
  43156. yGizmo: PlaneRotationGizmo;
  43157. /**
  43158. * Internal gizmo used for interactions on the z axis
  43159. */
  43160. zGizmo: PlaneRotationGizmo;
  43161. /** Fires an event when any of it's sub gizmos are dragged */
  43162. onDragStartObservable: Observable<{}>;
  43163. /** Fires an event when any of it's sub gizmos are released from dragging */
  43164. onDragEndObservable: Observable<{}>;
  43165. attachedMesh: Nullable<AbstractMesh>;
  43166. /**
  43167. * Creates a RotationGizmo
  43168. * @param gizmoLayer The utility layer the gizmo will be added to
  43169. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43170. */
  43171. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43172. updateGizmoRotationToMatchAttachedMesh: boolean;
  43173. /**
  43174. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43175. */
  43176. snapDistance: number;
  43177. /**
  43178. * Ratio for the scale of the gizmo (Default: 1)
  43179. */
  43180. scaleRatio: number;
  43181. /**
  43182. * Disposes of the gizmo
  43183. */
  43184. dispose(): void;
  43185. /**
  43186. * CustomMeshes are not supported by this gizmo
  43187. * @param mesh The mesh to replace the default mesh of the gizmo
  43188. */
  43189. setCustomMesh(mesh: Mesh): void;
  43190. }
  43191. }
  43192. declare module "babylonjs/Gizmos/positionGizmo" {
  43193. import { Observable } from "babylonjs/Misc/observable";
  43194. import { Nullable } from "babylonjs/types";
  43195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43196. import { Mesh } from "babylonjs/Meshes/mesh";
  43197. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43198. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43199. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43200. /**
  43201. * Gizmo that enables dragging a mesh along 3 axis
  43202. */
  43203. export class PositionGizmo extends Gizmo {
  43204. /**
  43205. * Internal gizmo used for interactions on the x axis
  43206. */
  43207. xGizmo: AxisDragGizmo;
  43208. /**
  43209. * Internal gizmo used for interactions on the y axis
  43210. */
  43211. yGizmo: AxisDragGizmo;
  43212. /**
  43213. * Internal gizmo used for interactions on the z axis
  43214. */
  43215. zGizmo: AxisDragGizmo;
  43216. /** Fires an event when any of it's sub gizmos are dragged */
  43217. onDragStartObservable: Observable<{}>;
  43218. /** Fires an event when any of it's sub gizmos are released from dragging */
  43219. onDragEndObservable: Observable<{}>;
  43220. attachedMesh: Nullable<AbstractMesh>;
  43221. /**
  43222. * Creates a PositionGizmo
  43223. * @param gizmoLayer The utility layer the gizmo will be added to
  43224. */
  43225. constructor(gizmoLayer?: UtilityLayerRenderer);
  43226. updateGizmoRotationToMatchAttachedMesh: boolean;
  43227. /**
  43228. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43229. */
  43230. snapDistance: number;
  43231. /**
  43232. * Ratio for the scale of the gizmo (Default: 1)
  43233. */
  43234. scaleRatio: number;
  43235. /**
  43236. * Disposes of the gizmo
  43237. */
  43238. dispose(): void;
  43239. /**
  43240. * CustomMeshes are not supported by this gizmo
  43241. * @param mesh The mesh to replace the default mesh of the gizmo
  43242. */
  43243. setCustomMesh(mesh: Mesh): void;
  43244. }
  43245. }
  43246. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43247. import { Scene } from "babylonjs/scene";
  43248. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43249. import { Mesh } from "babylonjs/Meshes/mesh";
  43250. /**
  43251. * Class containing static functions to help procedurally build meshes
  43252. */
  43253. export class PolyhedronBuilder {
  43254. /**
  43255. * Creates a polyhedron mesh
  43256. * * 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
  43257. * * The parameter `size` (positive float, default 1) sets the polygon size
  43258. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43259. * * 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`
  43260. * * 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
  43261. * * 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)`)
  43262. * * 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
  43263. * * 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
  43264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43267. * @param name defines the name of the mesh
  43268. * @param options defines the options used to create the mesh
  43269. * @param scene defines the hosting scene
  43270. * @returns the polyhedron mesh
  43271. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43272. */
  43273. static CreatePolyhedron(name: string, options: {
  43274. type?: number;
  43275. size?: number;
  43276. sizeX?: number;
  43277. sizeY?: number;
  43278. sizeZ?: number;
  43279. custom?: any;
  43280. faceUV?: Vector4[];
  43281. faceColors?: Color4[];
  43282. flat?: boolean;
  43283. updatable?: boolean;
  43284. sideOrientation?: number;
  43285. frontUVs?: Vector4;
  43286. backUVs?: Vector4;
  43287. }, scene: Scene): Mesh;
  43288. }
  43289. }
  43290. declare module "babylonjs/Gizmos/scaleGizmo" {
  43291. import { Observable } from "babylonjs/Misc/observable";
  43292. import { Nullable } from "babylonjs/types";
  43293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43294. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43295. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43296. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43297. /**
  43298. * Gizmo that enables scaling a mesh along 3 axis
  43299. */
  43300. export class ScaleGizmo extends Gizmo {
  43301. /**
  43302. * Internal gizmo used for interactions on the x axis
  43303. */
  43304. xGizmo: AxisScaleGizmo;
  43305. /**
  43306. * Internal gizmo used for interactions on the y axis
  43307. */
  43308. yGizmo: AxisScaleGizmo;
  43309. /**
  43310. * Internal gizmo used for interactions on the z axis
  43311. */
  43312. zGizmo: AxisScaleGizmo;
  43313. /**
  43314. * Internal gizmo used to scale all axis equally
  43315. */
  43316. uniformScaleGizmo: AxisScaleGizmo;
  43317. /** Fires an event when any of it's sub gizmos are dragged */
  43318. onDragStartObservable: Observable<{}>;
  43319. /** Fires an event when any of it's sub gizmos are released from dragging */
  43320. onDragEndObservable: Observable<{}>;
  43321. attachedMesh: Nullable<AbstractMesh>;
  43322. /**
  43323. * Creates a ScaleGizmo
  43324. * @param gizmoLayer The utility layer the gizmo will be added to
  43325. */
  43326. constructor(gizmoLayer?: UtilityLayerRenderer);
  43327. updateGizmoRotationToMatchAttachedMesh: boolean;
  43328. /**
  43329. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43330. */
  43331. snapDistance: number;
  43332. /**
  43333. * Ratio for the scale of the gizmo (Default: 1)
  43334. */
  43335. scaleRatio: number;
  43336. /**
  43337. * Disposes of the gizmo
  43338. */
  43339. dispose(): void;
  43340. }
  43341. }
  43342. declare module "babylonjs/Gizmos/gizmoManager" {
  43343. import { Observable } from "babylonjs/Misc/observable";
  43344. import { Nullable } from "babylonjs/types";
  43345. import { Scene, IDisposable } from "babylonjs/scene";
  43346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43347. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43348. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43349. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43350. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43351. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43352. /**
  43353. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43354. */
  43355. export class GizmoManager implements IDisposable {
  43356. private scene;
  43357. /**
  43358. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43359. */
  43360. gizmos: {
  43361. positionGizmo: Nullable<PositionGizmo>;
  43362. rotationGizmo: Nullable<RotationGizmo>;
  43363. scaleGizmo: Nullable<ScaleGizmo>;
  43364. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43365. };
  43366. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43367. clearGizmoOnEmptyPointerEvent: boolean;
  43368. /** Fires an event when the manager is attached to a mesh */
  43369. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43370. private _gizmosEnabled;
  43371. private _pointerObserver;
  43372. private _attachedMesh;
  43373. private _boundingBoxColor;
  43374. private _defaultUtilityLayer;
  43375. private _defaultKeepDepthUtilityLayer;
  43376. /**
  43377. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43378. */
  43379. boundingBoxDragBehavior: SixDofDragBehavior;
  43380. /**
  43381. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43382. */
  43383. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43384. /**
  43385. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43386. */
  43387. usePointerToAttachGizmos: boolean;
  43388. /**
  43389. * Instatiates a gizmo manager
  43390. * @param scene the scene to overlay the gizmos on top of
  43391. */
  43392. constructor(scene: Scene);
  43393. /**
  43394. * Attaches a set of gizmos to the specified mesh
  43395. * @param mesh The mesh the gizmo's should be attached to
  43396. */
  43397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43398. /**
  43399. * If the position gizmo is enabled
  43400. */
  43401. positionGizmoEnabled: boolean;
  43402. /**
  43403. * If the rotation gizmo is enabled
  43404. */
  43405. rotationGizmoEnabled: boolean;
  43406. /**
  43407. * If the scale gizmo is enabled
  43408. */
  43409. scaleGizmoEnabled: boolean;
  43410. /**
  43411. * If the boundingBox gizmo is enabled
  43412. */
  43413. boundingBoxGizmoEnabled: boolean;
  43414. /**
  43415. * Disposes of the gizmo manager
  43416. */
  43417. dispose(): void;
  43418. }
  43419. }
  43420. declare module "babylonjs/Gizmos/lightGizmo" {
  43421. import { Nullable } from "babylonjs/types";
  43422. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43423. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43424. import { Light } from "babylonjs/Lights/light";
  43425. /**
  43426. * Gizmo that enables viewing a light
  43427. */
  43428. export class LightGizmo extends Gizmo {
  43429. private _box;
  43430. /**
  43431. * Creates a LightGizmo
  43432. * @param gizmoLayer The utility layer the gizmo will be added to
  43433. */
  43434. constructor(gizmoLayer?: UtilityLayerRenderer);
  43435. private _light;
  43436. /**
  43437. * The light that the gizmo is attached to
  43438. */
  43439. light: Nullable<Light>;
  43440. /**
  43441. * @hidden
  43442. * Updates the gizmo to match the attached mesh's position/rotation
  43443. */
  43444. protected _update(): void;
  43445. }
  43446. }
  43447. declare module "babylonjs/Gizmos/index" {
  43448. export * from "babylonjs/Gizmos/axisDragGizmo";
  43449. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43450. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43451. export * from "babylonjs/Gizmos/gizmo";
  43452. export * from "babylonjs/Gizmos/gizmoManager";
  43453. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43454. export * from "babylonjs/Gizmos/positionGizmo";
  43455. export * from "babylonjs/Gizmos/rotationGizmo";
  43456. export * from "babylonjs/Gizmos/scaleGizmo";
  43457. export * from "babylonjs/Gizmos/lightGizmo";
  43458. }
  43459. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43460. /** @hidden */
  43461. export var backgroundFragmentDeclaration: {
  43462. name: string;
  43463. shader: string;
  43464. };
  43465. }
  43466. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43467. /** @hidden */
  43468. export var backgroundUboDeclaration: {
  43469. name: string;
  43470. shader: string;
  43471. };
  43472. }
  43473. declare module "babylonjs/Shaders/background.fragment" {
  43474. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43475. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43476. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43477. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43478. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43479. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43481. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43482. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43483. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43485. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43486. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43487. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43488. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43489. /** @hidden */
  43490. export var backgroundPixelShader: {
  43491. name: string;
  43492. shader: string;
  43493. };
  43494. }
  43495. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43496. /** @hidden */
  43497. export var backgroundVertexDeclaration: {
  43498. name: string;
  43499. shader: string;
  43500. };
  43501. }
  43502. declare module "babylonjs/Shaders/background.vertex" {
  43503. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43504. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43506. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43507. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43509. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43510. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43511. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43512. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43513. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43514. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43515. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43516. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43517. /** @hidden */
  43518. export var backgroundVertexShader: {
  43519. name: string;
  43520. shader: string;
  43521. };
  43522. }
  43523. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43524. import { Nullable, int, float } from "babylonjs/types";
  43525. import { Scene } from "babylonjs/scene";
  43526. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43529. import { Mesh } from "babylonjs/Meshes/mesh";
  43530. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43531. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43532. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43534. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43535. import "babylonjs/Shaders/background.fragment";
  43536. import "babylonjs/Shaders/background.vertex";
  43537. /**
  43538. * Background material used to create an efficient environement around your scene.
  43539. */
  43540. export class BackgroundMaterial extends PushMaterial {
  43541. /**
  43542. * Standard reflectance value at parallel view angle.
  43543. */
  43544. static StandardReflectance0: number;
  43545. /**
  43546. * Standard reflectance value at grazing angle.
  43547. */
  43548. static StandardReflectance90: number;
  43549. protected _primaryColor: Color3;
  43550. /**
  43551. * Key light Color (multiply against the environement texture)
  43552. */
  43553. primaryColor: Color3;
  43554. protected __perceptualColor: Nullable<Color3>;
  43555. /**
  43556. * Experimental Internal Use Only.
  43557. *
  43558. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43559. * This acts as a helper to set the primary color to a more "human friendly" value.
  43560. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43561. * output color as close as possible from the chosen value.
  43562. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43563. * part of lighting setup.)
  43564. */
  43565. _perceptualColor: Nullable<Color3>;
  43566. protected _primaryColorShadowLevel: float;
  43567. /**
  43568. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43569. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43570. */
  43571. primaryColorShadowLevel: float;
  43572. protected _primaryColorHighlightLevel: float;
  43573. /**
  43574. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43575. * The primary color is used at the level chosen to define what the white area would look.
  43576. */
  43577. primaryColorHighlightLevel: float;
  43578. protected _reflectionTexture: Nullable<BaseTexture>;
  43579. /**
  43580. * Reflection Texture used in the material.
  43581. * Should be author in a specific way for the best result (refer to the documentation).
  43582. */
  43583. reflectionTexture: Nullable<BaseTexture>;
  43584. protected _reflectionBlur: float;
  43585. /**
  43586. * Reflection Texture level of blur.
  43587. *
  43588. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43589. * texture twice.
  43590. */
  43591. reflectionBlur: float;
  43592. protected _diffuseTexture: Nullable<BaseTexture>;
  43593. /**
  43594. * Diffuse Texture used in the material.
  43595. * Should be author in a specific way for the best result (refer to the documentation).
  43596. */
  43597. diffuseTexture: Nullable<BaseTexture>;
  43598. protected _shadowLights: Nullable<IShadowLight[]>;
  43599. /**
  43600. * Specify the list of lights casting shadow on the material.
  43601. * All scene shadow lights will be included if null.
  43602. */
  43603. shadowLights: Nullable<IShadowLight[]>;
  43604. protected _shadowLevel: float;
  43605. /**
  43606. * Helps adjusting the shadow to a softer level if required.
  43607. * 0 means black shadows and 1 means no shadows.
  43608. */
  43609. shadowLevel: float;
  43610. protected _sceneCenter: Vector3;
  43611. /**
  43612. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43613. * It is usually zero but might be interesting to modify according to your setup.
  43614. */
  43615. sceneCenter: Vector3;
  43616. protected _opacityFresnel: boolean;
  43617. /**
  43618. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43619. * This helps ensuring a nice transition when the camera goes under the ground.
  43620. */
  43621. opacityFresnel: boolean;
  43622. protected _reflectionFresnel: boolean;
  43623. /**
  43624. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43625. * This helps adding a mirror texture on the ground.
  43626. */
  43627. reflectionFresnel: boolean;
  43628. protected _reflectionFalloffDistance: number;
  43629. /**
  43630. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43631. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43632. */
  43633. reflectionFalloffDistance: number;
  43634. protected _reflectionAmount: number;
  43635. /**
  43636. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43637. */
  43638. reflectionAmount: number;
  43639. protected _reflectionReflectance0: number;
  43640. /**
  43641. * This specifies the weight of the reflection at grazing angle.
  43642. */
  43643. reflectionReflectance0: number;
  43644. protected _reflectionReflectance90: number;
  43645. /**
  43646. * This specifies the weight of the reflection at a perpendicular point of view.
  43647. */
  43648. reflectionReflectance90: number;
  43649. /**
  43650. * Sets the reflection reflectance fresnel values according to the default standard
  43651. * empirically know to work well :-)
  43652. */
  43653. reflectionStandardFresnelWeight: number;
  43654. protected _useRGBColor: boolean;
  43655. /**
  43656. * Helps to directly use the maps channels instead of their level.
  43657. */
  43658. useRGBColor: boolean;
  43659. protected _enableNoise: boolean;
  43660. /**
  43661. * This helps reducing the banding effect that could occur on the background.
  43662. */
  43663. enableNoise: boolean;
  43664. /**
  43665. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43666. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43667. * Recommended to be keep at 1.0 except for special cases.
  43668. */
  43669. fovMultiplier: number;
  43670. private _fovMultiplier;
  43671. /**
  43672. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43673. */
  43674. useEquirectangularFOV: boolean;
  43675. private _maxSimultaneousLights;
  43676. /**
  43677. * Number of Simultaneous lights allowed on the material.
  43678. */
  43679. maxSimultaneousLights: int;
  43680. /**
  43681. * Default configuration related to image processing available in the Background Material.
  43682. */
  43683. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43684. /**
  43685. * Keep track of the image processing observer to allow dispose and replace.
  43686. */
  43687. private _imageProcessingObserver;
  43688. /**
  43689. * Attaches a new image processing configuration to the PBR Material.
  43690. * @param configuration (if null the scene configuration will be use)
  43691. */
  43692. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43693. /**
  43694. * Gets the image processing configuration used either in this material.
  43695. */
  43696. /**
  43697. * Sets the Default image processing configuration used either in the this material.
  43698. *
  43699. * If sets to null, the scene one is in use.
  43700. */
  43701. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43702. /**
  43703. * Gets wether the color curves effect is enabled.
  43704. */
  43705. /**
  43706. * Sets wether the color curves effect is enabled.
  43707. */
  43708. cameraColorCurvesEnabled: boolean;
  43709. /**
  43710. * Gets wether the color grading effect is enabled.
  43711. */
  43712. /**
  43713. * Gets wether the color grading effect is enabled.
  43714. */
  43715. cameraColorGradingEnabled: boolean;
  43716. /**
  43717. * Gets wether tonemapping is enabled or not.
  43718. */
  43719. /**
  43720. * Sets wether tonemapping is enabled or not
  43721. */
  43722. cameraToneMappingEnabled: boolean;
  43723. /**
  43724. * The camera exposure used on this material.
  43725. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43726. * This corresponds to a photographic exposure.
  43727. */
  43728. /**
  43729. * The camera exposure used on this material.
  43730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43731. * This corresponds to a photographic exposure.
  43732. */
  43733. cameraExposure: float;
  43734. /**
  43735. * Gets The camera contrast used on this material.
  43736. */
  43737. /**
  43738. * Sets The camera contrast used on this material.
  43739. */
  43740. cameraContrast: float;
  43741. /**
  43742. * Gets the Color Grading 2D Lookup Texture.
  43743. */
  43744. /**
  43745. * Sets the Color Grading 2D Lookup Texture.
  43746. */
  43747. cameraColorGradingTexture: Nullable<BaseTexture>;
  43748. /**
  43749. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43750. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43751. * 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;
  43752. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43753. */
  43754. /**
  43755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43757. * 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;
  43758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43759. */
  43760. cameraColorCurves: Nullable<ColorCurves>;
  43761. /**
  43762. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43763. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43764. */
  43765. switchToBGR: boolean;
  43766. private _renderTargets;
  43767. private _reflectionControls;
  43768. private _white;
  43769. private _primaryShadowColor;
  43770. private _primaryHighlightColor;
  43771. /**
  43772. * Instantiates a Background Material in the given scene
  43773. * @param name The friendly name of the material
  43774. * @param scene The scene to add the material to
  43775. */
  43776. constructor(name: string, scene: Scene);
  43777. /**
  43778. * Gets a boolean indicating that current material needs to register RTT
  43779. */
  43780. readonly hasRenderTargetTextures: boolean;
  43781. /**
  43782. * The entire material has been created in order to prevent overdraw.
  43783. * @returns false
  43784. */
  43785. needAlphaTesting(): boolean;
  43786. /**
  43787. * The entire material has been created in order to prevent overdraw.
  43788. * @returns true if blending is enable
  43789. */
  43790. needAlphaBlending(): boolean;
  43791. /**
  43792. * Checks wether the material is ready to be rendered for a given mesh.
  43793. * @param mesh The mesh to render
  43794. * @param subMesh The submesh to check against
  43795. * @param useInstances Specify wether or not the material is used with instances
  43796. * @returns true if all the dependencies are ready (Textures, Effects...)
  43797. */
  43798. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43799. /**
  43800. * Compute the primary color according to the chosen perceptual color.
  43801. */
  43802. private _computePrimaryColorFromPerceptualColor;
  43803. /**
  43804. * Compute the highlights and shadow colors according to their chosen levels.
  43805. */
  43806. private _computePrimaryColors;
  43807. /**
  43808. * Build the uniform buffer used in the material.
  43809. */
  43810. buildUniformLayout(): void;
  43811. /**
  43812. * Unbind the material.
  43813. */
  43814. unbind(): void;
  43815. /**
  43816. * Bind only the world matrix to the material.
  43817. * @param world The world matrix to bind.
  43818. */
  43819. bindOnlyWorldMatrix(world: Matrix): void;
  43820. /**
  43821. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43822. * @param world The world matrix to bind.
  43823. * @param subMesh The submesh to bind for.
  43824. */
  43825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43826. /**
  43827. * Dispose the material.
  43828. * @param forceDisposeEffect Force disposal of the associated effect.
  43829. * @param forceDisposeTextures Force disposal of the associated textures.
  43830. */
  43831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43832. /**
  43833. * Clones the material.
  43834. * @param name The cloned name.
  43835. * @returns The cloned material.
  43836. */
  43837. clone(name: string): BackgroundMaterial;
  43838. /**
  43839. * Serializes the current material to its JSON representation.
  43840. * @returns The JSON representation.
  43841. */
  43842. serialize(): any;
  43843. /**
  43844. * Gets the class name of the material
  43845. * @returns "BackgroundMaterial"
  43846. */
  43847. getClassName(): string;
  43848. /**
  43849. * Parse a JSON input to create back a background material.
  43850. * @param source The JSON data to parse
  43851. * @param scene The scene to create the parsed material in
  43852. * @param rootUrl The root url of the assets the material depends upon
  43853. * @returns the instantiated BackgroundMaterial.
  43854. */
  43855. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43856. }
  43857. }
  43858. declare module "babylonjs/Helpers/environmentHelper" {
  43859. import { Observable } from "babylonjs/Misc/observable";
  43860. import { Nullable } from "babylonjs/types";
  43861. import { Scene } from "babylonjs/scene";
  43862. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43864. import { Mesh } from "babylonjs/Meshes/mesh";
  43865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43866. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43867. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43868. import "babylonjs/Meshes/Builders/planeBuilder";
  43869. import "babylonjs/Meshes/Builders/boxBuilder";
  43870. /**
  43871. * Represents the different options available during the creation of
  43872. * a Environment helper.
  43873. *
  43874. * This can control the default ground, skybox and image processing setup of your scene.
  43875. */
  43876. export interface IEnvironmentHelperOptions {
  43877. /**
  43878. * Specifies wether or not to create a ground.
  43879. * True by default.
  43880. */
  43881. createGround: boolean;
  43882. /**
  43883. * Specifies the ground size.
  43884. * 15 by default.
  43885. */
  43886. groundSize: number;
  43887. /**
  43888. * The texture used on the ground for the main color.
  43889. * Comes from the BabylonJS CDN by default.
  43890. *
  43891. * Remarks: Can be either a texture or a url.
  43892. */
  43893. groundTexture: string | BaseTexture;
  43894. /**
  43895. * The color mixed in the ground texture by default.
  43896. * BabylonJS clearColor by default.
  43897. */
  43898. groundColor: Color3;
  43899. /**
  43900. * Specifies the ground opacity.
  43901. * 1 by default.
  43902. */
  43903. groundOpacity: number;
  43904. /**
  43905. * Enables the ground to receive shadows.
  43906. * True by default.
  43907. */
  43908. enableGroundShadow: boolean;
  43909. /**
  43910. * Helps preventing the shadow to be fully black on the ground.
  43911. * 0.5 by default.
  43912. */
  43913. groundShadowLevel: number;
  43914. /**
  43915. * Creates a mirror texture attach to the ground.
  43916. * false by default.
  43917. */
  43918. enableGroundMirror: boolean;
  43919. /**
  43920. * Specifies the ground mirror size ratio.
  43921. * 0.3 by default as the default kernel is 64.
  43922. */
  43923. groundMirrorSizeRatio: number;
  43924. /**
  43925. * Specifies the ground mirror blur kernel size.
  43926. * 64 by default.
  43927. */
  43928. groundMirrorBlurKernel: number;
  43929. /**
  43930. * Specifies the ground mirror visibility amount.
  43931. * 1 by default
  43932. */
  43933. groundMirrorAmount: number;
  43934. /**
  43935. * Specifies the ground mirror reflectance weight.
  43936. * This uses the standard weight of the background material to setup the fresnel effect
  43937. * of the mirror.
  43938. * 1 by default.
  43939. */
  43940. groundMirrorFresnelWeight: number;
  43941. /**
  43942. * Specifies the ground mirror Falloff distance.
  43943. * This can helps reducing the size of the reflection.
  43944. * 0 by Default.
  43945. */
  43946. groundMirrorFallOffDistance: number;
  43947. /**
  43948. * Specifies the ground mirror texture type.
  43949. * Unsigned Int by Default.
  43950. */
  43951. groundMirrorTextureType: number;
  43952. /**
  43953. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43954. * the shown objects.
  43955. */
  43956. groundYBias: number;
  43957. /**
  43958. * Specifies wether or not to create a skybox.
  43959. * True by default.
  43960. */
  43961. createSkybox: boolean;
  43962. /**
  43963. * Specifies the skybox size.
  43964. * 20 by default.
  43965. */
  43966. skyboxSize: number;
  43967. /**
  43968. * The texture used on the skybox for the main color.
  43969. * Comes from the BabylonJS CDN by default.
  43970. *
  43971. * Remarks: Can be either a texture or a url.
  43972. */
  43973. skyboxTexture: string | BaseTexture;
  43974. /**
  43975. * The color mixed in the skybox texture by default.
  43976. * BabylonJS clearColor by default.
  43977. */
  43978. skyboxColor: Color3;
  43979. /**
  43980. * The background rotation around the Y axis of the scene.
  43981. * This helps aligning the key lights of your scene with the background.
  43982. * 0 by default.
  43983. */
  43984. backgroundYRotation: number;
  43985. /**
  43986. * Compute automatically the size of the elements to best fit with the scene.
  43987. */
  43988. sizeAuto: boolean;
  43989. /**
  43990. * Default position of the rootMesh if autoSize is not true.
  43991. */
  43992. rootPosition: Vector3;
  43993. /**
  43994. * Sets up the image processing in the scene.
  43995. * true by default.
  43996. */
  43997. setupImageProcessing: boolean;
  43998. /**
  43999. * The texture used as your environment texture in the scene.
  44000. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44001. *
  44002. * Remarks: Can be either a texture or a url.
  44003. */
  44004. environmentTexture: string | BaseTexture;
  44005. /**
  44006. * The value of the exposure to apply to the scene.
  44007. * 0.6 by default if setupImageProcessing is true.
  44008. */
  44009. cameraExposure: number;
  44010. /**
  44011. * The value of the contrast to apply to the scene.
  44012. * 1.6 by default if setupImageProcessing is true.
  44013. */
  44014. cameraContrast: number;
  44015. /**
  44016. * Specifies wether or not tonemapping should be enabled in the scene.
  44017. * true by default if setupImageProcessing is true.
  44018. */
  44019. toneMappingEnabled: boolean;
  44020. }
  44021. /**
  44022. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44023. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44024. * It also helps with the default setup of your imageProcessing configuration.
  44025. */
  44026. export class EnvironmentHelper {
  44027. /**
  44028. * Default ground texture URL.
  44029. */
  44030. private static _groundTextureCDNUrl;
  44031. /**
  44032. * Default skybox texture URL.
  44033. */
  44034. private static _skyboxTextureCDNUrl;
  44035. /**
  44036. * Default environment texture URL.
  44037. */
  44038. private static _environmentTextureCDNUrl;
  44039. /**
  44040. * Creates the default options for the helper.
  44041. */
  44042. private static _getDefaultOptions;
  44043. private _rootMesh;
  44044. /**
  44045. * Gets the root mesh created by the helper.
  44046. */
  44047. readonly rootMesh: Mesh;
  44048. private _skybox;
  44049. /**
  44050. * Gets the skybox created by the helper.
  44051. */
  44052. readonly skybox: Nullable<Mesh>;
  44053. private _skyboxTexture;
  44054. /**
  44055. * Gets the skybox texture created by the helper.
  44056. */
  44057. readonly skyboxTexture: Nullable<BaseTexture>;
  44058. private _skyboxMaterial;
  44059. /**
  44060. * Gets the skybox material created by the helper.
  44061. */
  44062. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44063. private _ground;
  44064. /**
  44065. * Gets the ground mesh created by the helper.
  44066. */
  44067. readonly ground: Nullable<Mesh>;
  44068. private _groundTexture;
  44069. /**
  44070. * Gets the ground texture created by the helper.
  44071. */
  44072. readonly groundTexture: Nullable<BaseTexture>;
  44073. private _groundMirror;
  44074. /**
  44075. * Gets the ground mirror created by the helper.
  44076. */
  44077. readonly groundMirror: Nullable<MirrorTexture>;
  44078. /**
  44079. * Gets the ground mirror render list to helps pushing the meshes
  44080. * you wish in the ground reflection.
  44081. */
  44082. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44083. private _groundMaterial;
  44084. /**
  44085. * Gets the ground material created by the helper.
  44086. */
  44087. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44088. /**
  44089. * Stores the creation options.
  44090. */
  44091. private readonly _scene;
  44092. private _options;
  44093. /**
  44094. * This observable will be notified with any error during the creation of the environment,
  44095. * mainly texture creation errors.
  44096. */
  44097. onErrorObservable: Observable<{
  44098. message?: string;
  44099. exception?: any;
  44100. }>;
  44101. /**
  44102. * constructor
  44103. * @param options Defines the options we want to customize the helper
  44104. * @param scene The scene to add the material to
  44105. */
  44106. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44107. /**
  44108. * Updates the background according to the new options
  44109. * @param options
  44110. */
  44111. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44112. /**
  44113. * Sets the primary color of all the available elements.
  44114. * @param color the main color to affect to the ground and the background
  44115. */
  44116. setMainColor(color: Color3): void;
  44117. /**
  44118. * Setup the image processing according to the specified options.
  44119. */
  44120. private _setupImageProcessing;
  44121. /**
  44122. * Setup the environment texture according to the specified options.
  44123. */
  44124. private _setupEnvironmentTexture;
  44125. /**
  44126. * Setup the background according to the specified options.
  44127. */
  44128. private _setupBackground;
  44129. /**
  44130. * Get the scene sizes according to the setup.
  44131. */
  44132. private _getSceneSize;
  44133. /**
  44134. * Setup the ground according to the specified options.
  44135. */
  44136. private _setupGround;
  44137. /**
  44138. * Setup the ground material according to the specified options.
  44139. */
  44140. private _setupGroundMaterial;
  44141. /**
  44142. * Setup the ground diffuse texture according to the specified options.
  44143. */
  44144. private _setupGroundDiffuseTexture;
  44145. /**
  44146. * Setup the ground mirror texture according to the specified options.
  44147. */
  44148. private _setupGroundMirrorTexture;
  44149. /**
  44150. * Setup the ground to receive the mirror texture.
  44151. */
  44152. private _setupMirrorInGroundMaterial;
  44153. /**
  44154. * Setup the skybox according to the specified options.
  44155. */
  44156. private _setupSkybox;
  44157. /**
  44158. * Setup the skybox material according to the specified options.
  44159. */
  44160. private _setupSkyboxMaterial;
  44161. /**
  44162. * Setup the skybox reflection texture according to the specified options.
  44163. */
  44164. private _setupSkyboxReflectionTexture;
  44165. private _errorHandler;
  44166. /**
  44167. * Dispose all the elements created by the Helper.
  44168. */
  44169. dispose(): void;
  44170. }
  44171. }
  44172. declare module "babylonjs/Helpers/photoDome" {
  44173. import { Observable } from "babylonjs/Misc/observable";
  44174. import { Nullable } from "babylonjs/types";
  44175. import { Scene } from "babylonjs/scene";
  44176. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44177. import { Mesh } from "babylonjs/Meshes/mesh";
  44178. import { Texture } from "babylonjs/Materials/Textures/texture";
  44179. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44180. import "babylonjs/Meshes/Builders/sphereBuilder";
  44181. /**
  44182. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44183. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44184. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44185. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44186. */
  44187. export class PhotoDome extends TransformNode {
  44188. private _useDirectMapping;
  44189. /**
  44190. * The texture being displayed on the sphere
  44191. */
  44192. protected _photoTexture: Texture;
  44193. /**
  44194. * Gets or sets the texture being displayed on the sphere
  44195. */
  44196. photoTexture: Texture;
  44197. /**
  44198. * Observable raised when an error occured while loading the 360 image
  44199. */
  44200. onLoadErrorObservable: Observable<string>;
  44201. /**
  44202. * The skybox material
  44203. */
  44204. protected _material: BackgroundMaterial;
  44205. /**
  44206. * The surface used for the skybox
  44207. */
  44208. protected _mesh: Mesh;
  44209. /**
  44210. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44211. * Also see the options.resolution property.
  44212. */
  44213. fovMultiplier: number;
  44214. /**
  44215. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44216. * @param name Element's name, child elements will append suffixes for their own names.
  44217. * @param urlsOfPhoto defines the url of the photo to display
  44218. * @param options defines an object containing optional or exposed sub element properties
  44219. * @param onError defines a callback called when an error occured while loading the texture
  44220. */
  44221. constructor(name: string, urlOfPhoto: string, options: {
  44222. resolution?: number;
  44223. size?: number;
  44224. useDirectMapping?: boolean;
  44225. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44226. /**
  44227. * Releases resources associated with this node.
  44228. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44229. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44230. */
  44231. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44232. }
  44233. }
  44234. declare module "babylonjs/Misc/textureTools" {
  44235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44236. import { Texture } from "babylonjs/Materials/Textures/texture";
  44237. import { Scene } from "babylonjs/scene";
  44238. /**
  44239. * Class used to host texture specific utilities
  44240. */
  44241. export class TextureTools {
  44242. /**
  44243. * Uses the GPU to create a copy texture rescaled at a given size
  44244. * @param texture Texture to copy from
  44245. * @param width defines the desired width
  44246. * @param height defines the desired height
  44247. * @param useBilinearMode defines if bilinear mode has to be used
  44248. * @return the generated texture
  44249. */
  44250. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44251. /**
  44252. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44253. * @param scene defines the hosting scene
  44254. * @returns the environment BRDF texture
  44255. */
  44256. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44257. private static _environmentBRDFBase64Texture;
  44258. }
  44259. }
  44260. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44261. import { Nullable } from "babylonjs/types";
  44262. import { IAnimatable } from "babylonjs/Misc/tools";
  44263. import { Color3 } from "babylonjs/Maths/math";
  44264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44265. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44266. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44267. import { Engine } from "babylonjs/Engines/engine";
  44268. import { Scene } from "babylonjs/scene";
  44269. /**
  44270. * @hidden
  44271. */
  44272. export interface IMaterialClearCoatDefines {
  44273. CLEARCOAT: boolean;
  44274. CLEARCOAT_DEFAULTIOR: boolean;
  44275. CLEARCOAT_TEXTURE: boolean;
  44276. CLEARCOAT_TEXTUREDIRECTUV: number;
  44277. CLEARCOAT_BUMP: boolean;
  44278. CLEARCOAT_BUMPDIRECTUV: number;
  44279. CLEARCOAT_TINT: boolean;
  44280. CLEARCOAT_TINT_TEXTURE: boolean;
  44281. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44282. /** @hidden */
  44283. _areTexturesDirty: boolean;
  44284. }
  44285. /**
  44286. * Define the code related to the clear coat parameters of the pbr material.
  44287. */
  44288. export class PBRClearCoatConfiguration {
  44289. /**
  44290. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44291. * The default fits with a polyurethane material.
  44292. */
  44293. private static readonly _DefaultIndiceOfRefraction;
  44294. private _isEnabled;
  44295. /**
  44296. * Defines if the clear coat is enabled in the material.
  44297. */
  44298. isEnabled: boolean;
  44299. /**
  44300. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44301. */
  44302. intensity: number;
  44303. /**
  44304. * Defines the clear coat layer roughness.
  44305. */
  44306. roughness: number;
  44307. private _indiceOfRefraction;
  44308. /**
  44309. * Defines the indice of refraction of the clear coat.
  44310. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44311. * The default fits with a polyurethane material.
  44312. * Changing the default value is more performance intensive.
  44313. */
  44314. indiceOfRefraction: number;
  44315. private _texture;
  44316. /**
  44317. * Stores the clear coat values in a texture.
  44318. */
  44319. texture: Nullable<BaseTexture>;
  44320. private _bumpTexture;
  44321. /**
  44322. * Define the clear coat specific bump texture.
  44323. */
  44324. bumpTexture: Nullable<BaseTexture>;
  44325. private _isTintEnabled;
  44326. /**
  44327. * Defines if the clear coat tint is enabled in the material.
  44328. */
  44329. isTintEnabled: boolean;
  44330. /**
  44331. * Defines if the clear coat tint is enabled in the material.
  44332. * This is only use if tint is enabled
  44333. */
  44334. tintColor: Color3;
  44335. /**
  44336. * Defines if the distance at which the tint color should be found in the
  44337. * clear coat media.
  44338. * This is only use if tint is enabled
  44339. */
  44340. tintColorAtDistance: number;
  44341. /**
  44342. * Defines the clear coat layer thickness.
  44343. * This is only use if tint is enabled
  44344. */
  44345. tintThickness: number;
  44346. private _tintTexture;
  44347. /**
  44348. * Stores the clear tint values in a texture.
  44349. * rgb is tint
  44350. * a is a thickness factor
  44351. */
  44352. tintTexture: Nullable<BaseTexture>;
  44353. /** @hidden */
  44354. private _internalMarkAllSubMeshesAsTexturesDirty;
  44355. /** @hidden */
  44356. _markAllSubMeshesAsTexturesDirty(): void;
  44357. /**
  44358. * Instantiate a new istance of clear coat configuration.
  44359. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44360. */
  44361. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44362. /**
  44363. * Specifies that the submesh is ready to be used.
  44364. * @param defines the list of "defines" to update.
  44365. * @param scene defines the scene the material belongs to.
  44366. * @param engine defines the engine the material belongs to.
  44367. * @param disableBumpMap defines wether the material disables bump or not.
  44368. * @returns - boolean indicating that the submesh is ready or not.
  44369. */
  44370. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44371. /**
  44372. * Checks to see if a texture is used in the material.
  44373. * @param defines the list of "defines" to update.
  44374. * @param scene defines the scene to the material belongs to.
  44375. */
  44376. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44377. /**
  44378. * Binds the material data.
  44379. * @param uniformBuffer defines the Uniform buffer to fill in.
  44380. * @param scene defines the scene the material belongs to.
  44381. * @param engine defines the engine the material belongs to.
  44382. * @param disableBumpMap defines wether the material disables bump or not.
  44383. * @param isFrozen defines wether the material is frozen or not.
  44384. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44385. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44386. */
  44387. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44388. /**
  44389. * Checks to see if a texture is used in the material.
  44390. * @param texture - Base texture to use.
  44391. * @returns - Boolean specifying if a texture is used in the material.
  44392. */
  44393. hasTexture(texture: BaseTexture): boolean;
  44394. /**
  44395. * Returns an array of the actively used textures.
  44396. * @param activeTextures Array of BaseTextures
  44397. */
  44398. getActiveTextures(activeTextures: BaseTexture[]): void;
  44399. /**
  44400. * Returns the animatable textures.
  44401. * @param animatables Array of animatable textures.
  44402. */
  44403. getAnimatables(animatables: IAnimatable[]): void;
  44404. /**
  44405. * Disposes the resources of the material.
  44406. * @param forceDisposeTextures - Forces the disposal of all textures.
  44407. */
  44408. dispose(forceDisposeTextures?: boolean): void;
  44409. /**
  44410. * Get the current class name of the texture useful for serialization or dynamic coding.
  44411. * @returns "PBRClearCoatConfiguration"
  44412. */
  44413. getClassName(): string;
  44414. /**
  44415. * Makes a duplicate of the current configuration into another one.
  44416. * @param clearCoatConfiguration define the config where to copy the info
  44417. */
  44418. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44419. /**
  44420. * Serializes this clear coat configuration.
  44421. * @returns - An object with the serialized config.
  44422. */
  44423. serialize(): any;
  44424. /**
  44425. * Parses a Clear Coat Configuration from a serialized object.
  44426. * @param source - Serialized object.
  44427. */
  44428. parse(source: any): void;
  44429. /**
  44430. * Add fallbacks to the effect fallbacks list.
  44431. * @param defines defines the Base texture to use.
  44432. * @param fallbacks defines the current fallback list.
  44433. * @param currentRank defines the current fallback rank.
  44434. * @returns the new fallback rank.
  44435. */
  44436. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44437. /**
  44438. * Add the required uniforms to the current list.
  44439. * @param uniforms defines the current uniform list.
  44440. */
  44441. static AddUniforms(uniforms: string[]): void;
  44442. /**
  44443. * Add the required samplers to the current list.
  44444. * @param samplers defines the current sampler list.
  44445. */
  44446. static AddSamplers(samplers: string[]): void;
  44447. /**
  44448. * Add the required uniforms to the current buffer.
  44449. * @param uniformBuffer defines the current uniform buffer.
  44450. */
  44451. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44452. }
  44453. }
  44454. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44455. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44456. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44458. /**
  44459. * @hidden
  44460. */
  44461. export interface IMaterialAnisotropicDefines {
  44462. ANISOTROPIC: boolean;
  44463. MAINUV1: boolean;
  44464. _areMiscDirty: boolean;
  44465. _needUVs: boolean;
  44466. }
  44467. /**
  44468. * Define the code related to the anisotropic parameters of the pbr material.
  44469. */
  44470. export class PBRAnisotropicConfiguration {
  44471. private _isEnabled;
  44472. /**
  44473. * Defines if the anisotropy is enabled in the material.
  44474. */
  44475. isEnabled: boolean;
  44476. /**
  44477. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44478. */
  44479. intensity: number;
  44480. /**
  44481. * Defines if the effect is along the tangents or bitangents.
  44482. * By default, the effect is "strectching" the highlights along the tangents.
  44483. */
  44484. followTangents: boolean;
  44485. /** @hidden */
  44486. private _internalMarkAllSubMeshesAsMiscDirty;
  44487. /** @hidden */
  44488. _markAllSubMeshesAsMiscDirty(): void;
  44489. /**
  44490. * Instantiate a new istance of clear coat configuration.
  44491. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44492. */
  44493. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44494. /**
  44495. * Checks to see if a texture is used in the material.
  44496. * @param defines the list of "defines" to update.
  44497. * @param mesh the mesh we are preparing the defines for.
  44498. */
  44499. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44500. /**
  44501. * Binds the material data.
  44502. * @param uniformBuffer defines the Uniform buffer to fill in.
  44503. * @param isFrozen defines wether the material is frozen or not.
  44504. */
  44505. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44506. /**
  44507. * Get the current class name of the texture useful for serialization or dynamic coding.
  44508. * @returns "PBRAnisotropicConfiguration"
  44509. */
  44510. getClassName(): string;
  44511. /**
  44512. * Makes a duplicate of the current configuration into another one.
  44513. * @param anisotropicConfiguration define the config where to copy the info
  44514. */
  44515. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44516. /**
  44517. * Serializes this clear coat configuration.
  44518. * @returns - An object with the serialized config.
  44519. */
  44520. serialize(): any;
  44521. /**
  44522. * Parses a Clear Coat Configuration from a serialized object.
  44523. * @param source - Serialized object.
  44524. */
  44525. parse(source: any): void;
  44526. /**
  44527. * Add fallbacks to the effect fallbacks list.
  44528. * @param defines defines the Base texture to use.
  44529. * @param fallbacks defines the current fallback list.
  44530. * @param currentRank defines the current fallback rank.
  44531. * @returns the new fallback rank.
  44532. */
  44533. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44534. /**
  44535. * Add the required uniforms to the current list.
  44536. * @param uniforms defines the current uniform list.
  44537. */
  44538. static AddUniforms(uniforms: string[]): void;
  44539. /**
  44540. * Add the required uniforms to the current buffer.
  44541. * @param uniformBuffer defines the current uniform buffer.
  44542. */
  44543. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44544. }
  44545. }
  44546. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44547. /**
  44548. * @hidden
  44549. */
  44550. export interface IMaterialBRDFDefines {
  44551. BRDF_V_HEIGHT_CORRELATED: boolean;
  44552. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44553. /** @hidden */
  44554. _areMiscDirty: boolean;
  44555. }
  44556. /**
  44557. * Define the code related to the BRDF parameters of the pbr material.
  44558. */
  44559. export class PBRBRDFConfiguration {
  44560. private _useEnergyConservation;
  44561. /**
  44562. * Defines if the material uses energy conservation.
  44563. */
  44564. useEnergyConservation: boolean;
  44565. private _useSmithVisibilityHeightCorrelated;
  44566. /**
  44567. * LEGACY Mode set to false
  44568. * Defines if the material uses height smith correlated visibility term.
  44569. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44570. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44571. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44572. * Not relying on height correlated will also disable energy conservation.
  44573. */
  44574. useSmithVisibilityHeightCorrelated: boolean;
  44575. /** @hidden */
  44576. private _internalMarkAllSubMeshesAsMiscDirty;
  44577. /** @hidden */
  44578. _markAllSubMeshesAsMiscDirty(): void;
  44579. /**
  44580. * Instantiate a new istance of clear coat configuration.
  44581. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44582. */
  44583. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44584. /**
  44585. * Checks to see if a texture is used in the material.
  44586. * @param defines the list of "defines" to update.
  44587. */
  44588. prepareDefines(defines: IMaterialBRDFDefines): void;
  44589. /**
  44590. * Get the current class name of the texture useful for serialization or dynamic coding.
  44591. * @returns "PBRClearCoatConfiguration"
  44592. */
  44593. getClassName(): string;
  44594. /**
  44595. * Makes a duplicate of the current configuration into another one.
  44596. * @param brdfConfiguration define the config where to copy the info
  44597. */
  44598. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44599. /**
  44600. * Serializes this BRDF configuration.
  44601. * @returns - An object with the serialized config.
  44602. */
  44603. serialize(): any;
  44604. /**
  44605. * Parses a BRDF Configuration from a serialized object.
  44606. * @param source - Serialized object.
  44607. */
  44608. parse(source: any): void;
  44609. }
  44610. }
  44611. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44612. /** @hidden */
  44613. export var pbrFragmentDeclaration: {
  44614. name: string;
  44615. shader: string;
  44616. };
  44617. }
  44618. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44619. /** @hidden */
  44620. export var pbrUboDeclaration: {
  44621. name: string;
  44622. shader: string;
  44623. };
  44624. }
  44625. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44626. /** @hidden */
  44627. export var pbrFunctions: {
  44628. name: string;
  44629. shader: string;
  44630. };
  44631. }
  44632. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44633. /** @hidden */
  44634. export var harmonicsFunctions: {
  44635. name: string;
  44636. shader: string;
  44637. };
  44638. }
  44639. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44640. /** @hidden */
  44641. export var pbrPreLightingFunctions: {
  44642. name: string;
  44643. shader: string;
  44644. };
  44645. }
  44646. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44647. /** @hidden */
  44648. export var pbrFalloffLightingFunctions: {
  44649. name: string;
  44650. shader: string;
  44651. };
  44652. }
  44653. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44654. /** @hidden */
  44655. export var pbrLightingFunctions: {
  44656. name: string;
  44657. shader: string;
  44658. };
  44659. }
  44660. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44661. /** @hidden */
  44662. export var pbrDebug: {
  44663. name: string;
  44664. shader: string;
  44665. };
  44666. }
  44667. declare module "babylonjs/Shaders/pbr.fragment" {
  44668. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44669. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44670. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44671. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44672. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44673. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44674. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44675. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44676. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44677. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44678. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44679. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44680. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44681. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44682. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44683. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44684. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44685. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44687. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44688. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44689. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44690. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44691. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44692. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44693. /** @hidden */
  44694. export var pbrPixelShader: {
  44695. name: string;
  44696. shader: string;
  44697. };
  44698. }
  44699. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44700. /** @hidden */
  44701. export var pbrVertexDeclaration: {
  44702. name: string;
  44703. shader: string;
  44704. };
  44705. }
  44706. declare module "babylonjs/Shaders/pbr.vertex" {
  44707. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44708. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44709. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44710. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44711. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44712. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44713. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44714. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44715. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44716. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44717. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44718. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44719. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44720. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44721. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44722. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44723. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44724. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44725. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44726. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44727. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44728. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44729. /** @hidden */
  44730. export var pbrVertexShader: {
  44731. name: string;
  44732. shader: string;
  44733. };
  44734. }
  44735. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44736. import { IAnimatable } from "babylonjs/Misc/tools";
  44737. import { Nullable } from "babylonjs/types";
  44738. import { Scene } from "babylonjs/scene";
  44739. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44740. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44742. import { Mesh } from "babylonjs/Meshes/mesh";
  44743. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44744. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44745. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44746. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44747. import { Material } from "babylonjs/Materials/material";
  44748. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44750. import "babylonjs/Shaders/pbr.fragment";
  44751. import "babylonjs/Shaders/pbr.vertex";
  44752. /**
  44753. * The Physically based material base class of BJS.
  44754. *
  44755. * This offers the main features of a standard PBR material.
  44756. * For more information, please refer to the documentation :
  44757. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44758. */
  44759. export abstract class PBRBaseMaterial extends PushMaterial {
  44760. /**
  44761. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44762. */
  44763. static readonly PBRMATERIAL_OPAQUE: number;
  44764. /**
  44765. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44766. */
  44767. static readonly PBRMATERIAL_ALPHATEST: number;
  44768. /**
  44769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44770. */
  44771. static readonly PBRMATERIAL_ALPHABLEND: number;
  44772. /**
  44773. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44774. * They are also discarded below the alpha cutoff threshold to improve performances.
  44775. */
  44776. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44777. /**
  44778. * Defines the default value of how much AO map is occluding the analytical lights
  44779. * (point spot...).
  44780. */
  44781. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44782. /**
  44783. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44784. */
  44785. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44786. /**
  44787. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44788. * to enhance interoperability with other engines.
  44789. */
  44790. static readonly LIGHTFALLOFF_GLTF: number;
  44791. /**
  44792. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44793. * to enhance interoperability with other materials.
  44794. */
  44795. static readonly LIGHTFALLOFF_STANDARD: number;
  44796. /**
  44797. * Intensity of the direct lights e.g. the four lights available in your scene.
  44798. * This impacts both the direct diffuse and specular highlights.
  44799. */
  44800. protected _directIntensity: number;
  44801. /**
  44802. * Intensity of the emissive part of the material.
  44803. * This helps controlling the emissive effect without modifying the emissive color.
  44804. */
  44805. protected _emissiveIntensity: number;
  44806. /**
  44807. * Intensity of the environment e.g. how much the environment will light the object
  44808. * either through harmonics for rough material or through the refelction for shiny ones.
  44809. */
  44810. protected _environmentIntensity: number;
  44811. /**
  44812. * This is a special control allowing the reduction of the specular highlights coming from the
  44813. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44814. */
  44815. protected _specularIntensity: number;
  44816. /**
  44817. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44818. */
  44819. private _lightingInfos;
  44820. /**
  44821. * Debug Control allowing disabling the bump map on this material.
  44822. */
  44823. protected _disableBumpMap: boolean;
  44824. /**
  44825. * AKA Diffuse Texture in standard nomenclature.
  44826. */
  44827. protected _albedoTexture: BaseTexture;
  44828. /**
  44829. * AKA Occlusion Texture in other nomenclature.
  44830. */
  44831. protected _ambientTexture: BaseTexture;
  44832. /**
  44833. * AKA Occlusion Texture Intensity in other nomenclature.
  44834. */
  44835. protected _ambientTextureStrength: number;
  44836. /**
  44837. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44838. * 1 means it completely occludes it
  44839. * 0 mean it has no impact
  44840. */
  44841. protected _ambientTextureImpactOnAnalyticalLights: number;
  44842. /**
  44843. * Stores the alpha values in a texture.
  44844. */
  44845. protected _opacityTexture: BaseTexture;
  44846. /**
  44847. * Stores the reflection values in a texture.
  44848. */
  44849. protected _reflectionTexture: BaseTexture;
  44850. /**
  44851. * Stores the refraction values in a texture.
  44852. */
  44853. protected _refractionTexture: BaseTexture;
  44854. /**
  44855. * Stores the emissive values in a texture.
  44856. */
  44857. protected _emissiveTexture: BaseTexture;
  44858. /**
  44859. * AKA Specular texture in other nomenclature.
  44860. */
  44861. protected _reflectivityTexture: BaseTexture;
  44862. /**
  44863. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44864. */
  44865. protected _metallicTexture: BaseTexture;
  44866. /**
  44867. * Specifies the metallic scalar of the metallic/roughness workflow.
  44868. * Can also be used to scale the metalness values of the metallic texture.
  44869. */
  44870. protected _metallic: Nullable<number>;
  44871. /**
  44872. * Specifies the roughness scalar of the metallic/roughness workflow.
  44873. * Can also be used to scale the roughness values of the metallic texture.
  44874. */
  44875. protected _roughness: Nullable<number>;
  44876. /**
  44877. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44878. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44879. */
  44880. protected _microSurfaceTexture: BaseTexture;
  44881. /**
  44882. * Stores surface normal data used to displace a mesh in a texture.
  44883. */
  44884. protected _bumpTexture: BaseTexture;
  44885. /**
  44886. * Stores the pre-calculated light information of a mesh in a texture.
  44887. */
  44888. protected _lightmapTexture: BaseTexture;
  44889. /**
  44890. * The color of a material in ambient lighting.
  44891. */
  44892. protected _ambientColor: Color3;
  44893. /**
  44894. * AKA Diffuse Color in other nomenclature.
  44895. */
  44896. protected _albedoColor: Color3;
  44897. /**
  44898. * AKA Specular Color in other nomenclature.
  44899. */
  44900. protected _reflectivityColor: Color3;
  44901. /**
  44902. * The color applied when light is reflected from a material.
  44903. */
  44904. protected _reflectionColor: Color3;
  44905. /**
  44906. * The color applied when light is emitted from a material.
  44907. */
  44908. protected _emissiveColor: Color3;
  44909. /**
  44910. * AKA Glossiness in other nomenclature.
  44911. */
  44912. protected _microSurface: number;
  44913. /**
  44914. * source material index of refraction (IOR)' / 'destination material IOR.
  44915. */
  44916. protected _indexOfRefraction: number;
  44917. /**
  44918. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44919. */
  44920. protected _invertRefractionY: boolean;
  44921. /**
  44922. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44923. * Materials half opaque for instance using refraction could benefit from this control.
  44924. */
  44925. protected _linkRefractionWithTransparency: boolean;
  44926. /**
  44927. * Specifies that the material will use the light map as a show map.
  44928. */
  44929. protected _useLightmapAsShadowmap: boolean;
  44930. /**
  44931. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44932. * makes the reflect vector face the model (under horizon).
  44933. */
  44934. protected _useHorizonOcclusion: boolean;
  44935. /**
  44936. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44937. * too much the area relying on ambient texture to define their ambient occlusion.
  44938. */
  44939. protected _useRadianceOcclusion: boolean;
  44940. /**
  44941. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44942. */
  44943. protected _useAlphaFromAlbedoTexture: boolean;
  44944. /**
  44945. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44946. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44947. */
  44948. protected _useSpecularOverAlpha: boolean;
  44949. /**
  44950. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44951. */
  44952. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44953. /**
  44954. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44955. */
  44956. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44957. /**
  44958. * Specifies if the metallic texture contains the roughness information in its green channel.
  44959. */
  44960. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44961. /**
  44962. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44963. */
  44964. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44965. /**
  44966. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44967. */
  44968. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44969. /**
  44970. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44971. */
  44972. protected _useAmbientInGrayScale: boolean;
  44973. /**
  44974. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44975. * The material will try to infer what glossiness each pixel should be.
  44976. */
  44977. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44978. /**
  44979. * Defines the falloff type used in this material.
  44980. * It by default is Physical.
  44981. */
  44982. protected _lightFalloff: number;
  44983. /**
  44984. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44985. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44986. */
  44987. protected _useRadianceOverAlpha: boolean;
  44988. /**
  44989. * Allows using an object space normal map (instead of tangent space).
  44990. */
  44991. protected _useObjectSpaceNormalMap: boolean;
  44992. /**
  44993. * Allows using the bump map in parallax mode.
  44994. */
  44995. protected _useParallax: boolean;
  44996. /**
  44997. * Allows using the bump map in parallax occlusion mode.
  44998. */
  44999. protected _useParallaxOcclusion: boolean;
  45000. /**
  45001. * Controls the scale bias of the parallax mode.
  45002. */
  45003. protected _parallaxScaleBias: number;
  45004. /**
  45005. * If sets to true, disables all the lights affecting the material.
  45006. */
  45007. protected _disableLighting: boolean;
  45008. /**
  45009. * Number of Simultaneous lights allowed on the material.
  45010. */
  45011. protected _maxSimultaneousLights: number;
  45012. /**
  45013. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45014. */
  45015. protected _invertNormalMapX: boolean;
  45016. /**
  45017. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45018. */
  45019. protected _invertNormalMapY: boolean;
  45020. /**
  45021. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45022. */
  45023. protected _twoSidedLighting: boolean;
  45024. /**
  45025. * Defines the alpha limits in alpha test mode.
  45026. */
  45027. protected _alphaCutOff: number;
  45028. /**
  45029. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45030. */
  45031. protected _forceAlphaTest: boolean;
  45032. /**
  45033. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45034. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45035. */
  45036. protected _useAlphaFresnel: boolean;
  45037. /**
  45038. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45039. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45040. */
  45041. protected _useLinearAlphaFresnel: boolean;
  45042. /**
  45043. * The transparency mode of the material.
  45044. */
  45045. protected _transparencyMode: Nullable<number>;
  45046. /**
  45047. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45048. * from cos thetav and roughness:
  45049. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45050. */
  45051. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45052. /**
  45053. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45054. */
  45055. protected _forceIrradianceInFragment: boolean;
  45056. /**
  45057. * Force normal to face away from face.
  45058. */
  45059. protected _forceNormalForward: boolean;
  45060. /**
  45061. * Enables specular anti aliasing in the PBR shader.
  45062. * It will both interacts on the Geometry for analytical and IBL lighting.
  45063. * It also prefilter the roughness map based on the bump values.
  45064. */
  45065. protected _enableSpecularAntiAliasing: boolean;
  45066. /**
  45067. * Default configuration related to image processing available in the PBR Material.
  45068. */
  45069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45070. /**
  45071. * Keep track of the image processing observer to allow dispose and replace.
  45072. */
  45073. private _imageProcessingObserver;
  45074. /**
  45075. * Attaches a new image processing configuration to the PBR Material.
  45076. * @param configuration
  45077. */
  45078. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45079. /**
  45080. * Stores the available render targets.
  45081. */
  45082. private _renderTargets;
  45083. /**
  45084. * Sets the global ambient color for the material used in lighting calculations.
  45085. */
  45086. private _globalAmbientColor;
  45087. /**
  45088. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45089. */
  45090. private _useLogarithmicDepth;
  45091. /**
  45092. * If set to true, no lighting calculations will be applied.
  45093. */
  45094. private _unlit;
  45095. private _debugMode;
  45096. /**
  45097. * @hidden
  45098. * This is reserved for the inspector.
  45099. * Defines the material debug mode.
  45100. * It helps seeing only some components of the material while troubleshooting.
  45101. */
  45102. debugMode: number;
  45103. /**
  45104. * @hidden
  45105. * This is reserved for the inspector.
  45106. * Specify from where on screen the debug mode should start.
  45107. * The value goes from -1 (full screen) to 1 (not visible)
  45108. * It helps with side by side comparison against the final render
  45109. * This defaults to -1
  45110. */
  45111. private debugLimit;
  45112. /**
  45113. * @hidden
  45114. * This is reserved for the inspector.
  45115. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45116. * You can use the factor to better multiply the final value.
  45117. */
  45118. private debugFactor;
  45119. /**
  45120. * Defines the clear coat layer parameters for the material.
  45121. */
  45122. readonly clearCoat: PBRClearCoatConfiguration;
  45123. /**
  45124. * Defines the anisotropic parameters for the material.
  45125. */
  45126. readonly anisotropy: PBRAnisotropicConfiguration;
  45127. /**
  45128. * Defines the BRDF parameters for the material.
  45129. */
  45130. readonly brdf: PBRBRDFConfiguration;
  45131. /**
  45132. * Instantiates a new PBRMaterial instance.
  45133. *
  45134. * @param name The material name
  45135. * @param scene The scene the material will be use in.
  45136. */
  45137. constructor(name: string, scene: Scene);
  45138. /**
  45139. * Gets a boolean indicating that current material needs to register RTT
  45140. */
  45141. readonly hasRenderTargetTextures: boolean;
  45142. /**
  45143. * Gets the name of the material class.
  45144. */
  45145. getClassName(): string;
  45146. /**
  45147. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45148. */
  45149. /**
  45150. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45151. */
  45152. useLogarithmicDepth: boolean;
  45153. /**
  45154. * Gets the current transparency mode.
  45155. */
  45156. /**
  45157. * Sets the transparency mode of the material.
  45158. *
  45159. * | Value | Type | Description |
  45160. * | ----- | ----------------------------------- | ----------- |
  45161. * | 0 | OPAQUE | |
  45162. * | 1 | ALPHATEST | |
  45163. * | 2 | ALPHABLEND | |
  45164. * | 3 | ALPHATESTANDBLEND | |
  45165. *
  45166. */
  45167. transparencyMode: Nullable<number>;
  45168. /**
  45169. * Returns true if alpha blending should be disabled.
  45170. */
  45171. private readonly _disableAlphaBlending;
  45172. /**
  45173. * Specifies whether or not this material should be rendered in alpha blend mode.
  45174. */
  45175. needAlphaBlending(): boolean;
  45176. /**
  45177. * Specifies if the mesh will require alpha blending.
  45178. * @param mesh - BJS mesh.
  45179. */
  45180. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45181. /**
  45182. * Specifies whether or not this material should be rendered in alpha test mode.
  45183. */
  45184. needAlphaTesting(): boolean;
  45185. /**
  45186. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45187. */
  45188. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45189. /**
  45190. * Gets the texture used for the alpha test.
  45191. */
  45192. getAlphaTestTexture(): BaseTexture;
  45193. /**
  45194. * Specifies that the submesh is ready to be used.
  45195. * @param mesh - BJS mesh.
  45196. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45197. * @param useInstances - Specifies that instances should be used.
  45198. * @returns - boolean indicating that the submesh is ready or not.
  45199. */
  45200. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45201. /**
  45202. * Specifies if the material uses metallic roughness workflow.
  45203. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45204. */
  45205. isMetallicWorkflow(): boolean;
  45206. private _prepareEffect;
  45207. private _prepareDefines;
  45208. /**
  45209. * Force shader compilation
  45210. */
  45211. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45212. clipPlane: boolean;
  45213. }>): void;
  45214. /**
  45215. * Initializes the uniform buffer layout for the shader.
  45216. */
  45217. buildUniformLayout(): void;
  45218. /**
  45219. * Unbinds the textures.
  45220. */
  45221. unbind(): void;
  45222. /**
  45223. * Binds the submesh data.
  45224. * @param world - The world matrix.
  45225. * @param mesh - The BJS mesh.
  45226. * @param subMesh - A submesh of the BJS mesh.
  45227. */
  45228. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45229. /**
  45230. * Returns the animatable textures.
  45231. * @returns - Array of animatable textures.
  45232. */
  45233. getAnimatables(): IAnimatable[];
  45234. /**
  45235. * Returns the texture used for reflections.
  45236. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45237. */
  45238. private _getReflectionTexture;
  45239. /**
  45240. * Returns the texture used for refraction or null if none is used.
  45241. * @returns - Refection texture if present. If no refraction texture and refraction
  45242. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45243. */
  45244. private _getRefractionTexture;
  45245. /**
  45246. * Returns an array of the actively used textures.
  45247. * @returns - Array of BaseTextures
  45248. */
  45249. getActiveTextures(): BaseTexture[];
  45250. /**
  45251. * Checks to see if a texture is used in the material.
  45252. * @param texture - Base texture to use.
  45253. * @returns - Boolean specifying if a texture is used in the material.
  45254. */
  45255. hasTexture(texture: BaseTexture): boolean;
  45256. /**
  45257. * Disposes the resources of the material.
  45258. * @param forceDisposeEffect - Forces the disposal of effects.
  45259. * @param forceDisposeTextures - Forces the disposal of all textures.
  45260. */
  45261. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45262. }
  45263. }
  45264. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45265. import { Nullable } from "babylonjs/types";
  45266. import { Scene } from "babylonjs/scene";
  45267. import { Color3 } from "babylonjs/Maths/math";
  45268. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45269. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45271. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45272. /**
  45273. * The Physically based material of BJS.
  45274. *
  45275. * This offers the main features of a standard PBR material.
  45276. * For more information, please refer to the documentation :
  45277. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45278. */
  45279. export class PBRMaterial extends PBRBaseMaterial {
  45280. /**
  45281. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45282. */
  45283. static readonly PBRMATERIAL_OPAQUE: number;
  45284. /**
  45285. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45286. */
  45287. static readonly PBRMATERIAL_ALPHATEST: number;
  45288. /**
  45289. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45290. */
  45291. static readonly PBRMATERIAL_ALPHABLEND: number;
  45292. /**
  45293. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45294. * They are also discarded below the alpha cutoff threshold to improve performances.
  45295. */
  45296. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45297. /**
  45298. * Defines the default value of how much AO map is occluding the analytical lights
  45299. * (point spot...).
  45300. */
  45301. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45302. /**
  45303. * Intensity of the direct lights e.g. the four lights available in your scene.
  45304. * This impacts both the direct diffuse and specular highlights.
  45305. */
  45306. directIntensity: number;
  45307. /**
  45308. * Intensity of the emissive part of the material.
  45309. * This helps controlling the emissive effect without modifying the emissive color.
  45310. */
  45311. emissiveIntensity: number;
  45312. /**
  45313. * Intensity of the environment e.g. how much the environment will light the object
  45314. * either through harmonics for rough material or through the refelction for shiny ones.
  45315. */
  45316. environmentIntensity: number;
  45317. /**
  45318. * This is a special control allowing the reduction of the specular highlights coming from the
  45319. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45320. */
  45321. specularIntensity: number;
  45322. /**
  45323. * Debug Control allowing disabling the bump map on this material.
  45324. */
  45325. disableBumpMap: boolean;
  45326. /**
  45327. * AKA Diffuse Texture in standard nomenclature.
  45328. */
  45329. albedoTexture: BaseTexture;
  45330. /**
  45331. * AKA Occlusion Texture in other nomenclature.
  45332. */
  45333. ambientTexture: BaseTexture;
  45334. /**
  45335. * AKA Occlusion Texture Intensity in other nomenclature.
  45336. */
  45337. ambientTextureStrength: number;
  45338. /**
  45339. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45340. * 1 means it completely occludes it
  45341. * 0 mean it has no impact
  45342. */
  45343. ambientTextureImpactOnAnalyticalLights: number;
  45344. /**
  45345. * Stores the alpha values in a texture.
  45346. */
  45347. opacityTexture: BaseTexture;
  45348. /**
  45349. * Stores the reflection values in a texture.
  45350. */
  45351. reflectionTexture: Nullable<BaseTexture>;
  45352. /**
  45353. * Stores the emissive values in a texture.
  45354. */
  45355. emissiveTexture: BaseTexture;
  45356. /**
  45357. * AKA Specular texture in other nomenclature.
  45358. */
  45359. reflectivityTexture: BaseTexture;
  45360. /**
  45361. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45362. */
  45363. metallicTexture: BaseTexture;
  45364. /**
  45365. * Specifies the metallic scalar of the metallic/roughness workflow.
  45366. * Can also be used to scale the metalness values of the metallic texture.
  45367. */
  45368. metallic: Nullable<number>;
  45369. /**
  45370. * Specifies the roughness scalar of the metallic/roughness workflow.
  45371. * Can also be used to scale the roughness values of the metallic texture.
  45372. */
  45373. roughness: Nullable<number>;
  45374. /**
  45375. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45376. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45377. */
  45378. microSurfaceTexture: BaseTexture;
  45379. /**
  45380. * Stores surface normal data used to displace a mesh in a texture.
  45381. */
  45382. bumpTexture: BaseTexture;
  45383. /**
  45384. * Stores the pre-calculated light information of a mesh in a texture.
  45385. */
  45386. lightmapTexture: BaseTexture;
  45387. /**
  45388. * Stores the refracted light information in a texture.
  45389. */
  45390. refractionTexture: BaseTexture;
  45391. /**
  45392. * The color of a material in ambient lighting.
  45393. */
  45394. ambientColor: Color3;
  45395. /**
  45396. * AKA Diffuse Color in other nomenclature.
  45397. */
  45398. albedoColor: Color3;
  45399. /**
  45400. * AKA Specular Color in other nomenclature.
  45401. */
  45402. reflectivityColor: Color3;
  45403. /**
  45404. * The color reflected from the material.
  45405. */
  45406. reflectionColor: Color3;
  45407. /**
  45408. * The color emitted from the material.
  45409. */
  45410. emissiveColor: Color3;
  45411. /**
  45412. * AKA Glossiness in other nomenclature.
  45413. */
  45414. microSurface: number;
  45415. /**
  45416. * source material index of refraction (IOR)' / 'destination material IOR.
  45417. */
  45418. indexOfRefraction: number;
  45419. /**
  45420. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45421. */
  45422. invertRefractionY: boolean;
  45423. /**
  45424. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45425. * Materials half opaque for instance using refraction could benefit from this control.
  45426. */
  45427. linkRefractionWithTransparency: boolean;
  45428. /**
  45429. * If true, the light map contains occlusion information instead of lighting info.
  45430. */
  45431. useLightmapAsShadowmap: boolean;
  45432. /**
  45433. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45434. */
  45435. useAlphaFromAlbedoTexture: boolean;
  45436. /**
  45437. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45438. */
  45439. forceAlphaTest: boolean;
  45440. /**
  45441. * Defines the alpha limits in alpha test mode.
  45442. */
  45443. alphaCutOff: number;
  45444. /**
  45445. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45446. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45447. */
  45448. useSpecularOverAlpha: boolean;
  45449. /**
  45450. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45451. */
  45452. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45453. /**
  45454. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45455. */
  45456. useRoughnessFromMetallicTextureAlpha: boolean;
  45457. /**
  45458. * Specifies if the metallic texture contains the roughness information in its green channel.
  45459. */
  45460. useRoughnessFromMetallicTextureGreen: boolean;
  45461. /**
  45462. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45463. */
  45464. useMetallnessFromMetallicTextureBlue: boolean;
  45465. /**
  45466. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45467. */
  45468. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45469. /**
  45470. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45471. */
  45472. useAmbientInGrayScale: boolean;
  45473. /**
  45474. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45475. * The material will try to infer what glossiness each pixel should be.
  45476. */
  45477. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45478. /**
  45479. * BJS is using an harcoded light falloff based on a manually sets up range.
  45480. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45481. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45482. */
  45483. /**
  45484. * BJS is using an harcoded light falloff based on a manually sets up range.
  45485. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45486. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45487. */
  45488. usePhysicalLightFalloff: boolean;
  45489. /**
  45490. * In order to support the falloff compatibility with gltf, a special mode has been added
  45491. * to reproduce the gltf light falloff.
  45492. */
  45493. /**
  45494. * In order to support the falloff compatibility with gltf, a special mode has been added
  45495. * to reproduce the gltf light falloff.
  45496. */
  45497. useGLTFLightFalloff: boolean;
  45498. /**
  45499. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45500. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45501. */
  45502. useRadianceOverAlpha: boolean;
  45503. /**
  45504. * Allows using an object space normal map (instead of tangent space).
  45505. */
  45506. useObjectSpaceNormalMap: boolean;
  45507. /**
  45508. * Allows using the bump map in parallax mode.
  45509. */
  45510. useParallax: boolean;
  45511. /**
  45512. * Allows using the bump map in parallax occlusion mode.
  45513. */
  45514. useParallaxOcclusion: boolean;
  45515. /**
  45516. * Controls the scale bias of the parallax mode.
  45517. */
  45518. parallaxScaleBias: number;
  45519. /**
  45520. * If sets to true, disables all the lights affecting the material.
  45521. */
  45522. disableLighting: boolean;
  45523. /**
  45524. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45525. */
  45526. forceIrradianceInFragment: boolean;
  45527. /**
  45528. * Number of Simultaneous lights allowed on the material.
  45529. */
  45530. maxSimultaneousLights: number;
  45531. /**
  45532. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45533. */
  45534. invertNormalMapX: boolean;
  45535. /**
  45536. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45537. */
  45538. invertNormalMapY: boolean;
  45539. /**
  45540. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45541. */
  45542. twoSidedLighting: boolean;
  45543. /**
  45544. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45545. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45546. */
  45547. useAlphaFresnel: boolean;
  45548. /**
  45549. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45550. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45551. */
  45552. useLinearAlphaFresnel: boolean;
  45553. /**
  45554. * Let user defines the brdf lookup texture used for IBL.
  45555. * A default 8bit version is embedded but you could point at :
  45556. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45557. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45558. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45559. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45560. */
  45561. environmentBRDFTexture: Nullable<BaseTexture>;
  45562. /**
  45563. * Force normal to face away from face.
  45564. */
  45565. forceNormalForward: boolean;
  45566. /**
  45567. * Enables specular anti aliasing in the PBR shader.
  45568. * It will both interacts on the Geometry for analytical and IBL lighting.
  45569. * It also prefilter the roughness map based on the bump values.
  45570. */
  45571. enableSpecularAntiAliasing: boolean;
  45572. /**
  45573. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45574. * makes the reflect vector face the model (under horizon).
  45575. */
  45576. useHorizonOcclusion: boolean;
  45577. /**
  45578. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45579. * too much the area relying on ambient texture to define their ambient occlusion.
  45580. */
  45581. useRadianceOcclusion: boolean;
  45582. /**
  45583. * If set to true, no lighting calculations will be applied.
  45584. */
  45585. unlit: boolean;
  45586. /**
  45587. * Gets the image processing configuration used either in this material.
  45588. */
  45589. /**
  45590. * Sets the Default image processing configuration used either in the this material.
  45591. *
  45592. * If sets to null, the scene one is in use.
  45593. */
  45594. imageProcessingConfiguration: ImageProcessingConfiguration;
  45595. /**
  45596. * Gets wether the color curves effect is enabled.
  45597. */
  45598. /**
  45599. * Sets wether the color curves effect is enabled.
  45600. */
  45601. cameraColorCurvesEnabled: boolean;
  45602. /**
  45603. * Gets wether the color grading effect is enabled.
  45604. */
  45605. /**
  45606. * Gets wether the color grading effect is enabled.
  45607. */
  45608. cameraColorGradingEnabled: boolean;
  45609. /**
  45610. * Gets wether tonemapping is enabled or not.
  45611. */
  45612. /**
  45613. * Sets wether tonemapping is enabled or not
  45614. */
  45615. cameraToneMappingEnabled: boolean;
  45616. /**
  45617. * The camera exposure used on this material.
  45618. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45619. * This corresponds to a photographic exposure.
  45620. */
  45621. /**
  45622. * The camera exposure used on this material.
  45623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45624. * This corresponds to a photographic exposure.
  45625. */
  45626. cameraExposure: number;
  45627. /**
  45628. * Gets The camera contrast used on this material.
  45629. */
  45630. /**
  45631. * Sets The camera contrast used on this material.
  45632. */
  45633. cameraContrast: number;
  45634. /**
  45635. * Gets the Color Grading 2D Lookup Texture.
  45636. */
  45637. /**
  45638. * Sets the Color Grading 2D Lookup Texture.
  45639. */
  45640. cameraColorGradingTexture: Nullable<BaseTexture>;
  45641. /**
  45642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45644. * 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;
  45645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45646. */
  45647. /**
  45648. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45649. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45650. * 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;
  45651. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45652. */
  45653. cameraColorCurves: Nullable<ColorCurves>;
  45654. /**
  45655. * Instantiates a new PBRMaterial instance.
  45656. *
  45657. * @param name The material name
  45658. * @param scene The scene the material will be use in.
  45659. */
  45660. constructor(name: string, scene: Scene);
  45661. /**
  45662. * Returns the name of this material class.
  45663. */
  45664. getClassName(): string;
  45665. /**
  45666. * Makes a duplicate of the current material.
  45667. * @param name - name to use for the new material.
  45668. */
  45669. clone(name: string): PBRMaterial;
  45670. /**
  45671. * Serializes this PBR Material.
  45672. * @returns - An object with the serialized material.
  45673. */
  45674. serialize(): any;
  45675. /**
  45676. * Parses a PBR Material from a serialized object.
  45677. * @param source - Serialized object.
  45678. * @param scene - BJS scene instance.
  45679. * @param rootUrl - url for the scene object
  45680. * @returns - PBRMaterial
  45681. */
  45682. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45683. }
  45684. }
  45685. declare module "babylonjs/Helpers/sceneHelpers" {
  45686. import { Nullable } from "babylonjs/types";
  45687. import { Mesh } from "babylonjs/Meshes/mesh";
  45688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45689. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45690. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45691. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45692. import "babylonjs/Meshes/Builders/boxBuilder";
  45693. /** @hidden */
  45694. export var _forceSceneHelpersToBundle: boolean;
  45695. module "babylonjs/scene" {
  45696. interface Scene {
  45697. /**
  45698. * Creates a default light for the scene.
  45699. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45700. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45701. */
  45702. createDefaultLight(replace?: boolean): void;
  45703. /**
  45704. * Creates a default camera for the scene.
  45705. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45706. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45707. * @param replace has default false, when true replaces the active camera in the scene
  45708. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45709. */
  45710. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45711. /**
  45712. * Creates a default camera and a default light.
  45713. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45714. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45715. * @param replace has the default false, when true replaces the active camera/light in the scene
  45716. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45717. */
  45718. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45719. /**
  45720. * Creates a new sky box
  45721. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45722. * @param environmentTexture defines the texture to use as environment texture
  45723. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45724. * @param scale defines the overall scale of the skybox
  45725. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45726. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45727. * @returns a new mesh holding the sky box
  45728. */
  45729. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45730. /**
  45731. * Creates a new environment
  45732. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45733. * @param options defines the options you can use to configure the environment
  45734. * @returns the new EnvironmentHelper
  45735. */
  45736. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45737. /**
  45738. * Creates a new VREXperienceHelper
  45739. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45740. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45741. * @returns a new VREXperienceHelper
  45742. */
  45743. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45744. /**
  45745. * Creates a new XREXperienceHelper
  45746. * @see http://doc.babylonjs.com/how_to/webxr
  45747. * @returns a promise for a new XREXperienceHelper
  45748. */
  45749. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45750. }
  45751. }
  45752. }
  45753. declare module "babylonjs/Helpers/videoDome" {
  45754. import { Scene } from "babylonjs/scene";
  45755. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45756. import { Mesh } from "babylonjs/Meshes/mesh";
  45757. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45758. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45759. import "babylonjs/Meshes/Builders/sphereBuilder";
  45760. /**
  45761. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45762. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45763. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45764. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45765. */
  45766. export class VideoDome extends TransformNode {
  45767. /**
  45768. * Define the video source as a Monoscopic panoramic 360 video.
  45769. */
  45770. static readonly MODE_MONOSCOPIC: number;
  45771. /**
  45772. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45773. */
  45774. static readonly MODE_TOPBOTTOM: number;
  45775. /**
  45776. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45777. */
  45778. static readonly MODE_SIDEBYSIDE: number;
  45779. private _useDirectMapping;
  45780. /**
  45781. * The video texture being displayed on the sphere
  45782. */
  45783. protected _videoTexture: VideoTexture;
  45784. /**
  45785. * Gets the video texture being displayed on the sphere
  45786. */
  45787. readonly videoTexture: VideoTexture;
  45788. /**
  45789. * The skybox material
  45790. */
  45791. protected _material: BackgroundMaterial;
  45792. /**
  45793. * The surface used for the skybox
  45794. */
  45795. protected _mesh: Mesh;
  45796. /**
  45797. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45798. * Also see the options.resolution property.
  45799. */
  45800. fovMultiplier: number;
  45801. private _videoMode;
  45802. /**
  45803. * Gets or set the current video mode for the video. It can be:
  45804. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45805. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45806. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45807. */
  45808. videoMode: number;
  45809. /**
  45810. * Oberserver used in Stereoscopic VR Mode.
  45811. */
  45812. private _onBeforeCameraRenderObserver;
  45813. /**
  45814. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45815. * @param name Element's name, child elements will append suffixes for their own names.
  45816. * @param urlsOrVideo defines the url(s) or the video element to use
  45817. * @param options An object containing optional or exposed sub element properties
  45818. */
  45819. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45820. resolution?: number;
  45821. clickToPlay?: boolean;
  45822. autoPlay?: boolean;
  45823. loop?: boolean;
  45824. size?: number;
  45825. poster?: string;
  45826. useDirectMapping?: boolean;
  45827. }, scene: Scene);
  45828. private _changeVideoMode;
  45829. /**
  45830. * Releases resources associated with this node.
  45831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45833. */
  45834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45835. }
  45836. }
  45837. declare module "babylonjs/Helpers/index" {
  45838. export * from "babylonjs/Helpers/environmentHelper";
  45839. export * from "babylonjs/Helpers/photoDome";
  45840. export * from "babylonjs/Helpers/sceneHelpers";
  45841. export * from "babylonjs/Helpers/videoDome";
  45842. }
  45843. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45844. import { PerfCounter } from "babylonjs/Misc/tools";
  45845. import { IDisposable } from "babylonjs/scene";
  45846. import { Engine } from "babylonjs/Engines/engine";
  45847. /**
  45848. * This class can be used to get instrumentation data from a Babylon engine
  45849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45850. */
  45851. export class EngineInstrumentation implements IDisposable {
  45852. /**
  45853. * Define the instrumented engine.
  45854. */
  45855. engine: Engine;
  45856. private _captureGPUFrameTime;
  45857. private _gpuFrameTimeToken;
  45858. private _gpuFrameTime;
  45859. private _captureShaderCompilationTime;
  45860. private _shaderCompilationTime;
  45861. private _onBeginFrameObserver;
  45862. private _onEndFrameObserver;
  45863. private _onBeforeShaderCompilationObserver;
  45864. private _onAfterShaderCompilationObserver;
  45865. /**
  45866. * Gets the perf counter used for GPU frame time
  45867. */
  45868. readonly gpuFrameTimeCounter: PerfCounter;
  45869. /**
  45870. * Gets the GPU frame time capture status
  45871. */
  45872. /**
  45873. * Enable or disable the GPU frame time capture
  45874. */
  45875. captureGPUFrameTime: boolean;
  45876. /**
  45877. * Gets the perf counter used for shader compilation time
  45878. */
  45879. readonly shaderCompilationTimeCounter: PerfCounter;
  45880. /**
  45881. * Gets the shader compilation time capture status
  45882. */
  45883. /**
  45884. * Enable or disable the shader compilation time capture
  45885. */
  45886. captureShaderCompilationTime: boolean;
  45887. /**
  45888. * Instantiates a new engine instrumentation.
  45889. * This class can be used to get instrumentation data from a Babylon engine
  45890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45891. * @param engine Defines the engine to instrument
  45892. */
  45893. constructor(
  45894. /**
  45895. * Define the instrumented engine.
  45896. */
  45897. engine: Engine);
  45898. /**
  45899. * Dispose and release associated resources.
  45900. */
  45901. dispose(): void;
  45902. }
  45903. }
  45904. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45905. import { PerfCounter } from "babylonjs/Misc/tools";
  45906. import { Scene, IDisposable } from "babylonjs/scene";
  45907. /**
  45908. * This class can be used to get instrumentation data from a Babylon engine
  45909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45910. */
  45911. export class SceneInstrumentation implements IDisposable {
  45912. /**
  45913. * Defines the scene to instrument
  45914. */
  45915. scene: Scene;
  45916. private _captureActiveMeshesEvaluationTime;
  45917. private _activeMeshesEvaluationTime;
  45918. private _captureRenderTargetsRenderTime;
  45919. private _renderTargetsRenderTime;
  45920. private _captureFrameTime;
  45921. private _frameTime;
  45922. private _captureRenderTime;
  45923. private _renderTime;
  45924. private _captureInterFrameTime;
  45925. private _interFrameTime;
  45926. private _captureParticlesRenderTime;
  45927. private _particlesRenderTime;
  45928. private _captureSpritesRenderTime;
  45929. private _spritesRenderTime;
  45930. private _capturePhysicsTime;
  45931. private _physicsTime;
  45932. private _captureAnimationsTime;
  45933. private _animationsTime;
  45934. private _captureCameraRenderTime;
  45935. private _cameraRenderTime;
  45936. private _onBeforeActiveMeshesEvaluationObserver;
  45937. private _onAfterActiveMeshesEvaluationObserver;
  45938. private _onBeforeRenderTargetsRenderObserver;
  45939. private _onAfterRenderTargetsRenderObserver;
  45940. private _onAfterRenderObserver;
  45941. private _onBeforeDrawPhaseObserver;
  45942. private _onAfterDrawPhaseObserver;
  45943. private _onBeforeAnimationsObserver;
  45944. private _onBeforeParticlesRenderingObserver;
  45945. private _onAfterParticlesRenderingObserver;
  45946. private _onBeforeSpritesRenderingObserver;
  45947. private _onAfterSpritesRenderingObserver;
  45948. private _onBeforePhysicsObserver;
  45949. private _onAfterPhysicsObserver;
  45950. private _onAfterAnimationsObserver;
  45951. private _onBeforeCameraRenderObserver;
  45952. private _onAfterCameraRenderObserver;
  45953. /**
  45954. * Gets the perf counter used for active meshes evaluation time
  45955. */
  45956. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45957. /**
  45958. * Gets the active meshes evaluation time capture status
  45959. */
  45960. /**
  45961. * Enable or disable the active meshes evaluation time capture
  45962. */
  45963. captureActiveMeshesEvaluationTime: boolean;
  45964. /**
  45965. * Gets the perf counter used for render targets render time
  45966. */
  45967. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45968. /**
  45969. * Gets the render targets render time capture status
  45970. */
  45971. /**
  45972. * Enable or disable the render targets render time capture
  45973. */
  45974. captureRenderTargetsRenderTime: boolean;
  45975. /**
  45976. * Gets the perf counter used for particles render time
  45977. */
  45978. readonly particlesRenderTimeCounter: PerfCounter;
  45979. /**
  45980. * Gets the particles render time capture status
  45981. */
  45982. /**
  45983. * Enable or disable the particles render time capture
  45984. */
  45985. captureParticlesRenderTime: boolean;
  45986. /**
  45987. * Gets the perf counter used for sprites render time
  45988. */
  45989. readonly spritesRenderTimeCounter: PerfCounter;
  45990. /**
  45991. * Gets the sprites render time capture status
  45992. */
  45993. /**
  45994. * Enable or disable the sprites render time capture
  45995. */
  45996. captureSpritesRenderTime: boolean;
  45997. /**
  45998. * Gets the perf counter used for physics time
  45999. */
  46000. readonly physicsTimeCounter: PerfCounter;
  46001. /**
  46002. * Gets the physics time capture status
  46003. */
  46004. /**
  46005. * Enable or disable the physics time capture
  46006. */
  46007. capturePhysicsTime: boolean;
  46008. /**
  46009. * Gets the perf counter used for animations time
  46010. */
  46011. readonly animationsTimeCounter: PerfCounter;
  46012. /**
  46013. * Gets the animations time capture status
  46014. */
  46015. /**
  46016. * Enable or disable the animations time capture
  46017. */
  46018. captureAnimationsTime: boolean;
  46019. /**
  46020. * Gets the perf counter used for frame time capture
  46021. */
  46022. readonly frameTimeCounter: PerfCounter;
  46023. /**
  46024. * Gets the frame time capture status
  46025. */
  46026. /**
  46027. * Enable or disable the frame time capture
  46028. */
  46029. captureFrameTime: boolean;
  46030. /**
  46031. * Gets the perf counter used for inter-frames time capture
  46032. */
  46033. readonly interFrameTimeCounter: PerfCounter;
  46034. /**
  46035. * Gets the inter-frames time capture status
  46036. */
  46037. /**
  46038. * Enable or disable the inter-frames time capture
  46039. */
  46040. captureInterFrameTime: boolean;
  46041. /**
  46042. * Gets the perf counter used for render time capture
  46043. */
  46044. readonly renderTimeCounter: PerfCounter;
  46045. /**
  46046. * Gets the render time capture status
  46047. */
  46048. /**
  46049. * Enable or disable the render time capture
  46050. */
  46051. captureRenderTime: boolean;
  46052. /**
  46053. * Gets the perf counter used for camera render time capture
  46054. */
  46055. readonly cameraRenderTimeCounter: PerfCounter;
  46056. /**
  46057. * Gets the camera render time capture status
  46058. */
  46059. /**
  46060. * Enable or disable the camera render time capture
  46061. */
  46062. captureCameraRenderTime: boolean;
  46063. /**
  46064. * Gets the perf counter used for draw calls
  46065. */
  46066. readonly drawCallsCounter: PerfCounter;
  46067. /**
  46068. * Gets the perf counter used for texture collisions
  46069. */
  46070. readonly textureCollisionsCounter: PerfCounter;
  46071. /**
  46072. * Instantiates a new scene instrumentation.
  46073. * This class can be used to get instrumentation data from a Babylon engine
  46074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46075. * @param scene Defines the scene to instrument
  46076. */
  46077. constructor(
  46078. /**
  46079. * Defines the scene to instrument
  46080. */
  46081. scene: Scene);
  46082. /**
  46083. * Dispose and release associated resources.
  46084. */
  46085. dispose(): void;
  46086. }
  46087. }
  46088. declare module "babylonjs/Instrumentation/index" {
  46089. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46090. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46091. export * from "babylonjs/Instrumentation/timeToken";
  46092. }
  46093. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46094. /** @hidden */
  46095. export var glowMapGenerationPixelShader: {
  46096. name: string;
  46097. shader: string;
  46098. };
  46099. }
  46100. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46101. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46103. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46104. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46105. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46106. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46107. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46108. /** @hidden */
  46109. export var glowMapGenerationVertexShader: {
  46110. name: string;
  46111. shader: string;
  46112. };
  46113. }
  46114. declare module "babylonjs/Layers/effectLayer" {
  46115. import { Observable } from "babylonjs/Misc/observable";
  46116. import { Nullable } from "babylonjs/types";
  46117. import { Camera } from "babylonjs/Cameras/camera";
  46118. import { Scene } from "babylonjs/scene";
  46119. import { Color4, ISize } from "babylonjs/Maths/math";
  46120. import { Engine } from "babylonjs/Engines/engine";
  46121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46123. import { Mesh } from "babylonjs/Meshes/mesh";
  46124. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46126. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46127. import { Effect } from "babylonjs/Materials/effect";
  46128. import { Material } from "babylonjs/Materials/material";
  46129. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46130. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46131. /**
  46132. * Effect layer options. This helps customizing the behaviour
  46133. * of the effect layer.
  46134. */
  46135. export interface IEffectLayerOptions {
  46136. /**
  46137. * Multiplication factor apply to the canvas size to compute the render target size
  46138. * used to generated the objects (the smaller the faster).
  46139. */
  46140. mainTextureRatio: number;
  46141. /**
  46142. * Enforces a fixed size texture to ensure effect stability across devices.
  46143. */
  46144. mainTextureFixedSize?: number;
  46145. /**
  46146. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46147. */
  46148. alphaBlendingMode: number;
  46149. /**
  46150. * The camera attached to the layer.
  46151. */
  46152. camera: Nullable<Camera>;
  46153. /**
  46154. * The rendering group to draw the layer in.
  46155. */
  46156. renderingGroupId: number;
  46157. }
  46158. /**
  46159. * The effect layer Helps adding post process effect blended with the main pass.
  46160. *
  46161. * This can be for instance use to generate glow or higlight effects on the scene.
  46162. *
  46163. * The effect layer class can not be used directly and is intented to inherited from to be
  46164. * customized per effects.
  46165. */
  46166. export abstract class EffectLayer {
  46167. private _vertexBuffers;
  46168. private _indexBuffer;
  46169. private _cachedDefines;
  46170. private _effectLayerMapGenerationEffect;
  46171. private _effectLayerOptions;
  46172. private _mergeEffect;
  46173. protected _scene: Scene;
  46174. protected _engine: Engine;
  46175. protected _maxSize: number;
  46176. protected _mainTextureDesiredSize: ISize;
  46177. protected _mainTexture: RenderTargetTexture;
  46178. protected _shouldRender: boolean;
  46179. protected _postProcesses: PostProcess[];
  46180. protected _textures: BaseTexture[];
  46181. protected _emissiveTextureAndColor: {
  46182. texture: Nullable<BaseTexture>;
  46183. color: Color4;
  46184. };
  46185. /**
  46186. * The name of the layer
  46187. */
  46188. name: string;
  46189. /**
  46190. * The clear color of the texture used to generate the glow map.
  46191. */
  46192. neutralColor: Color4;
  46193. /**
  46194. * Specifies wether the highlight layer is enabled or not.
  46195. */
  46196. isEnabled: boolean;
  46197. /**
  46198. * Gets the camera attached to the layer.
  46199. */
  46200. readonly camera: Nullable<Camera>;
  46201. /**
  46202. * Gets the rendering group id the layer should render in.
  46203. */
  46204. readonly renderingGroupId: number;
  46205. /**
  46206. * An event triggered when the effect layer has been disposed.
  46207. */
  46208. onDisposeObservable: Observable<EffectLayer>;
  46209. /**
  46210. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46211. */
  46212. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46213. /**
  46214. * An event triggered when the generated texture is being merged in the scene.
  46215. */
  46216. onBeforeComposeObservable: Observable<EffectLayer>;
  46217. /**
  46218. * An event triggered when the generated texture has been merged in the scene.
  46219. */
  46220. onAfterComposeObservable: Observable<EffectLayer>;
  46221. /**
  46222. * An event triggered when the efffect layer changes its size.
  46223. */
  46224. onSizeChangedObservable: Observable<EffectLayer>;
  46225. /** @hidden */
  46226. static _SceneComponentInitialization: (scene: Scene) => void;
  46227. /**
  46228. * Instantiates a new effect Layer and references it in the scene.
  46229. * @param name The name of the layer
  46230. * @param scene The scene to use the layer in
  46231. */
  46232. constructor(
  46233. /** The Friendly of the effect in the scene */
  46234. name: string, scene: Scene);
  46235. /**
  46236. * Get the effect name of the layer.
  46237. * @return The effect name
  46238. */
  46239. abstract getEffectName(): string;
  46240. /**
  46241. * Checks for the readiness of the element composing the layer.
  46242. * @param subMesh the mesh to check for
  46243. * @param useInstances specify wether or not to use instances to render the mesh
  46244. * @return true if ready otherwise, false
  46245. */
  46246. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46247. /**
  46248. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46249. * @returns true if the effect requires stencil during the main canvas render pass.
  46250. */
  46251. abstract needStencil(): boolean;
  46252. /**
  46253. * Create the merge effect. This is the shader use to blit the information back
  46254. * to the main canvas at the end of the scene rendering.
  46255. * @returns The effect containing the shader used to merge the effect on the main canvas
  46256. */
  46257. protected abstract _createMergeEffect(): Effect;
  46258. /**
  46259. * Creates the render target textures and post processes used in the effect layer.
  46260. */
  46261. protected abstract _createTextureAndPostProcesses(): void;
  46262. /**
  46263. * Implementation specific of rendering the generating effect on the main canvas.
  46264. * @param effect The effect used to render through
  46265. */
  46266. protected abstract _internalRender(effect: Effect): void;
  46267. /**
  46268. * Sets the required values for both the emissive texture and and the main color.
  46269. */
  46270. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46271. /**
  46272. * Free any resources and references associated to a mesh.
  46273. * Internal use
  46274. * @param mesh The mesh to free.
  46275. */
  46276. abstract _disposeMesh(mesh: Mesh): void;
  46277. /**
  46278. * Serializes this layer (Glow or Highlight for example)
  46279. * @returns a serialized layer object
  46280. */
  46281. abstract serialize?(): any;
  46282. /**
  46283. * Initializes the effect layer with the required options.
  46284. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46285. */
  46286. protected _init(options: Partial<IEffectLayerOptions>): void;
  46287. /**
  46288. * Generates the index buffer of the full screen quad blending to the main canvas.
  46289. */
  46290. private _generateIndexBuffer;
  46291. /**
  46292. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46293. */
  46294. private _genrateVertexBuffer;
  46295. /**
  46296. * Sets the main texture desired size which is the closest power of two
  46297. * of the engine canvas size.
  46298. */
  46299. private _setMainTextureSize;
  46300. /**
  46301. * Creates the main texture for the effect layer.
  46302. */
  46303. protected _createMainTexture(): void;
  46304. /**
  46305. * Adds specific effects defines.
  46306. * @param defines The defines to add specifics to.
  46307. */
  46308. protected _addCustomEffectDefines(defines: string[]): void;
  46309. /**
  46310. * Checks for the readiness of the element composing the layer.
  46311. * @param subMesh the mesh to check for
  46312. * @param useInstances specify wether or not to use instances to render the mesh
  46313. * @param emissiveTexture the associated emissive texture used to generate the glow
  46314. * @return true if ready otherwise, false
  46315. */
  46316. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46317. /**
  46318. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46319. */
  46320. render(): void;
  46321. /**
  46322. * Determine if a given mesh will be used in the current effect.
  46323. * @param mesh mesh to test
  46324. * @returns true if the mesh will be used
  46325. */
  46326. hasMesh(mesh: AbstractMesh): boolean;
  46327. /**
  46328. * Returns true if the layer contains information to display, otherwise false.
  46329. * @returns true if the glow layer should be rendered
  46330. */
  46331. shouldRender(): boolean;
  46332. /**
  46333. * Returns true if the mesh should render, otherwise false.
  46334. * @param mesh The mesh to render
  46335. * @returns true if it should render otherwise false
  46336. */
  46337. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46338. /**
  46339. * Returns true if the mesh can be rendered, otherwise false.
  46340. * @param mesh The mesh to render
  46341. * @param material The material used on the mesh
  46342. * @returns true if it can be rendered otherwise false
  46343. */
  46344. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46345. /**
  46346. * Returns true if the mesh should render, otherwise false.
  46347. * @param mesh The mesh to render
  46348. * @returns true if it should render otherwise false
  46349. */
  46350. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46351. /**
  46352. * Renders the submesh passed in parameter to the generation map.
  46353. */
  46354. protected _renderSubMesh(subMesh: SubMesh): void;
  46355. /**
  46356. * Rebuild the required buffers.
  46357. * @hidden Internal use only.
  46358. */
  46359. _rebuild(): void;
  46360. /**
  46361. * Dispose only the render target textures and post process.
  46362. */
  46363. private _disposeTextureAndPostProcesses;
  46364. /**
  46365. * Dispose the highlight layer and free resources.
  46366. */
  46367. dispose(): void;
  46368. /**
  46369. * Gets the class name of the effect layer
  46370. * @returns the string with the class name of the effect layer
  46371. */
  46372. getClassName(): string;
  46373. /**
  46374. * Creates an effect layer from parsed effect layer data
  46375. * @param parsedEffectLayer defines effect layer data
  46376. * @param scene defines the current scene
  46377. * @param rootUrl defines the root URL containing the effect layer information
  46378. * @returns a parsed effect Layer
  46379. */
  46380. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46381. }
  46382. }
  46383. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46384. import { Scene } from "babylonjs/scene";
  46385. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46386. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46387. import { AbstractScene } from "babylonjs/abstractScene";
  46388. module "babylonjs/abstractScene" {
  46389. interface AbstractScene {
  46390. /**
  46391. * The list of effect layers (highlights/glow) added to the scene
  46392. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46393. * @see http://doc.babylonjs.com/how_to/glow_layer
  46394. */
  46395. effectLayers: Array<EffectLayer>;
  46396. /**
  46397. * Removes the given effect layer from this scene.
  46398. * @param toRemove defines the effect layer to remove
  46399. * @returns the index of the removed effect layer
  46400. */
  46401. removeEffectLayer(toRemove: EffectLayer): number;
  46402. /**
  46403. * Adds the given effect layer to this scene
  46404. * @param newEffectLayer defines the effect layer to add
  46405. */
  46406. addEffectLayer(newEffectLayer: EffectLayer): void;
  46407. }
  46408. }
  46409. /**
  46410. * Defines the layer scene component responsible to manage any effect layers
  46411. * in a given scene.
  46412. */
  46413. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46414. /**
  46415. * The component name helpfull to identify the component in the list of scene components.
  46416. */
  46417. readonly name: string;
  46418. /**
  46419. * The scene the component belongs to.
  46420. */
  46421. scene: Scene;
  46422. private _engine;
  46423. private _renderEffects;
  46424. private _needStencil;
  46425. private _previousStencilState;
  46426. /**
  46427. * Creates a new instance of the component for the given scene
  46428. * @param scene Defines the scene to register the component in
  46429. */
  46430. constructor(scene: Scene);
  46431. /**
  46432. * Registers the component in a given scene
  46433. */
  46434. register(): void;
  46435. /**
  46436. * Rebuilds the elements related to this component in case of
  46437. * context lost for instance.
  46438. */
  46439. rebuild(): void;
  46440. /**
  46441. * Serializes the component data to the specified json object
  46442. * @param serializationObject The object to serialize to
  46443. */
  46444. serialize(serializationObject: any): void;
  46445. /**
  46446. * Adds all the element from the container to the scene
  46447. * @param container the container holding the elements
  46448. */
  46449. addFromContainer(container: AbstractScene): void;
  46450. /**
  46451. * Removes all the elements in the container from the scene
  46452. * @param container contains the elements to remove
  46453. */
  46454. removeFromContainer(container: AbstractScene): void;
  46455. /**
  46456. * Disposes the component and the associated ressources.
  46457. */
  46458. dispose(): void;
  46459. private _isReadyForMesh;
  46460. private _renderMainTexture;
  46461. private _setStencil;
  46462. private _setStencilBack;
  46463. private _draw;
  46464. private _drawCamera;
  46465. private _drawRenderingGroup;
  46466. }
  46467. }
  46468. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46469. /** @hidden */
  46470. export var glowMapMergePixelShader: {
  46471. name: string;
  46472. shader: string;
  46473. };
  46474. }
  46475. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46476. /** @hidden */
  46477. export var glowMapMergeVertexShader: {
  46478. name: string;
  46479. shader: string;
  46480. };
  46481. }
  46482. declare module "babylonjs/Layers/glowLayer" {
  46483. import { Nullable } from "babylonjs/types";
  46484. import { Camera } from "babylonjs/Cameras/camera";
  46485. import { Scene } from "babylonjs/scene";
  46486. import { Color4 } from "babylonjs/Maths/math";
  46487. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46489. import { Mesh } from "babylonjs/Meshes/mesh";
  46490. import { Texture } from "babylonjs/Materials/Textures/texture";
  46491. import { Effect } from "babylonjs/Materials/effect";
  46492. import { Material } from "babylonjs/Materials/material";
  46493. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46494. import "babylonjs/Shaders/glowMapMerge.fragment";
  46495. import "babylonjs/Shaders/glowMapMerge.vertex";
  46496. module "babylonjs/abstractScene" {
  46497. interface AbstractScene {
  46498. /**
  46499. * Return a the first highlight layer of the scene with a given name.
  46500. * @param name The name of the highlight layer to look for.
  46501. * @return The highlight layer if found otherwise null.
  46502. */
  46503. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46504. }
  46505. }
  46506. /**
  46507. * Glow layer options. This helps customizing the behaviour
  46508. * of the glow layer.
  46509. */
  46510. export interface IGlowLayerOptions {
  46511. /**
  46512. * Multiplication factor apply to the canvas size to compute the render target size
  46513. * used to generated the glowing objects (the smaller the faster).
  46514. */
  46515. mainTextureRatio: number;
  46516. /**
  46517. * Enforces a fixed size texture to ensure resize independant blur.
  46518. */
  46519. mainTextureFixedSize?: number;
  46520. /**
  46521. * How big is the kernel of the blur texture.
  46522. */
  46523. blurKernelSize: number;
  46524. /**
  46525. * The camera attached to the layer.
  46526. */
  46527. camera: Nullable<Camera>;
  46528. /**
  46529. * Enable MSAA by chosing the number of samples.
  46530. */
  46531. mainTextureSamples?: number;
  46532. /**
  46533. * The rendering group to draw the layer in.
  46534. */
  46535. renderingGroupId: number;
  46536. }
  46537. /**
  46538. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46539. *
  46540. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46541. * glowy meshes to your scene.
  46542. *
  46543. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46544. */
  46545. export class GlowLayer extends EffectLayer {
  46546. /**
  46547. * Effect Name of the layer.
  46548. */
  46549. static readonly EffectName: string;
  46550. /**
  46551. * The default blur kernel size used for the glow.
  46552. */
  46553. static DefaultBlurKernelSize: number;
  46554. /**
  46555. * The default texture size ratio used for the glow.
  46556. */
  46557. static DefaultTextureRatio: number;
  46558. /**
  46559. * Sets the kernel size of the blur.
  46560. */
  46561. /**
  46562. * Gets the kernel size of the blur.
  46563. */
  46564. blurKernelSize: number;
  46565. /**
  46566. * Sets the glow intensity.
  46567. */
  46568. /**
  46569. * Gets the glow intensity.
  46570. */
  46571. intensity: number;
  46572. private _options;
  46573. private _intensity;
  46574. private _horizontalBlurPostprocess1;
  46575. private _verticalBlurPostprocess1;
  46576. private _horizontalBlurPostprocess2;
  46577. private _verticalBlurPostprocess2;
  46578. private _blurTexture1;
  46579. private _blurTexture2;
  46580. private _postProcesses1;
  46581. private _postProcesses2;
  46582. private _includedOnlyMeshes;
  46583. private _excludedMeshes;
  46584. /**
  46585. * Callback used to let the user override the color selection on a per mesh basis
  46586. */
  46587. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46588. /**
  46589. * Callback used to let the user override the texture selection on a per mesh basis
  46590. */
  46591. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46592. /**
  46593. * Instantiates a new glow Layer and references it to the scene.
  46594. * @param name The name of the layer
  46595. * @param scene The scene to use the layer in
  46596. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46597. */
  46598. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46599. /**
  46600. * Get the effect name of the layer.
  46601. * @return The effect name
  46602. */
  46603. getEffectName(): string;
  46604. /**
  46605. * Create the merge effect. This is the shader use to blit the information back
  46606. * to the main canvas at the end of the scene rendering.
  46607. */
  46608. protected _createMergeEffect(): Effect;
  46609. /**
  46610. * Creates the render target textures and post processes used in the glow layer.
  46611. */
  46612. protected _createTextureAndPostProcesses(): void;
  46613. /**
  46614. * Checks for the readiness of the element composing the layer.
  46615. * @param subMesh the mesh to check for
  46616. * @param useInstances specify wether or not to use instances to render the mesh
  46617. * @param emissiveTexture the associated emissive texture used to generate the glow
  46618. * @return true if ready otherwise, false
  46619. */
  46620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46621. /**
  46622. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46623. */
  46624. needStencil(): boolean;
  46625. /**
  46626. * Returns true if the mesh can be rendered, otherwise false.
  46627. * @param mesh The mesh to render
  46628. * @param material The material used on the mesh
  46629. * @returns true if it can be rendered otherwise false
  46630. */
  46631. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46632. /**
  46633. * Implementation specific of rendering the generating effect on the main canvas.
  46634. * @param effect The effect used to render through
  46635. */
  46636. protected _internalRender(effect: Effect): void;
  46637. /**
  46638. * Sets the required values for both the emissive texture and and the main color.
  46639. */
  46640. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46641. /**
  46642. * Returns true if the mesh should render, otherwise false.
  46643. * @param mesh The mesh to render
  46644. * @returns true if it should render otherwise false
  46645. */
  46646. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46647. /**
  46648. * Adds specific effects defines.
  46649. * @param defines The defines to add specifics to.
  46650. */
  46651. protected _addCustomEffectDefines(defines: string[]): void;
  46652. /**
  46653. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46654. * @param mesh The mesh to exclude from the glow layer
  46655. */
  46656. addExcludedMesh(mesh: Mesh): void;
  46657. /**
  46658. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46659. * @param mesh The mesh to remove
  46660. */
  46661. removeExcludedMesh(mesh: Mesh): void;
  46662. /**
  46663. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46664. * @param mesh The mesh to include in the glow layer
  46665. */
  46666. addIncludedOnlyMesh(mesh: Mesh): void;
  46667. /**
  46668. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46669. * @param mesh The mesh to remove
  46670. */
  46671. removeIncludedOnlyMesh(mesh: Mesh): void;
  46672. /**
  46673. * Determine if a given mesh will be used in the glow layer
  46674. * @param mesh The mesh to test
  46675. * @returns true if the mesh will be highlighted by the current glow layer
  46676. */
  46677. hasMesh(mesh: AbstractMesh): boolean;
  46678. /**
  46679. * Free any resources and references associated to a mesh.
  46680. * Internal use
  46681. * @param mesh The mesh to free.
  46682. * @hidden
  46683. */
  46684. _disposeMesh(mesh: Mesh): void;
  46685. /**
  46686. * Gets the class name of the effect layer
  46687. * @returns the string with the class name of the effect layer
  46688. */
  46689. getClassName(): string;
  46690. /**
  46691. * Serializes this glow layer
  46692. * @returns a serialized glow layer object
  46693. */
  46694. serialize(): any;
  46695. /**
  46696. * Creates a Glow Layer from parsed glow layer data
  46697. * @param parsedGlowLayer defines glow layer data
  46698. * @param scene defines the current scene
  46699. * @param rootUrl defines the root URL containing the glow layer information
  46700. * @returns a parsed Glow Layer
  46701. */
  46702. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46703. }
  46704. }
  46705. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46706. /** @hidden */
  46707. export var glowBlurPostProcessPixelShader: {
  46708. name: string;
  46709. shader: string;
  46710. };
  46711. }
  46712. declare module "babylonjs/Layers/highlightLayer" {
  46713. import { Observable } from "babylonjs/Misc/observable";
  46714. import { Nullable } from "babylonjs/types";
  46715. import { Camera } from "babylonjs/Cameras/camera";
  46716. import { Scene } from "babylonjs/scene";
  46717. import { Color3, Color4 } from "babylonjs/Maths/math";
  46718. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46720. import { Mesh } from "babylonjs/Meshes/mesh";
  46721. import { Effect } from "babylonjs/Materials/effect";
  46722. import { Material } from "babylonjs/Materials/material";
  46723. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46724. import "babylonjs/Shaders/glowMapMerge.fragment";
  46725. import "babylonjs/Shaders/glowMapMerge.vertex";
  46726. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46727. module "babylonjs/abstractScene" {
  46728. interface AbstractScene {
  46729. /**
  46730. * Return a the first highlight layer of the scene with a given name.
  46731. * @param name The name of the highlight layer to look for.
  46732. * @return The highlight layer if found otherwise null.
  46733. */
  46734. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46735. }
  46736. }
  46737. /**
  46738. * Highlight layer options. This helps customizing the behaviour
  46739. * of the highlight layer.
  46740. */
  46741. export interface IHighlightLayerOptions {
  46742. /**
  46743. * Multiplication factor apply to the canvas size to compute the render target size
  46744. * used to generated the glowing objects (the smaller the faster).
  46745. */
  46746. mainTextureRatio: number;
  46747. /**
  46748. * Enforces a fixed size texture to ensure resize independant blur.
  46749. */
  46750. mainTextureFixedSize?: number;
  46751. /**
  46752. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46753. * of the picture to blur (the smaller the faster).
  46754. */
  46755. blurTextureSizeRatio: number;
  46756. /**
  46757. * How big in texel of the blur texture is the vertical blur.
  46758. */
  46759. blurVerticalSize: number;
  46760. /**
  46761. * How big in texel of the blur texture is the horizontal blur.
  46762. */
  46763. blurHorizontalSize: number;
  46764. /**
  46765. * Alpha blending mode used to apply the blur. Default is combine.
  46766. */
  46767. alphaBlendingMode: number;
  46768. /**
  46769. * The camera attached to the layer.
  46770. */
  46771. camera: Nullable<Camera>;
  46772. /**
  46773. * Should we display highlight as a solid stroke?
  46774. */
  46775. isStroke?: boolean;
  46776. /**
  46777. * The rendering group to draw the layer in.
  46778. */
  46779. renderingGroupId: number;
  46780. }
  46781. /**
  46782. * The highlight layer Helps adding a glow effect around a mesh.
  46783. *
  46784. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46785. * glowy meshes to your scene.
  46786. *
  46787. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46788. */
  46789. export class HighlightLayer extends EffectLayer {
  46790. name: string;
  46791. /**
  46792. * Effect Name of the highlight layer.
  46793. */
  46794. static readonly EffectName: string;
  46795. /**
  46796. * The neutral color used during the preparation of the glow effect.
  46797. * This is black by default as the blend operation is a blend operation.
  46798. */
  46799. static NeutralColor: Color4;
  46800. /**
  46801. * Stencil value used for glowing meshes.
  46802. */
  46803. static GlowingMeshStencilReference: number;
  46804. /**
  46805. * Stencil value used for the other meshes in the scene.
  46806. */
  46807. static NormalMeshStencilReference: number;
  46808. /**
  46809. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46810. */
  46811. innerGlow: boolean;
  46812. /**
  46813. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46814. */
  46815. outerGlow: boolean;
  46816. /**
  46817. * Specifies the horizontal size of the blur.
  46818. */
  46819. /**
  46820. * Gets the horizontal size of the blur.
  46821. */
  46822. blurHorizontalSize: number;
  46823. /**
  46824. * Specifies the vertical size of the blur.
  46825. */
  46826. /**
  46827. * Gets the vertical size of the blur.
  46828. */
  46829. blurVerticalSize: number;
  46830. /**
  46831. * An event triggered when the highlight layer is being blurred.
  46832. */
  46833. onBeforeBlurObservable: Observable<HighlightLayer>;
  46834. /**
  46835. * An event triggered when the highlight layer has been blurred.
  46836. */
  46837. onAfterBlurObservable: Observable<HighlightLayer>;
  46838. private _instanceGlowingMeshStencilReference;
  46839. private _options;
  46840. private _downSamplePostprocess;
  46841. private _horizontalBlurPostprocess;
  46842. private _verticalBlurPostprocess;
  46843. private _blurTexture;
  46844. private _meshes;
  46845. private _excludedMeshes;
  46846. /**
  46847. * Instantiates a new highlight Layer and references it to the scene..
  46848. * @param name The name of the layer
  46849. * @param scene The scene to use the layer in
  46850. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46851. */
  46852. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46853. /**
  46854. * Get the effect name of the layer.
  46855. * @return The effect name
  46856. */
  46857. getEffectName(): string;
  46858. /**
  46859. * Create the merge effect. This is the shader use to blit the information back
  46860. * to the main canvas at the end of the scene rendering.
  46861. */
  46862. protected _createMergeEffect(): Effect;
  46863. /**
  46864. * Creates the render target textures and post processes used in the highlight layer.
  46865. */
  46866. protected _createTextureAndPostProcesses(): void;
  46867. /**
  46868. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46869. */
  46870. needStencil(): boolean;
  46871. /**
  46872. * Checks for the readiness of the element composing the layer.
  46873. * @param subMesh the mesh to check for
  46874. * @param useInstances specify wether or not to use instances to render the mesh
  46875. * @param emissiveTexture the associated emissive texture used to generate the glow
  46876. * @return true if ready otherwise, false
  46877. */
  46878. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46879. /**
  46880. * Implementation specific of rendering the generating effect on the main canvas.
  46881. * @param effect The effect used to render through
  46882. */
  46883. protected _internalRender(effect: Effect): void;
  46884. /**
  46885. * Returns true if the layer contains information to display, otherwise false.
  46886. */
  46887. shouldRender(): boolean;
  46888. /**
  46889. * Returns true if the mesh should render, otherwise false.
  46890. * @param mesh The mesh to render
  46891. * @returns true if it should render otherwise false
  46892. */
  46893. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46894. /**
  46895. * Sets the required values for both the emissive texture and and the main color.
  46896. */
  46897. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46898. /**
  46899. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46900. * @param mesh The mesh to exclude from the highlight layer
  46901. */
  46902. addExcludedMesh(mesh: Mesh): void;
  46903. /**
  46904. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46905. * @param mesh The mesh to highlight
  46906. */
  46907. removeExcludedMesh(mesh: Mesh): void;
  46908. /**
  46909. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46910. * @param mesh mesh to test
  46911. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46912. */
  46913. hasMesh(mesh: AbstractMesh): boolean;
  46914. /**
  46915. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46916. * @param mesh The mesh to highlight
  46917. * @param color The color of the highlight
  46918. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46919. */
  46920. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46921. /**
  46922. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46923. * @param mesh The mesh to highlight
  46924. */
  46925. removeMesh(mesh: Mesh): void;
  46926. /**
  46927. * Force the stencil to the normal expected value for none glowing parts
  46928. */
  46929. private _defaultStencilReference;
  46930. /**
  46931. * Free any resources and references associated to a mesh.
  46932. * Internal use
  46933. * @param mesh The mesh to free.
  46934. * @hidden
  46935. */
  46936. _disposeMesh(mesh: Mesh): void;
  46937. /**
  46938. * Dispose the highlight layer and free resources.
  46939. */
  46940. dispose(): void;
  46941. /**
  46942. * Gets the class name of the effect layer
  46943. * @returns the string with the class name of the effect layer
  46944. */
  46945. getClassName(): string;
  46946. /**
  46947. * Serializes this Highlight layer
  46948. * @returns a serialized Highlight layer object
  46949. */
  46950. serialize(): any;
  46951. /**
  46952. * Creates a Highlight layer from parsed Highlight layer data
  46953. * @param parsedHightlightLayer defines the Highlight layer data
  46954. * @param scene defines the current scene
  46955. * @param rootUrl defines the root URL containing the Highlight layer information
  46956. * @returns a parsed Highlight layer
  46957. */
  46958. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46959. }
  46960. }
  46961. declare module "babylonjs/Layers/index" {
  46962. export * from "babylonjs/Layers/effectLayer";
  46963. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46964. export * from "babylonjs/Layers/glowLayer";
  46965. export * from "babylonjs/Layers/highlightLayer";
  46966. export * from "babylonjs/Layers/layer";
  46967. export * from "babylonjs/Layers/layerSceneComponent";
  46968. }
  46969. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46970. /** @hidden */
  46971. export var lensFlarePixelShader: {
  46972. name: string;
  46973. shader: string;
  46974. };
  46975. }
  46976. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46977. /** @hidden */
  46978. export var lensFlareVertexShader: {
  46979. name: string;
  46980. shader: string;
  46981. };
  46982. }
  46983. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46984. import { Scene } from "babylonjs/scene";
  46985. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46987. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46988. import "babylonjs/Shaders/lensFlare.fragment";
  46989. import "babylonjs/Shaders/lensFlare.vertex";
  46990. /**
  46991. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46992. * It is usually composed of several `lensFlare`.
  46993. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46994. */
  46995. export class LensFlareSystem {
  46996. /**
  46997. * Define the name of the lens flare system
  46998. */
  46999. name: string;
  47000. /**
  47001. * List of lens flares used in this system.
  47002. */
  47003. lensFlares: LensFlare[];
  47004. /**
  47005. * Define a limit from the border the lens flare can be visible.
  47006. */
  47007. borderLimit: number;
  47008. /**
  47009. * Define a viewport border we do not want to see the lens flare in.
  47010. */
  47011. viewportBorder: number;
  47012. /**
  47013. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47014. */
  47015. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47016. /**
  47017. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47018. */
  47019. layerMask: number;
  47020. /**
  47021. * Define the id of the lens flare system in the scene.
  47022. * (equal to name by default)
  47023. */
  47024. id: string;
  47025. private _scene;
  47026. private _emitter;
  47027. private _vertexBuffers;
  47028. private _indexBuffer;
  47029. private _effect;
  47030. private _positionX;
  47031. private _positionY;
  47032. private _isEnabled;
  47033. /** @hidden */
  47034. static _SceneComponentInitialization: (scene: Scene) => void;
  47035. /**
  47036. * Instantiates a lens flare system.
  47037. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47038. * It is usually composed of several `lensFlare`.
  47039. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47040. * @param name Define the name of the lens flare system in the scene
  47041. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47042. * @param scene Define the scene the lens flare system belongs to
  47043. */
  47044. constructor(
  47045. /**
  47046. * Define the name of the lens flare system
  47047. */
  47048. name: string, emitter: any, scene: Scene);
  47049. /**
  47050. * Define if the lens flare system is enabled.
  47051. */
  47052. isEnabled: boolean;
  47053. /**
  47054. * Get the scene the effects belongs to.
  47055. * @returns the scene holding the lens flare system
  47056. */
  47057. getScene(): Scene;
  47058. /**
  47059. * Get the emitter of the lens flare system.
  47060. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47061. * @returns the emitter of the lens flare system
  47062. */
  47063. getEmitter(): any;
  47064. /**
  47065. * Set the emitter of the lens flare system.
  47066. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47067. * @param newEmitter Define the new emitter of the system
  47068. */
  47069. setEmitter(newEmitter: any): void;
  47070. /**
  47071. * Get the lens flare system emitter position.
  47072. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47073. * @returns the position
  47074. */
  47075. getEmitterPosition(): Vector3;
  47076. /**
  47077. * @hidden
  47078. */
  47079. computeEffectivePosition(globalViewport: Viewport): boolean;
  47080. /** @hidden */
  47081. _isVisible(): boolean;
  47082. /**
  47083. * @hidden
  47084. */
  47085. render(): boolean;
  47086. /**
  47087. * Dispose and release the lens flare with its associated resources.
  47088. */
  47089. dispose(): void;
  47090. /**
  47091. * Parse a lens flare system from a JSON repressentation
  47092. * @param parsedLensFlareSystem Define the JSON to parse
  47093. * @param scene Define the scene the parsed system should be instantiated in
  47094. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47095. * @returns the parsed system
  47096. */
  47097. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47098. /**
  47099. * Serialize the current Lens Flare System into a JSON representation.
  47100. * @returns the serialized JSON
  47101. */
  47102. serialize(): any;
  47103. }
  47104. }
  47105. declare module "babylonjs/LensFlares/lensFlare" {
  47106. import { Nullable } from "babylonjs/types";
  47107. import { Color3 } from "babylonjs/Maths/math";
  47108. import { Texture } from "babylonjs/Materials/Textures/texture";
  47109. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47110. /**
  47111. * This represents one of the lens effect in a `lensFlareSystem`.
  47112. * It controls one of the indiviual texture used in the effect.
  47113. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47114. */
  47115. export class LensFlare {
  47116. /**
  47117. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47118. */
  47119. size: number;
  47120. /**
  47121. * 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.
  47122. */
  47123. position: number;
  47124. /**
  47125. * Define the lens color.
  47126. */
  47127. color: Color3;
  47128. /**
  47129. * Define the lens texture.
  47130. */
  47131. texture: Nullable<Texture>;
  47132. /**
  47133. * Define the alpha mode to render this particular lens.
  47134. */
  47135. alphaMode: number;
  47136. private _system;
  47137. /**
  47138. * Creates a new Lens Flare.
  47139. * This represents one of the lens effect in a `lensFlareSystem`.
  47140. * It controls one of the indiviual texture used in the effect.
  47141. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47142. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47143. * @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.
  47144. * @param color Define the lens color
  47145. * @param imgUrl Define the lens texture url
  47146. * @param system Define the `lensFlareSystem` this flare is part of
  47147. * @returns The newly created Lens Flare
  47148. */
  47149. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47150. /**
  47151. * Instantiates a new Lens Flare.
  47152. * This represents one of the lens effect in a `lensFlareSystem`.
  47153. * It controls one of the indiviual texture used in the effect.
  47154. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47155. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47156. * @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.
  47157. * @param color Define the lens color
  47158. * @param imgUrl Define the lens texture url
  47159. * @param system Define the `lensFlareSystem` this flare is part of
  47160. */
  47161. constructor(
  47162. /**
  47163. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47164. */
  47165. size: number,
  47166. /**
  47167. * 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.
  47168. */
  47169. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47170. /**
  47171. * Dispose and release the lens flare with its associated resources.
  47172. */
  47173. dispose(): void;
  47174. }
  47175. }
  47176. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47177. import { Nullable } from "babylonjs/types";
  47178. import { Scene } from "babylonjs/scene";
  47179. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47180. import { AbstractScene } from "babylonjs/abstractScene";
  47181. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47182. module "babylonjs/abstractScene" {
  47183. interface AbstractScene {
  47184. /**
  47185. * The list of lens flare system added to the scene
  47186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47187. */
  47188. lensFlareSystems: Array<LensFlareSystem>;
  47189. /**
  47190. * Removes the given lens flare system from this scene.
  47191. * @param toRemove The lens flare system to remove
  47192. * @returns The index of the removed lens flare system
  47193. */
  47194. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47195. /**
  47196. * Adds the given lens flare system to this scene
  47197. * @param newLensFlareSystem The lens flare system to add
  47198. */
  47199. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47200. /**
  47201. * Gets a lens flare system using its name
  47202. * @param name defines the name to look for
  47203. * @returns the lens flare system or null if not found
  47204. */
  47205. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47206. /**
  47207. * Gets a lens flare system using its id
  47208. * @param id defines the id to look for
  47209. * @returns the lens flare system or null if not found
  47210. */
  47211. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47212. }
  47213. }
  47214. /**
  47215. * Defines the lens flare scene component responsible to manage any lens flares
  47216. * in a given scene.
  47217. */
  47218. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47219. /**
  47220. * The component name helpfull to identify the component in the list of scene components.
  47221. */
  47222. readonly name: string;
  47223. /**
  47224. * The scene the component belongs to.
  47225. */
  47226. scene: Scene;
  47227. /**
  47228. * Creates a new instance of the component for the given scene
  47229. * @param scene Defines the scene to register the component in
  47230. */
  47231. constructor(scene: Scene);
  47232. /**
  47233. * Registers the component in a given scene
  47234. */
  47235. register(): void;
  47236. /**
  47237. * Rebuilds the elements related to this component in case of
  47238. * context lost for instance.
  47239. */
  47240. rebuild(): void;
  47241. /**
  47242. * Adds all the element from the container to the scene
  47243. * @param container the container holding the elements
  47244. */
  47245. addFromContainer(container: AbstractScene): void;
  47246. /**
  47247. * Removes all the elements in the container from the scene
  47248. * @param container contains the elements to remove
  47249. */
  47250. removeFromContainer(container: AbstractScene): void;
  47251. /**
  47252. * Serializes the component data to the specified json object
  47253. * @param serializationObject The object to serialize to
  47254. */
  47255. serialize(serializationObject: any): void;
  47256. /**
  47257. * Disposes the component and the associated ressources.
  47258. */
  47259. dispose(): void;
  47260. private _draw;
  47261. }
  47262. }
  47263. declare module "babylonjs/LensFlares/index" {
  47264. export * from "babylonjs/LensFlares/lensFlare";
  47265. export * from "babylonjs/LensFlares/lensFlareSystem";
  47266. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47267. }
  47268. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47269. import { Scene } from "babylonjs/scene";
  47270. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47271. import { AbstractScene } from "babylonjs/abstractScene";
  47272. /**
  47273. * Defines the shadow generator component responsible to manage any shadow generators
  47274. * in a given scene.
  47275. */
  47276. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47277. /**
  47278. * The component name helpfull to identify the component in the list of scene components.
  47279. */
  47280. readonly name: string;
  47281. /**
  47282. * The scene the component belongs to.
  47283. */
  47284. scene: Scene;
  47285. /**
  47286. * Creates a new instance of the component for the given scene
  47287. * @param scene Defines the scene to register the component in
  47288. */
  47289. constructor(scene: Scene);
  47290. /**
  47291. * Registers the component in a given scene
  47292. */
  47293. register(): void;
  47294. /**
  47295. * Rebuilds the elements related to this component in case of
  47296. * context lost for instance.
  47297. */
  47298. rebuild(): void;
  47299. /**
  47300. * Serializes the component data to the specified json object
  47301. * @param serializationObject The object to serialize to
  47302. */
  47303. serialize(serializationObject: any): void;
  47304. /**
  47305. * Adds all the element from the container to the scene
  47306. * @param container the container holding the elements
  47307. */
  47308. addFromContainer(container: AbstractScene): void;
  47309. /**
  47310. * Removes all the elements in the container from the scene
  47311. * @param container contains the elements to remove
  47312. */
  47313. removeFromContainer(container: AbstractScene): void;
  47314. /**
  47315. * Rebuilds the elements related to this component in case of
  47316. * context lost for instance.
  47317. */
  47318. dispose(): void;
  47319. private _gatherRenderTargets;
  47320. }
  47321. }
  47322. declare module "babylonjs/Lights/Shadows/index" {
  47323. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47324. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47325. }
  47326. declare module "babylonjs/Lights/directionalLight" {
  47327. import { Camera } from "babylonjs/Cameras/camera";
  47328. import { Scene } from "babylonjs/scene";
  47329. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47331. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47332. import { Effect } from "babylonjs/Materials/effect";
  47333. /**
  47334. * A directional light is defined by a direction (what a surprise!).
  47335. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47336. * 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.
  47337. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47338. */
  47339. export class DirectionalLight extends ShadowLight {
  47340. private _shadowFrustumSize;
  47341. /**
  47342. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47343. */
  47344. /**
  47345. * Specifies a fix frustum size for the shadow generation.
  47346. */
  47347. shadowFrustumSize: number;
  47348. private _shadowOrthoScale;
  47349. /**
  47350. * Gets the shadow projection scale against the optimal computed one.
  47351. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47352. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47353. */
  47354. /**
  47355. * Sets the shadow projection scale against the optimal computed one.
  47356. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47357. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47358. */
  47359. shadowOrthoScale: number;
  47360. /**
  47361. * Automatically compute the projection matrix to best fit (including all the casters)
  47362. * on each frame.
  47363. */
  47364. autoUpdateExtends: boolean;
  47365. private _orthoLeft;
  47366. private _orthoRight;
  47367. private _orthoTop;
  47368. private _orthoBottom;
  47369. /**
  47370. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47371. * The directional light is emitted from everywhere in the given direction.
  47372. * It can cast shadows.
  47373. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47374. * @param name The friendly name of the light
  47375. * @param direction The direction of the light
  47376. * @param scene The scene the light belongs to
  47377. */
  47378. constructor(name: string, direction: Vector3, scene: Scene);
  47379. /**
  47380. * Returns the string "DirectionalLight".
  47381. * @return The class name
  47382. */
  47383. getClassName(): string;
  47384. /**
  47385. * Returns the integer 1.
  47386. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47387. */
  47388. getTypeID(): number;
  47389. /**
  47390. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47391. * Returns the DirectionalLight Shadow projection matrix.
  47392. */
  47393. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47394. /**
  47395. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47396. * Returns the DirectionalLight Shadow projection matrix.
  47397. */
  47398. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47399. /**
  47400. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47401. * Returns the DirectionalLight Shadow projection matrix.
  47402. */
  47403. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47404. protected _buildUniformLayout(): void;
  47405. /**
  47406. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47407. * @param effect The effect to update
  47408. * @param lightIndex The index of the light in the effect to update
  47409. * @returns The directional light
  47410. */
  47411. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47412. /**
  47413. * Gets the minZ used for shadow according to both the scene and the light.
  47414. *
  47415. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47416. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47417. * @param activeCamera The camera we are returning the min for
  47418. * @returns the depth min z
  47419. */
  47420. getDepthMinZ(activeCamera: Camera): number;
  47421. /**
  47422. * Gets the maxZ used for shadow according to both the scene and the light.
  47423. *
  47424. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47425. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47426. * @param activeCamera The camera we are returning the max for
  47427. * @returns the depth max z
  47428. */
  47429. getDepthMaxZ(activeCamera: Camera): number;
  47430. /**
  47431. * Prepares the list of defines specific to the light type.
  47432. * @param defines the list of defines
  47433. * @param lightIndex defines the index of the light for the effect
  47434. */
  47435. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47436. }
  47437. }
  47438. declare module "babylonjs/Lights/pointLight" {
  47439. import { Scene } from "babylonjs/scene";
  47440. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47442. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47443. import { Effect } from "babylonjs/Materials/effect";
  47444. /**
  47445. * A point light is a light defined by an unique point in world space.
  47446. * The light is emitted in every direction from this point.
  47447. * A good example of a point light is a standard light bulb.
  47448. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47449. */
  47450. export class PointLight extends ShadowLight {
  47451. private _shadowAngle;
  47452. /**
  47453. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47454. * This specifies what angle the shadow will use to be created.
  47455. *
  47456. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47457. */
  47458. /**
  47459. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47460. * This specifies what angle the shadow will use to be created.
  47461. *
  47462. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47463. */
  47464. shadowAngle: number;
  47465. /**
  47466. * Gets the direction if it has been set.
  47467. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47468. */
  47469. /**
  47470. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47471. */
  47472. direction: Vector3;
  47473. /**
  47474. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47475. * A PointLight emits the light in every direction.
  47476. * It can cast shadows.
  47477. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47478. * ```javascript
  47479. * var pointLight = new PointLight("pl", camera.position, scene);
  47480. * ```
  47481. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47482. * @param name The light friendly name
  47483. * @param position The position of the point light in the scene
  47484. * @param scene The scene the lights belongs to
  47485. */
  47486. constructor(name: string, position: Vector3, scene: Scene);
  47487. /**
  47488. * Returns the string "PointLight"
  47489. * @returns the class name
  47490. */
  47491. getClassName(): string;
  47492. /**
  47493. * Returns the integer 0.
  47494. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47495. */
  47496. getTypeID(): number;
  47497. /**
  47498. * Specifies wether or not the shadowmap should be a cube texture.
  47499. * @returns true if the shadowmap needs to be a cube texture.
  47500. */
  47501. needCube(): boolean;
  47502. /**
  47503. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47504. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47505. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47506. */
  47507. getShadowDirection(faceIndex?: number): Vector3;
  47508. /**
  47509. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47510. * - fov = PI / 2
  47511. * - aspect ratio : 1.0
  47512. * - z-near and far equal to the active camera minZ and maxZ.
  47513. * Returns the PointLight.
  47514. */
  47515. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47516. protected _buildUniformLayout(): void;
  47517. /**
  47518. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47519. * @param effect The effect to update
  47520. * @param lightIndex The index of the light in the effect to update
  47521. * @returns The point light
  47522. */
  47523. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47524. /**
  47525. * Prepares the list of defines specific to the light type.
  47526. * @param defines the list of defines
  47527. * @param lightIndex defines the index of the light for the effect
  47528. */
  47529. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47530. }
  47531. }
  47532. declare module "babylonjs/Lights/spotLight" {
  47533. import { Nullable } from "babylonjs/types";
  47534. import { Scene } from "babylonjs/scene";
  47535. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47537. import { Effect } from "babylonjs/Materials/effect";
  47538. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47539. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47540. /**
  47541. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47542. * These values define a cone of light starting from the position, emitting toward the direction.
  47543. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47544. * and the exponent defines the speed of the decay of the light with distance (reach).
  47545. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47546. */
  47547. export class SpotLight extends ShadowLight {
  47548. private _angle;
  47549. private _innerAngle;
  47550. private _cosHalfAngle;
  47551. private _lightAngleScale;
  47552. private _lightAngleOffset;
  47553. /**
  47554. * Gets the cone angle of the spot light in Radians.
  47555. */
  47556. /**
  47557. * Sets the cone angle of the spot light in Radians.
  47558. */
  47559. angle: number;
  47560. /**
  47561. * Only used in gltf falloff mode, this defines the angle where
  47562. * the directional falloff will start before cutting at angle which could be seen
  47563. * as outer angle.
  47564. */
  47565. /**
  47566. * Only used in gltf falloff mode, this defines the angle where
  47567. * the directional falloff will start before cutting at angle which could be seen
  47568. * as outer angle.
  47569. */
  47570. innerAngle: number;
  47571. private _shadowAngleScale;
  47572. /**
  47573. * Allows scaling the angle of the light for shadow generation only.
  47574. */
  47575. /**
  47576. * Allows scaling the angle of the light for shadow generation only.
  47577. */
  47578. shadowAngleScale: number;
  47579. /**
  47580. * The light decay speed with the distance from the emission spot.
  47581. */
  47582. exponent: number;
  47583. private _projectionTextureMatrix;
  47584. /**
  47585. * Allows reading the projecton texture
  47586. */
  47587. readonly projectionTextureMatrix: Matrix;
  47588. protected _projectionTextureLightNear: number;
  47589. /**
  47590. * Gets the near clip of the Spotlight for texture projection.
  47591. */
  47592. /**
  47593. * Sets the near clip of the Spotlight for texture projection.
  47594. */
  47595. projectionTextureLightNear: number;
  47596. protected _projectionTextureLightFar: number;
  47597. /**
  47598. * Gets the far clip of the Spotlight for texture projection.
  47599. */
  47600. /**
  47601. * Sets the far clip of the Spotlight for texture projection.
  47602. */
  47603. projectionTextureLightFar: number;
  47604. protected _projectionTextureUpDirection: Vector3;
  47605. /**
  47606. * Gets the Up vector of the Spotlight for texture projection.
  47607. */
  47608. /**
  47609. * Sets the Up vector of the Spotlight for texture projection.
  47610. */
  47611. projectionTextureUpDirection: Vector3;
  47612. private _projectionTexture;
  47613. /**
  47614. * Gets the projection texture of the light.
  47615. */
  47616. /**
  47617. * Sets the projection texture of the light.
  47618. */
  47619. projectionTexture: Nullable<BaseTexture>;
  47620. private _projectionTextureViewLightDirty;
  47621. private _projectionTextureProjectionLightDirty;
  47622. private _projectionTextureDirty;
  47623. private _projectionTextureViewTargetVector;
  47624. private _projectionTextureViewLightMatrix;
  47625. private _projectionTextureProjectionLightMatrix;
  47626. private _projectionTextureScalingMatrix;
  47627. /**
  47628. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47629. * It can cast shadows.
  47630. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47631. * @param name The light friendly name
  47632. * @param position The position of the spot light in the scene
  47633. * @param direction The direction of the light in the scene
  47634. * @param angle The cone angle of the light in Radians
  47635. * @param exponent The light decay speed with the distance from the emission spot
  47636. * @param scene The scene the lights belongs to
  47637. */
  47638. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47639. /**
  47640. * Returns the string "SpotLight".
  47641. * @returns the class name
  47642. */
  47643. getClassName(): string;
  47644. /**
  47645. * Returns the integer 2.
  47646. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47647. */
  47648. getTypeID(): number;
  47649. /**
  47650. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47651. */
  47652. protected _setDirection(value: Vector3): void;
  47653. /**
  47654. * Overrides the position setter to recompute the projection texture view light Matrix.
  47655. */
  47656. protected _setPosition(value: Vector3): void;
  47657. /**
  47658. * 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.
  47659. * Returns the SpotLight.
  47660. */
  47661. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47662. protected _computeProjectionTextureViewLightMatrix(): void;
  47663. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47664. /**
  47665. * Main function for light texture projection matrix computing.
  47666. */
  47667. protected _computeProjectionTextureMatrix(): void;
  47668. protected _buildUniformLayout(): void;
  47669. private _computeAngleValues;
  47670. /**
  47671. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47672. * @param effect The effect to update
  47673. * @param lightIndex The index of the light in the effect to update
  47674. * @returns The spot light
  47675. */
  47676. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47677. /**
  47678. * Disposes the light and the associated resources.
  47679. */
  47680. dispose(): void;
  47681. /**
  47682. * Prepares the list of defines specific to the light type.
  47683. * @param defines the list of defines
  47684. * @param lightIndex defines the index of the light for the effect
  47685. */
  47686. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47687. }
  47688. }
  47689. declare module "babylonjs/Lights/index" {
  47690. export * from "babylonjs/Lights/light";
  47691. export * from "babylonjs/Lights/shadowLight";
  47692. export * from "babylonjs/Lights/Shadows/index";
  47693. export * from "babylonjs/Lights/directionalLight";
  47694. export * from "babylonjs/Lights/hemisphericLight";
  47695. export * from "babylonjs/Lights/pointLight";
  47696. export * from "babylonjs/Lights/spotLight";
  47697. }
  47698. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47699. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47700. /**
  47701. * Header information of HDR texture files.
  47702. */
  47703. export interface HDRInfo {
  47704. /**
  47705. * The height of the texture in pixels.
  47706. */
  47707. height: number;
  47708. /**
  47709. * The width of the texture in pixels.
  47710. */
  47711. width: number;
  47712. /**
  47713. * The index of the beginning of the data in the binary file.
  47714. */
  47715. dataPosition: number;
  47716. }
  47717. /**
  47718. * This groups tools to convert HDR texture to native colors array.
  47719. */
  47720. export class HDRTools {
  47721. private static Ldexp;
  47722. private static Rgbe2float;
  47723. private static readStringLine;
  47724. /**
  47725. * Reads header information from an RGBE texture stored in a native array.
  47726. * More information on this format are available here:
  47727. * https://en.wikipedia.org/wiki/RGBE_image_format
  47728. *
  47729. * @param uint8array The binary file stored in native array.
  47730. * @return The header information.
  47731. */
  47732. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47733. /**
  47734. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47735. * This RGBE texture needs to store the information as a panorama.
  47736. *
  47737. * More information on this format are available here:
  47738. * https://en.wikipedia.org/wiki/RGBE_image_format
  47739. *
  47740. * @param buffer The binary file stored in an array buffer.
  47741. * @param size The expected size of the extracted cubemap.
  47742. * @return The Cube Map information.
  47743. */
  47744. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47745. /**
  47746. * Returns the pixels data extracted from an RGBE texture.
  47747. * This pixels will be stored left to right up to down in the R G B order in one array.
  47748. *
  47749. * More information on this format are available here:
  47750. * https://en.wikipedia.org/wiki/RGBE_image_format
  47751. *
  47752. * @param uint8array The binary file stored in an array buffer.
  47753. * @param hdrInfo The header information of the file.
  47754. * @return The pixels data in RGB right to left up to down order.
  47755. */
  47756. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47757. private static RGBE_ReadPixels_RLE;
  47758. }
  47759. }
  47760. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47761. import { Nullable } from "babylonjs/types";
  47762. import { Scene } from "babylonjs/scene";
  47763. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47765. /**
  47766. * This represents a texture coming from an HDR input.
  47767. *
  47768. * The only supported format is currently panorama picture stored in RGBE format.
  47769. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47770. */
  47771. export class HDRCubeTexture extends BaseTexture {
  47772. private static _facesMapping;
  47773. private _generateHarmonics;
  47774. private _noMipmap;
  47775. private _textureMatrix;
  47776. private _size;
  47777. private _onLoad;
  47778. private _onError;
  47779. /**
  47780. * The texture URL.
  47781. */
  47782. url: string;
  47783. /**
  47784. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47785. */
  47786. coordinatesMode: number;
  47787. protected _isBlocking: boolean;
  47788. /**
  47789. * Sets wether or not the texture is blocking during loading.
  47790. */
  47791. /**
  47792. * Gets wether or not the texture is blocking during loading.
  47793. */
  47794. isBlocking: boolean;
  47795. protected _rotationY: number;
  47796. /**
  47797. * Sets texture matrix rotation angle around Y axis in radians.
  47798. */
  47799. /**
  47800. * Gets texture matrix rotation angle around Y axis radians.
  47801. */
  47802. rotationY: number;
  47803. /**
  47804. * Gets or sets the center of the bounding box associated with the cube texture
  47805. * It must define where the camera used to render the texture was set
  47806. */
  47807. boundingBoxPosition: Vector3;
  47808. private _boundingBoxSize;
  47809. /**
  47810. * Gets or sets the size of the bounding box associated with the cube texture
  47811. * When defined, the cubemap will switch to local mode
  47812. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47813. * @example https://www.babylonjs-playground.com/#RNASML
  47814. */
  47815. boundingBoxSize: Vector3;
  47816. /**
  47817. * Instantiates an HDRTexture from the following parameters.
  47818. *
  47819. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47820. * @param scene The scene the texture will be used in
  47821. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47822. * @param noMipmap Forces to not generate the mipmap if true
  47823. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47824. * @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)
  47825. * @param reserved Reserved flag for internal use.
  47826. */
  47827. 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>);
  47828. /**
  47829. * Get the current class name of the texture useful for serialization or dynamic coding.
  47830. * @returns "HDRCubeTexture"
  47831. */
  47832. getClassName(): string;
  47833. /**
  47834. * Occurs when the file is raw .hdr file.
  47835. */
  47836. private loadTexture;
  47837. clone(): HDRCubeTexture;
  47838. delayLoad(): void;
  47839. /**
  47840. * Get the texture reflection matrix used to rotate/transform the reflection.
  47841. * @returns the reflection matrix
  47842. */
  47843. getReflectionTextureMatrix(): Matrix;
  47844. /**
  47845. * Set the texture reflection matrix used to rotate/transform the reflection.
  47846. * @param value Define the reflection matrix to set
  47847. */
  47848. setReflectionTextureMatrix(value: Matrix): void;
  47849. /**
  47850. * Parses a JSON representation of an HDR Texture in order to create the texture
  47851. * @param parsedTexture Define the JSON representation
  47852. * @param scene Define the scene the texture should be created in
  47853. * @param rootUrl Define the root url in case we need to load relative dependencies
  47854. * @returns the newly created texture after parsing
  47855. */
  47856. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47857. serialize(): any;
  47858. }
  47859. }
  47860. declare module "babylonjs/Physics/physicsEngine" {
  47861. import { Nullable } from "babylonjs/types";
  47862. import { Vector3 } from "babylonjs/Maths/math";
  47863. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47864. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47865. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47866. /**
  47867. * Class used to control physics engine
  47868. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47869. */
  47870. export class PhysicsEngine implements IPhysicsEngine {
  47871. private _physicsPlugin;
  47872. /**
  47873. * Global value used to control the smallest number supported by the simulation
  47874. */
  47875. static Epsilon: number;
  47876. private _impostors;
  47877. private _joints;
  47878. /**
  47879. * Gets the gravity vector used by the simulation
  47880. */
  47881. gravity: Vector3;
  47882. /**
  47883. * Factory used to create the default physics plugin.
  47884. * @returns The default physics plugin
  47885. */
  47886. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47887. /**
  47888. * Creates a new Physics Engine
  47889. * @param gravity defines the gravity vector used by the simulation
  47890. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47891. */
  47892. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47893. /**
  47894. * Sets the gravity vector used by the simulation
  47895. * @param gravity defines the gravity vector to use
  47896. */
  47897. setGravity(gravity: Vector3): void;
  47898. /**
  47899. * Set the time step of the physics engine.
  47900. * Default is 1/60.
  47901. * To slow it down, enter 1/600 for example.
  47902. * To speed it up, 1/30
  47903. * @param newTimeStep defines the new timestep to apply to this world.
  47904. */
  47905. setTimeStep(newTimeStep?: number): void;
  47906. /**
  47907. * Get the time step of the physics engine.
  47908. * @returns the current time step
  47909. */
  47910. getTimeStep(): number;
  47911. /**
  47912. * Release all resources
  47913. */
  47914. dispose(): void;
  47915. /**
  47916. * Gets the name of the current physics plugin
  47917. * @returns the name of the plugin
  47918. */
  47919. getPhysicsPluginName(): string;
  47920. /**
  47921. * Adding a new impostor for the impostor tracking.
  47922. * This will be done by the impostor itself.
  47923. * @param impostor the impostor to add
  47924. */
  47925. addImpostor(impostor: PhysicsImpostor): void;
  47926. /**
  47927. * Remove an impostor from the engine.
  47928. * This impostor and its mesh will not longer be updated by the physics engine.
  47929. * @param impostor the impostor to remove
  47930. */
  47931. removeImpostor(impostor: PhysicsImpostor): void;
  47932. /**
  47933. * Add a joint to the physics engine
  47934. * @param mainImpostor defines the main impostor to which the joint is added.
  47935. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47936. * @param joint defines the joint that will connect both impostors.
  47937. */
  47938. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47939. /**
  47940. * Removes a joint from the simulation
  47941. * @param mainImpostor defines the impostor used with the joint
  47942. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47943. * @param joint defines the joint to remove
  47944. */
  47945. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47946. /**
  47947. * Called by the scene. No need to call it.
  47948. * @param delta defines the timespam between frames
  47949. */
  47950. _step(delta: number): void;
  47951. /**
  47952. * Gets the current plugin used to run the simulation
  47953. * @returns current plugin
  47954. */
  47955. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47956. /**
  47957. * Gets the list of physic impostors
  47958. * @returns an array of PhysicsImpostor
  47959. */
  47960. getImpostors(): Array<PhysicsImpostor>;
  47961. /**
  47962. * Gets the impostor for a physics enabled object
  47963. * @param object defines the object impersonated by the impostor
  47964. * @returns the PhysicsImpostor or null if not found
  47965. */
  47966. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47967. /**
  47968. * Gets the impostor for a physics body object
  47969. * @param body defines physics body used by the impostor
  47970. * @returns the PhysicsImpostor or null if not found
  47971. */
  47972. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47973. }
  47974. }
  47975. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47976. import { Nullable } from "babylonjs/types";
  47977. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47979. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47980. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47981. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47982. /** @hidden */
  47983. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47984. private _useDeltaForWorldStep;
  47985. world: any;
  47986. name: string;
  47987. private _physicsMaterials;
  47988. private _fixedTimeStep;
  47989. BJSCANNON: any;
  47990. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47991. setGravity(gravity: Vector3): void;
  47992. setTimeStep(timeStep: number): void;
  47993. getTimeStep(): number;
  47994. executeStep(delta: number): void;
  47995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47998. private _processChildMeshes;
  47999. removePhysicsBody(impostor: PhysicsImpostor): void;
  48000. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48001. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48002. private _addMaterial;
  48003. private _checkWithEpsilon;
  48004. private _createShape;
  48005. private _createHeightmap;
  48006. private _minus90X;
  48007. private _plus90X;
  48008. private _tmpPosition;
  48009. private _tmpDeltaPosition;
  48010. private _tmpUnityRotation;
  48011. private _updatePhysicsBodyTransformation;
  48012. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48013. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48014. isSupported(): boolean;
  48015. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48016. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48017. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48018. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48019. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48020. getBodyMass(impostor: PhysicsImpostor): number;
  48021. getBodyFriction(impostor: PhysicsImpostor): number;
  48022. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48023. getBodyRestitution(impostor: PhysicsImpostor): number;
  48024. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48025. sleepBody(impostor: PhysicsImpostor): void;
  48026. wakeUpBody(impostor: PhysicsImpostor): void;
  48027. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48028. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48029. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48030. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48031. getRadius(impostor: PhysicsImpostor): number;
  48032. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48033. dispose(): void;
  48034. private _extendNamespace;
  48035. }
  48036. }
  48037. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48038. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48039. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48040. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48042. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48043. import { Nullable } from "babylonjs/types";
  48044. /** @hidden */
  48045. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48046. world: any;
  48047. name: string;
  48048. BJSOIMO: any;
  48049. constructor(iterations?: number, oimoInjection?: any);
  48050. setGravity(gravity: Vector3): void;
  48051. setTimeStep(timeStep: number): void;
  48052. getTimeStep(): number;
  48053. private _tmpImpostorsArray;
  48054. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48055. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48056. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48057. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48058. private _tmpPositionVector;
  48059. removePhysicsBody(impostor: PhysicsImpostor): void;
  48060. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48061. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48062. isSupported(): boolean;
  48063. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48064. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48065. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48066. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48067. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48068. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48069. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48070. getBodyMass(impostor: PhysicsImpostor): number;
  48071. getBodyFriction(impostor: PhysicsImpostor): number;
  48072. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48073. getBodyRestitution(impostor: PhysicsImpostor): number;
  48074. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48075. sleepBody(impostor: PhysicsImpostor): void;
  48076. wakeUpBody(impostor: PhysicsImpostor): void;
  48077. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48078. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48079. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48080. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48081. getRadius(impostor: PhysicsImpostor): number;
  48082. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48083. dispose(): void;
  48084. }
  48085. }
  48086. declare module "babylonjs/Probes/reflectionProbe" {
  48087. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48088. import { Vector3 } from "babylonjs/Maths/math";
  48089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48090. import { Nullable } from "babylonjs/types";
  48091. import { Scene } from "babylonjs/scene";
  48092. module "babylonjs/abstractScene" {
  48093. interface AbstractScene {
  48094. /**
  48095. * The list of reflection probes added to the scene
  48096. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48097. */
  48098. reflectionProbes: Array<ReflectionProbe>;
  48099. /**
  48100. * Removes the given reflection probe from this scene.
  48101. * @param toRemove The reflection probe to remove
  48102. * @returns The index of the removed reflection probe
  48103. */
  48104. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48105. /**
  48106. * Adds the given reflection probe to this scene.
  48107. * @param newReflectionProbe The reflection probe to add
  48108. */
  48109. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48110. }
  48111. }
  48112. /**
  48113. * Class used to generate realtime reflection / refraction cube textures
  48114. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48115. */
  48116. export class ReflectionProbe {
  48117. /** defines the name of the probe */
  48118. name: string;
  48119. private _scene;
  48120. private _renderTargetTexture;
  48121. private _projectionMatrix;
  48122. private _viewMatrix;
  48123. private _target;
  48124. private _add;
  48125. private _attachedMesh;
  48126. private _invertYAxis;
  48127. /** Gets or sets probe position (center of the cube map) */
  48128. position: Vector3;
  48129. /**
  48130. * Creates a new reflection probe
  48131. * @param name defines the name of the probe
  48132. * @param size defines the texture resolution (for each face)
  48133. * @param scene defines the hosting scene
  48134. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48135. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48136. */
  48137. constructor(
  48138. /** defines the name of the probe */
  48139. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48140. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48141. samples: number;
  48142. /** Gets or sets the refresh rate to use (on every frame by default) */
  48143. refreshRate: number;
  48144. /**
  48145. * Gets the hosting scene
  48146. * @returns a Scene
  48147. */
  48148. getScene(): Scene;
  48149. /** Gets the internal CubeTexture used to render to */
  48150. readonly cubeTexture: RenderTargetTexture;
  48151. /** Gets the list of meshes to render */
  48152. readonly renderList: Nullable<AbstractMesh[]>;
  48153. /**
  48154. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48155. * @param mesh defines the mesh to attach to
  48156. */
  48157. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48158. /**
  48159. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48160. * @param renderingGroupId The rendering group id corresponding to its index
  48161. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48162. */
  48163. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48164. /**
  48165. * Clean all associated resources
  48166. */
  48167. dispose(): void;
  48168. /**
  48169. * Converts the reflection probe information to a readable string for debug purpose.
  48170. * @param fullDetails Supports for multiple levels of logging within scene loading
  48171. * @returns the human readable reflection probe info
  48172. */
  48173. toString(fullDetails?: boolean): string;
  48174. /**
  48175. * Get the class name of the relfection probe.
  48176. * @returns "ReflectionProbe"
  48177. */
  48178. getClassName(): string;
  48179. /**
  48180. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48181. * @returns The JSON representation of the texture
  48182. */
  48183. serialize(): any;
  48184. /**
  48185. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48186. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48187. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48188. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48189. * @returns The parsed reflection probe if successful
  48190. */
  48191. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48192. }
  48193. }
  48194. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48195. /** @hidden */
  48196. export var _BabylonLoaderRegistered: boolean;
  48197. }
  48198. declare module "babylonjs/Loading/Plugins/index" {
  48199. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48200. }
  48201. declare module "babylonjs/Loading/index" {
  48202. export * from "babylonjs/Loading/loadingScreen";
  48203. export * from "babylonjs/Loading/Plugins/index";
  48204. export * from "babylonjs/Loading/sceneLoader";
  48205. export * from "babylonjs/Loading/sceneLoaderFlags";
  48206. }
  48207. declare module "babylonjs/Materials/Background/index" {
  48208. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48209. }
  48210. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48211. import { Scene } from "babylonjs/scene";
  48212. import { Color3 } from "babylonjs/Maths/math";
  48213. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48215. /**
  48216. * The Physically based simple base material of BJS.
  48217. *
  48218. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48219. * It is used as the base class for both the specGloss and metalRough conventions.
  48220. */
  48221. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48222. /**
  48223. * Number of Simultaneous lights allowed on the material.
  48224. */
  48225. maxSimultaneousLights: number;
  48226. /**
  48227. * If sets to true, disables all the lights affecting the material.
  48228. */
  48229. disableLighting: boolean;
  48230. /**
  48231. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48232. */
  48233. environmentTexture: BaseTexture;
  48234. /**
  48235. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48236. */
  48237. invertNormalMapX: boolean;
  48238. /**
  48239. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48240. */
  48241. invertNormalMapY: boolean;
  48242. /**
  48243. * Normal map used in the model.
  48244. */
  48245. normalTexture: BaseTexture;
  48246. /**
  48247. * Emissivie color used to self-illuminate the model.
  48248. */
  48249. emissiveColor: Color3;
  48250. /**
  48251. * Emissivie texture used to self-illuminate the model.
  48252. */
  48253. emissiveTexture: BaseTexture;
  48254. /**
  48255. * Occlusion Channel Strenght.
  48256. */
  48257. occlusionStrength: number;
  48258. /**
  48259. * Occlusion Texture of the material (adding extra occlusion effects).
  48260. */
  48261. occlusionTexture: BaseTexture;
  48262. /**
  48263. * Defines the alpha limits in alpha test mode.
  48264. */
  48265. alphaCutOff: number;
  48266. /**
  48267. * Gets the current double sided mode.
  48268. */
  48269. /**
  48270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48271. */
  48272. doubleSided: boolean;
  48273. /**
  48274. * Stores the pre-calculated light information of a mesh in a texture.
  48275. */
  48276. lightmapTexture: BaseTexture;
  48277. /**
  48278. * If true, the light map contains occlusion information instead of lighting info.
  48279. */
  48280. useLightmapAsShadowmap: boolean;
  48281. /**
  48282. * Instantiates a new PBRMaterial instance.
  48283. *
  48284. * @param name The material name
  48285. * @param scene The scene the material will be use in.
  48286. */
  48287. constructor(name: string, scene: Scene);
  48288. getClassName(): string;
  48289. }
  48290. }
  48291. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48292. import { Scene } from "babylonjs/scene";
  48293. import { Color3 } from "babylonjs/Maths/math";
  48294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48295. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48296. /**
  48297. * The PBR material of BJS following the metal roughness convention.
  48298. *
  48299. * This fits to the PBR convention in the GLTF definition:
  48300. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48301. */
  48302. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48303. /**
  48304. * The base color has two different interpretations depending on the value of metalness.
  48305. * When the material is a metal, the base color is the specific measured reflectance value
  48306. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48307. * of the material.
  48308. */
  48309. baseColor: Color3;
  48310. /**
  48311. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48312. * well as opacity information in the alpha channel.
  48313. */
  48314. baseTexture: BaseTexture;
  48315. /**
  48316. * Specifies the metallic scalar value of the material.
  48317. * Can also be used to scale the metalness values of the metallic texture.
  48318. */
  48319. metallic: number;
  48320. /**
  48321. * Specifies the roughness scalar value of the material.
  48322. * Can also be used to scale the roughness values of the metallic texture.
  48323. */
  48324. roughness: number;
  48325. /**
  48326. * Texture containing both the metallic value in the B channel and the
  48327. * roughness value in the G channel to keep better precision.
  48328. */
  48329. metallicRoughnessTexture: BaseTexture;
  48330. /**
  48331. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48332. *
  48333. * @param name The material name
  48334. * @param scene The scene the material will be use in.
  48335. */
  48336. constructor(name: string, scene: Scene);
  48337. /**
  48338. * Return the currrent class name of the material.
  48339. */
  48340. getClassName(): string;
  48341. /**
  48342. * Makes a duplicate of the current material.
  48343. * @param name - name to use for the new material.
  48344. */
  48345. clone(name: string): PBRMetallicRoughnessMaterial;
  48346. /**
  48347. * Serialize the material to a parsable JSON object.
  48348. */
  48349. serialize(): any;
  48350. /**
  48351. * Parses a JSON object correponding to the serialize function.
  48352. */
  48353. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48354. }
  48355. }
  48356. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48357. import { Scene } from "babylonjs/scene";
  48358. import { Color3 } from "babylonjs/Maths/math";
  48359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48360. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48361. /**
  48362. * The PBR material of BJS following the specular glossiness convention.
  48363. *
  48364. * This fits to the PBR convention in the GLTF definition:
  48365. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48366. */
  48367. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48368. /**
  48369. * Specifies the diffuse color of the material.
  48370. */
  48371. diffuseColor: Color3;
  48372. /**
  48373. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48374. * channel.
  48375. */
  48376. diffuseTexture: BaseTexture;
  48377. /**
  48378. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48379. */
  48380. specularColor: Color3;
  48381. /**
  48382. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48383. */
  48384. glossiness: number;
  48385. /**
  48386. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48387. */
  48388. specularGlossinessTexture: BaseTexture;
  48389. /**
  48390. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48391. *
  48392. * @param name The material name
  48393. * @param scene The scene the material will be use in.
  48394. */
  48395. constructor(name: string, scene: Scene);
  48396. /**
  48397. * Return the currrent class name of the material.
  48398. */
  48399. getClassName(): string;
  48400. /**
  48401. * Makes a duplicate of the current material.
  48402. * @param name - name to use for the new material.
  48403. */
  48404. clone(name: string): PBRSpecularGlossinessMaterial;
  48405. /**
  48406. * Serialize the material to a parsable JSON object.
  48407. */
  48408. serialize(): any;
  48409. /**
  48410. * Parses a JSON object correponding to the serialize function.
  48411. */
  48412. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48413. }
  48414. }
  48415. declare module "babylonjs/Materials/PBR/index" {
  48416. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48417. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48418. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48419. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48420. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48421. }
  48422. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48423. import { Nullable } from "babylonjs/types";
  48424. import { Scene } from "babylonjs/scene";
  48425. import { Matrix } from "babylonjs/Maths/math";
  48426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48427. /**
  48428. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48429. * It can help converting any input color in a desired output one. This can then be used to create effects
  48430. * from sepia, black and white to sixties or futuristic rendering...
  48431. *
  48432. * The only supported format is currently 3dl.
  48433. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48434. */
  48435. export class ColorGradingTexture extends BaseTexture {
  48436. /**
  48437. * The current texture matrix. (will always be identity in color grading texture)
  48438. */
  48439. private _textureMatrix;
  48440. /**
  48441. * The texture URL.
  48442. */
  48443. url: string;
  48444. /**
  48445. * Empty line regex stored for GC.
  48446. */
  48447. private static _noneEmptyLineRegex;
  48448. private _engine;
  48449. /**
  48450. * Instantiates a ColorGradingTexture from the following parameters.
  48451. *
  48452. * @param url The location of the color gradind data (currently only supporting 3dl)
  48453. * @param scene The scene the texture will be used in
  48454. */
  48455. constructor(url: string, scene: Scene);
  48456. /**
  48457. * Returns the texture matrix used in most of the material.
  48458. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48459. */
  48460. getTextureMatrix(): Matrix;
  48461. /**
  48462. * Occurs when the file being loaded is a .3dl LUT file.
  48463. */
  48464. private load3dlTexture;
  48465. /**
  48466. * Starts the loading process of the texture.
  48467. */
  48468. private loadTexture;
  48469. /**
  48470. * Clones the color gradind texture.
  48471. */
  48472. clone(): ColorGradingTexture;
  48473. /**
  48474. * Called during delayed load for textures.
  48475. */
  48476. delayLoad(): void;
  48477. /**
  48478. * Parses a color grading texture serialized by Babylon.
  48479. * @param parsedTexture The texture information being parsedTexture
  48480. * @param scene The scene to load the texture in
  48481. * @param rootUrl The root url of the data assets to load
  48482. * @return A color gradind texture
  48483. */
  48484. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48485. /**
  48486. * Serializes the LUT texture to json format.
  48487. */
  48488. serialize(): any;
  48489. }
  48490. }
  48491. declare module "babylonjs/Misc/dds" {
  48492. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48493. import { Engine } from "babylonjs/Engines/engine";
  48494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48495. import { Nullable } from "babylonjs/types";
  48496. import { Scene } from "babylonjs/scene";
  48497. /**
  48498. * Direct draw surface info
  48499. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48500. */
  48501. export interface DDSInfo {
  48502. /**
  48503. * Width of the texture
  48504. */
  48505. width: number;
  48506. /**
  48507. * Width of the texture
  48508. */
  48509. height: number;
  48510. /**
  48511. * Number of Mipmaps for the texture
  48512. * @see https://en.wikipedia.org/wiki/Mipmap
  48513. */
  48514. mipmapCount: number;
  48515. /**
  48516. * If the textures format is a known fourCC format
  48517. * @see https://www.fourcc.org/
  48518. */
  48519. isFourCC: boolean;
  48520. /**
  48521. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48522. */
  48523. isRGB: boolean;
  48524. /**
  48525. * If the texture is a lumincance format
  48526. */
  48527. isLuminance: boolean;
  48528. /**
  48529. * If this is a cube texture
  48530. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48531. */
  48532. isCube: boolean;
  48533. /**
  48534. * If the texture is a compressed format eg. FOURCC_DXT1
  48535. */
  48536. isCompressed: boolean;
  48537. /**
  48538. * The dxgiFormat of the texture
  48539. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48540. */
  48541. dxgiFormat: number;
  48542. /**
  48543. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48544. */
  48545. textureType: number;
  48546. /**
  48547. * Sphericle polynomial created for the dds texture
  48548. */
  48549. sphericalPolynomial?: SphericalPolynomial;
  48550. }
  48551. /**
  48552. * Class used to provide DDS decompression tools
  48553. */
  48554. export class DDSTools {
  48555. /**
  48556. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48557. */
  48558. static StoreLODInAlphaChannel: boolean;
  48559. /**
  48560. * Gets DDS information from an array buffer
  48561. * @param arrayBuffer defines the array buffer to read data from
  48562. * @returns the DDS information
  48563. */
  48564. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48565. private static _FloatView;
  48566. private static _Int32View;
  48567. private static _ToHalfFloat;
  48568. private static _FromHalfFloat;
  48569. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48570. private static _GetHalfFloatRGBAArrayBuffer;
  48571. private static _GetFloatRGBAArrayBuffer;
  48572. private static _GetFloatAsUIntRGBAArrayBuffer;
  48573. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48574. private static _GetRGBAArrayBuffer;
  48575. private static _ExtractLongWordOrder;
  48576. private static _GetRGBArrayBuffer;
  48577. private static _GetLuminanceArrayBuffer;
  48578. /**
  48579. * Uploads DDS Levels to a Babylon Texture
  48580. * @hidden
  48581. */
  48582. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48583. }
  48584. module "babylonjs/Engines/engine" {
  48585. interface Engine {
  48586. /**
  48587. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48588. * @param rootUrl defines the url where the file to load is located
  48589. * @param scene defines the current scene
  48590. * @param lodScale defines scale to apply to the mip map selection
  48591. * @param lodOffset defines offset to apply to the mip map selection
  48592. * @param onLoad defines an optional callback raised when the texture is loaded
  48593. * @param onError defines an optional callback raised if there is an issue to load the texture
  48594. * @param format defines the format of the data
  48595. * @param forcedExtension defines the extension to use to pick the right loader
  48596. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48597. * @returns the cube texture as an InternalTexture
  48598. */
  48599. 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;
  48600. }
  48601. }
  48602. }
  48603. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48604. import { Nullable } from "babylonjs/types";
  48605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48606. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48607. /**
  48608. * Implementation of the DDS Texture Loader.
  48609. * @hidden
  48610. */
  48611. export class _DDSTextureLoader implements IInternalTextureLoader {
  48612. /**
  48613. * Defines wether the loader supports cascade loading the different faces.
  48614. */
  48615. readonly supportCascades: boolean;
  48616. /**
  48617. * This returns if the loader support the current file information.
  48618. * @param extension defines the file extension of the file being loaded
  48619. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48620. * @param fallback defines the fallback internal texture if any
  48621. * @param isBase64 defines whether the texture is encoded as a base64
  48622. * @param isBuffer defines whether the texture data are stored as a buffer
  48623. * @returns true if the loader can load the specified file
  48624. */
  48625. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48626. /**
  48627. * Transform the url before loading if required.
  48628. * @param rootUrl the url of the texture
  48629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48630. * @returns the transformed texture
  48631. */
  48632. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48633. /**
  48634. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48635. * @param rootUrl the url of the texture
  48636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48637. * @returns the fallback texture
  48638. */
  48639. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48640. /**
  48641. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48642. * @param data contains the texture data
  48643. * @param texture defines the BabylonJS internal texture
  48644. * @param createPolynomials will be true if polynomials have been requested
  48645. * @param onLoad defines the callback to trigger once the texture is ready
  48646. * @param onError defines the callback to trigger in case of error
  48647. */
  48648. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48649. /**
  48650. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48651. * @param data contains the texture data
  48652. * @param texture defines the BabylonJS internal texture
  48653. * @param callback defines the method to call once ready to upload
  48654. */
  48655. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48656. }
  48657. }
  48658. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48659. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48660. /** @hidden */
  48661. export var rgbdEncodePixelShader: {
  48662. name: string;
  48663. shader: string;
  48664. };
  48665. }
  48666. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48667. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48668. /** @hidden */
  48669. export var rgbdDecodePixelShader: {
  48670. name: string;
  48671. shader: string;
  48672. };
  48673. }
  48674. declare module "babylonjs/Misc/environmentTextureTools" {
  48675. import { Nullable } from "babylonjs/types";
  48676. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48677. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48678. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48679. import "babylonjs/Shaders/rgbdEncode.fragment";
  48680. import "babylonjs/Shaders/rgbdDecode.fragment";
  48681. /**
  48682. * Raw texture data and descriptor sufficient for WebGL texture upload
  48683. */
  48684. export interface EnvironmentTextureInfo {
  48685. /**
  48686. * Version of the environment map
  48687. */
  48688. version: number;
  48689. /**
  48690. * Width of image
  48691. */
  48692. width: number;
  48693. /**
  48694. * Irradiance information stored in the file.
  48695. */
  48696. irradiance: any;
  48697. /**
  48698. * Specular information stored in the file.
  48699. */
  48700. specular: any;
  48701. }
  48702. /**
  48703. * Sets of helpers addressing the serialization and deserialization of environment texture
  48704. * stored in a BabylonJS env file.
  48705. * Those files are usually stored as .env files.
  48706. */
  48707. export class EnvironmentTextureTools {
  48708. /**
  48709. * Magic number identifying the env file.
  48710. */
  48711. private static _MagicBytes;
  48712. /**
  48713. * Gets the environment info from an env file.
  48714. * @param data The array buffer containing the .env bytes.
  48715. * @returns the environment file info (the json header) if successfully parsed.
  48716. */
  48717. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48718. /**
  48719. * Creates an environment texture from a loaded cube texture.
  48720. * @param texture defines the cube texture to convert in env file
  48721. * @return a promise containing the environment data if succesfull.
  48722. */
  48723. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48724. /**
  48725. * Creates a JSON representation of the spherical data.
  48726. * @param texture defines the texture containing the polynomials
  48727. * @return the JSON representation of the spherical info
  48728. */
  48729. private static _CreateEnvTextureIrradiance;
  48730. /**
  48731. * Uploads the texture info contained in the env file to the GPU.
  48732. * @param texture defines the internal texture to upload to
  48733. * @param arrayBuffer defines the buffer cotaining the data to load
  48734. * @param info defines the texture info retrieved through the GetEnvInfo method
  48735. * @returns a promise
  48736. */
  48737. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48738. /**
  48739. * Uploads the levels of image data to the GPU.
  48740. * @param texture defines the internal texture to upload to
  48741. * @param imageData defines the array buffer views of image data [mipmap][face]
  48742. * @returns a promise
  48743. */
  48744. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48745. /**
  48746. * Uploads spherical polynomials information to the texture.
  48747. * @param texture defines the texture we are trying to upload the information to
  48748. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48749. */
  48750. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48751. /** @hidden */
  48752. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48753. }
  48754. }
  48755. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48756. import { Nullable } from "babylonjs/types";
  48757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48758. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48759. /**
  48760. * Implementation of the ENV Texture Loader.
  48761. * @hidden
  48762. */
  48763. export class _ENVTextureLoader implements IInternalTextureLoader {
  48764. /**
  48765. * Defines wether the loader supports cascade loading the different faces.
  48766. */
  48767. readonly supportCascades: boolean;
  48768. /**
  48769. * This returns if the loader support the current file information.
  48770. * @param extension defines the file extension of the file being loaded
  48771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48772. * @param fallback defines the fallback internal texture if any
  48773. * @param isBase64 defines whether the texture is encoded as a base64
  48774. * @param isBuffer defines whether the texture data are stored as a buffer
  48775. * @returns true if the loader can load the specified file
  48776. */
  48777. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48778. /**
  48779. * Transform the url before loading if required.
  48780. * @param rootUrl the url of the texture
  48781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48782. * @returns the transformed texture
  48783. */
  48784. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48785. /**
  48786. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48787. * @param rootUrl the url of the texture
  48788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48789. * @returns the fallback texture
  48790. */
  48791. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48792. /**
  48793. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48794. * @param data contains the texture data
  48795. * @param texture defines the BabylonJS internal texture
  48796. * @param createPolynomials will be true if polynomials have been requested
  48797. * @param onLoad defines the callback to trigger once the texture is ready
  48798. * @param onError defines the callback to trigger in case of error
  48799. */
  48800. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48801. /**
  48802. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48803. * @param data contains the texture data
  48804. * @param texture defines the BabylonJS internal texture
  48805. * @param callback defines the method to call once ready to upload
  48806. */
  48807. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48808. }
  48809. }
  48810. declare module "babylonjs/Misc/khronosTextureContainer" {
  48811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48812. /**
  48813. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48814. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48815. */
  48816. export class KhronosTextureContainer {
  48817. /** contents of the KTX container file */
  48818. arrayBuffer: any;
  48819. private static HEADER_LEN;
  48820. private static COMPRESSED_2D;
  48821. private static COMPRESSED_3D;
  48822. private static TEX_2D;
  48823. private static TEX_3D;
  48824. /**
  48825. * Gets the openGL type
  48826. */
  48827. glType: number;
  48828. /**
  48829. * Gets the openGL type size
  48830. */
  48831. glTypeSize: number;
  48832. /**
  48833. * Gets the openGL format
  48834. */
  48835. glFormat: number;
  48836. /**
  48837. * Gets the openGL internal format
  48838. */
  48839. glInternalFormat: number;
  48840. /**
  48841. * Gets the base internal format
  48842. */
  48843. glBaseInternalFormat: number;
  48844. /**
  48845. * Gets image width in pixel
  48846. */
  48847. pixelWidth: number;
  48848. /**
  48849. * Gets image height in pixel
  48850. */
  48851. pixelHeight: number;
  48852. /**
  48853. * Gets image depth in pixels
  48854. */
  48855. pixelDepth: number;
  48856. /**
  48857. * Gets the number of array elements
  48858. */
  48859. numberOfArrayElements: number;
  48860. /**
  48861. * Gets the number of faces
  48862. */
  48863. numberOfFaces: number;
  48864. /**
  48865. * Gets the number of mipmap levels
  48866. */
  48867. numberOfMipmapLevels: number;
  48868. /**
  48869. * Gets the bytes of key value data
  48870. */
  48871. bytesOfKeyValueData: number;
  48872. /**
  48873. * Gets the load type
  48874. */
  48875. loadType: number;
  48876. /**
  48877. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48878. */
  48879. isInvalid: boolean;
  48880. /**
  48881. * Creates a new KhronosTextureContainer
  48882. * @param arrayBuffer contents of the KTX container file
  48883. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48884. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48885. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48886. */
  48887. constructor(
  48888. /** contents of the KTX container file */
  48889. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48890. /**
  48891. * Uploads KTX content to a Babylon Texture.
  48892. * It is assumed that the texture has already been created & is currently bound
  48893. * @hidden
  48894. */
  48895. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48896. private _upload2DCompressedLevels;
  48897. }
  48898. }
  48899. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48900. import { Nullable } from "babylonjs/types";
  48901. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48902. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48903. /**
  48904. * Implementation of the KTX Texture Loader.
  48905. * @hidden
  48906. */
  48907. export class _KTXTextureLoader implements IInternalTextureLoader {
  48908. /**
  48909. * Defines wether the loader supports cascade loading the different faces.
  48910. */
  48911. readonly supportCascades: boolean;
  48912. /**
  48913. * This returns if the loader support the current file information.
  48914. * @param extension defines the file extension of the file being loaded
  48915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48916. * @param fallback defines the fallback internal texture if any
  48917. * @param isBase64 defines whether the texture is encoded as a base64
  48918. * @param isBuffer defines whether the texture data are stored as a buffer
  48919. * @returns true if the loader can load the specified file
  48920. */
  48921. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48922. /**
  48923. * Transform the url before loading if required.
  48924. * @param rootUrl the url of the texture
  48925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48926. * @returns the transformed texture
  48927. */
  48928. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48929. /**
  48930. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48931. * @param rootUrl the url of the texture
  48932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48933. * @returns the fallback texture
  48934. */
  48935. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48936. /**
  48937. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48938. * @param data contains the texture data
  48939. * @param texture defines the BabylonJS internal texture
  48940. * @param createPolynomials will be true if polynomials have been requested
  48941. * @param onLoad defines the callback to trigger once the texture is ready
  48942. * @param onError defines the callback to trigger in case of error
  48943. */
  48944. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48945. /**
  48946. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48947. * @param data contains the texture data
  48948. * @param texture defines the BabylonJS internal texture
  48949. * @param callback defines the method to call once ready to upload
  48950. */
  48951. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48952. }
  48953. }
  48954. declare module "babylonjs/Misc/tga" {
  48955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48956. /**
  48957. * Based on jsTGALoader - Javascript loader for TGA file
  48958. * By Vincent Thibault
  48959. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48960. */
  48961. export class TGATools {
  48962. private static _TYPE_INDEXED;
  48963. private static _TYPE_RGB;
  48964. private static _TYPE_GREY;
  48965. private static _TYPE_RLE_INDEXED;
  48966. private static _TYPE_RLE_RGB;
  48967. private static _TYPE_RLE_GREY;
  48968. private static _ORIGIN_MASK;
  48969. private static _ORIGIN_SHIFT;
  48970. private static _ORIGIN_BL;
  48971. private static _ORIGIN_BR;
  48972. private static _ORIGIN_UL;
  48973. private static _ORIGIN_UR;
  48974. /**
  48975. * Gets the header of a TGA file
  48976. * @param data defines the TGA data
  48977. * @returns the header
  48978. */
  48979. static GetTGAHeader(data: Uint8Array): any;
  48980. /**
  48981. * Uploads TGA content to a Babylon Texture
  48982. * @hidden
  48983. */
  48984. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48985. /** @hidden */
  48986. 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;
  48987. /** @hidden */
  48988. 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;
  48989. /** @hidden */
  48990. 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;
  48991. /** @hidden */
  48992. 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;
  48993. /** @hidden */
  48994. 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;
  48995. /** @hidden */
  48996. 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;
  48997. }
  48998. }
  48999. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49000. import { Nullable } from "babylonjs/types";
  49001. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49002. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49003. /**
  49004. * Implementation of the TGA Texture Loader.
  49005. * @hidden
  49006. */
  49007. export class _TGATextureLoader implements IInternalTextureLoader {
  49008. /**
  49009. * Defines wether the loader supports cascade loading the different faces.
  49010. */
  49011. readonly supportCascades: boolean;
  49012. /**
  49013. * This returns if the loader support the current file information.
  49014. * @param extension defines the file extension of the file being loaded
  49015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49016. * @param fallback defines the fallback internal texture if any
  49017. * @param isBase64 defines whether the texture is encoded as a base64
  49018. * @param isBuffer defines whether the texture data are stored as a buffer
  49019. * @returns true if the loader can load the specified file
  49020. */
  49021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49022. /**
  49023. * Transform the url before loading if required.
  49024. * @param rootUrl the url of the texture
  49025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49026. * @returns the transformed texture
  49027. */
  49028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49029. /**
  49030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49031. * @param rootUrl the url of the texture
  49032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49033. * @returns the fallback texture
  49034. */
  49035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49036. /**
  49037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49038. * @param data contains the texture data
  49039. * @param texture defines the BabylonJS internal texture
  49040. * @param createPolynomials will be true if polynomials have been requested
  49041. * @param onLoad defines the callback to trigger once the texture is ready
  49042. * @param onError defines the callback to trigger in case of error
  49043. */
  49044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49045. /**
  49046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49047. * @param data contains the texture data
  49048. * @param texture defines the BabylonJS internal texture
  49049. * @param callback defines the method to call once ready to upload
  49050. */
  49051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49052. }
  49053. }
  49054. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49055. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49056. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49057. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49058. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49059. }
  49060. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49061. import { Scene } from "babylonjs/scene";
  49062. import { Texture } from "babylonjs/Materials/Textures/texture";
  49063. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49064. /**
  49065. * 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.
  49066. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49067. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49068. */
  49069. export class CustomProceduralTexture extends ProceduralTexture {
  49070. private _animate;
  49071. private _time;
  49072. private _config;
  49073. private _texturePath;
  49074. /**
  49075. * Instantiates a new Custom Procedural Texture.
  49076. * 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.
  49077. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49078. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49079. * @param name Define the name of the texture
  49080. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49081. * @param size Define the size of the texture to create
  49082. * @param scene Define the scene the texture belongs to
  49083. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49084. * @param generateMipMaps Define if the texture should creates mip maps or not
  49085. */
  49086. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49087. private _loadJson;
  49088. /**
  49089. * Is the texture ready to be used ? (rendered at least once)
  49090. * @returns true if ready, otherwise, false.
  49091. */
  49092. isReady(): boolean;
  49093. /**
  49094. * Render the texture to its associated render target.
  49095. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49096. */
  49097. render(useCameraPostProcess?: boolean): void;
  49098. /**
  49099. * Update the list of dependant textures samplers in the shader.
  49100. */
  49101. updateTextures(): void;
  49102. /**
  49103. * Update the uniform values of the procedural texture in the shader.
  49104. */
  49105. updateShaderUniforms(): void;
  49106. /**
  49107. * Define if the texture animates or not.
  49108. */
  49109. animate: boolean;
  49110. }
  49111. }
  49112. declare module "babylonjs/Shaders/noise.fragment" {
  49113. /** @hidden */
  49114. export var noisePixelShader: {
  49115. name: string;
  49116. shader: string;
  49117. };
  49118. }
  49119. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49120. import { Nullable } from "babylonjs/types";
  49121. import { Scene } from "babylonjs/scene";
  49122. import { Texture } from "babylonjs/Materials/Textures/texture";
  49123. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49124. import "babylonjs/Shaders/noise.fragment";
  49125. /**
  49126. * Class used to generate noise procedural textures
  49127. */
  49128. export class NoiseProceduralTexture extends ProceduralTexture {
  49129. private _time;
  49130. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49131. brightness: number;
  49132. /** Defines the number of octaves to process */
  49133. octaves: number;
  49134. /** Defines the level of persistence (0.8 by default) */
  49135. persistence: number;
  49136. /** Gets or sets animation speed factor (default is 1) */
  49137. animationSpeedFactor: number;
  49138. /**
  49139. * Creates a new NoiseProceduralTexture
  49140. * @param name defines the name fo the texture
  49141. * @param size defines the size of the texture (default is 256)
  49142. * @param scene defines the hosting scene
  49143. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49144. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49145. */
  49146. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49147. private _updateShaderUniforms;
  49148. protected _getDefines(): string;
  49149. /** Generate the current state of the procedural texture */
  49150. render(useCameraPostProcess?: boolean): void;
  49151. /**
  49152. * Serializes this noise procedural texture
  49153. * @returns a serialized noise procedural texture object
  49154. */
  49155. serialize(): any;
  49156. /**
  49157. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49158. * @param parsedTexture defines parsed texture data
  49159. * @param scene defines the current scene
  49160. * @param rootUrl defines the root URL containing noise procedural texture information
  49161. * @returns a parsed NoiseProceduralTexture
  49162. */
  49163. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49164. }
  49165. }
  49166. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49167. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49168. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49169. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49170. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49171. }
  49172. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49173. import { Nullable } from "babylonjs/types";
  49174. import { Scene } from "babylonjs/scene";
  49175. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49176. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49177. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49178. /**
  49179. * Raw cube texture where the raw buffers are passed in
  49180. */
  49181. export class RawCubeTexture extends CubeTexture {
  49182. /**
  49183. * Creates a cube texture where the raw buffers are passed in.
  49184. * @param scene defines the scene the texture is attached to
  49185. * @param data defines the array of data to use to create each face
  49186. * @param size defines the size of the textures
  49187. * @param format defines the format of the data
  49188. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49189. * @param generateMipMaps defines if the engine should generate the mip levels
  49190. * @param invertY defines if data must be stored with Y axis inverted
  49191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49192. * @param compression defines the compression used (null by default)
  49193. */
  49194. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49195. /**
  49196. * Updates the raw cube texture.
  49197. * @param data defines the data to store
  49198. * @param format defines the data format
  49199. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49200. * @param invertY defines if data must be stored with Y axis inverted
  49201. * @param compression defines the compression used (null by default)
  49202. * @param level defines which level of the texture to update
  49203. */
  49204. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49205. /**
  49206. * Updates a raw cube texture with RGBD encoded data.
  49207. * @param data defines the array of data [mipmap][face] to use to create each face
  49208. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49209. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49210. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49211. * @returns a promsie that resolves when the operation is complete
  49212. */
  49213. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49214. /**
  49215. * Clones the raw cube texture.
  49216. * @return a new cube texture
  49217. */
  49218. clone(): CubeTexture;
  49219. /** @hidden */
  49220. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49221. }
  49222. }
  49223. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49224. import { Scene } from "babylonjs/scene";
  49225. import { Texture } from "babylonjs/Materials/Textures/texture";
  49226. /**
  49227. * Class used to store 3D textures containing user data
  49228. */
  49229. export class RawTexture3D extends Texture {
  49230. /** Gets or sets the texture format to use */
  49231. format: number;
  49232. private _engine;
  49233. /**
  49234. * Create a new RawTexture3D
  49235. * @param data defines the data of the texture
  49236. * @param width defines the width of the texture
  49237. * @param height defines the height of the texture
  49238. * @param depth defines the depth of the texture
  49239. * @param format defines the texture format to use
  49240. * @param scene defines the hosting scene
  49241. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49242. * @param invertY defines if texture must be stored with Y axis inverted
  49243. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49244. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49245. */
  49246. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49247. /** Gets or sets the texture format to use */
  49248. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49249. /**
  49250. * Update the texture with new data
  49251. * @param data defines the data to store in the texture
  49252. */
  49253. update(data: ArrayBufferView): void;
  49254. }
  49255. }
  49256. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49257. import { Scene } from "babylonjs/scene";
  49258. import { Plane } from "babylonjs/Maths/math";
  49259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49260. /**
  49261. * Creates a refraction texture used by refraction channel of the standard material.
  49262. * It is like a mirror but to see through a material.
  49263. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49264. */
  49265. export class RefractionTexture extends RenderTargetTexture {
  49266. /**
  49267. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49268. * 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.
  49269. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49270. */
  49271. refractionPlane: Plane;
  49272. /**
  49273. * Define how deep under the surface we should see.
  49274. */
  49275. depth: number;
  49276. /**
  49277. * Creates a refraction texture used by refraction channel of the standard material.
  49278. * It is like a mirror but to see through a material.
  49279. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49280. * @param name Define the texture name
  49281. * @param size Define the size of the underlying texture
  49282. * @param scene Define the scene the refraction belongs to
  49283. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49284. */
  49285. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49286. /**
  49287. * Clone the refraction texture.
  49288. * @returns the cloned texture
  49289. */
  49290. clone(): RefractionTexture;
  49291. /**
  49292. * Serialize the texture to a JSON representation you could use in Parse later on
  49293. * @returns the serialized JSON representation
  49294. */
  49295. serialize(): any;
  49296. }
  49297. }
  49298. declare module "babylonjs/Materials/Textures/index" {
  49299. export * from "babylonjs/Materials/Textures/baseTexture";
  49300. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49301. export * from "babylonjs/Materials/Textures/cubeTexture";
  49302. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49303. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49304. export * from "babylonjs/Materials/Textures/internalTexture";
  49305. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49306. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49307. export * from "babylonjs/Materials/Textures/Loaders/index";
  49308. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49309. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49310. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49311. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49312. export * from "babylonjs/Materials/Textures/rawTexture";
  49313. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49314. export * from "babylonjs/Materials/Textures/refractionTexture";
  49315. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49316. export * from "babylonjs/Materials/Textures/texture";
  49317. export * from "babylonjs/Materials/Textures/videoTexture";
  49318. }
  49319. declare module "babylonjs/Materials/index" {
  49320. export * from "babylonjs/Materials/Background/index";
  49321. export * from "babylonjs/Materials/colorCurves";
  49322. export * from "babylonjs/Materials/effect";
  49323. export * from "babylonjs/Materials/fresnelParameters";
  49324. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49325. export * from "babylonjs/Materials/material";
  49326. export * from "babylonjs/Materials/materialDefines";
  49327. export * from "babylonjs/Materials/materialHelper";
  49328. export * from "babylonjs/Materials/multiMaterial";
  49329. export * from "babylonjs/Materials/PBR/index";
  49330. export * from "babylonjs/Materials/pushMaterial";
  49331. export * from "babylonjs/Materials/shaderMaterial";
  49332. export * from "babylonjs/Materials/standardMaterial";
  49333. export * from "babylonjs/Materials/Textures/index";
  49334. export * from "babylonjs/Materials/uniformBuffer";
  49335. export * from "babylonjs/Materials/materialFlags";
  49336. }
  49337. declare module "babylonjs/Maths/index" {
  49338. export * from "babylonjs/Maths/math.scalar";
  49339. export * from "babylonjs/Maths/math";
  49340. export * from "babylonjs/Maths/sphericalPolynomial";
  49341. }
  49342. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49343. import { IDisposable } from "babylonjs/scene";
  49344. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49345. /**
  49346. * Configuration for Draco compression
  49347. */
  49348. export interface IDracoCompressionConfiguration {
  49349. /**
  49350. * Configuration for the decoder.
  49351. */
  49352. decoder?: {
  49353. /**
  49354. * The url to the WebAssembly module.
  49355. */
  49356. wasmUrl?: string;
  49357. /**
  49358. * The url to the WebAssembly binary.
  49359. */
  49360. wasmBinaryUrl?: string;
  49361. /**
  49362. * The url to the fallback JavaScript module.
  49363. */
  49364. fallbackUrl?: string;
  49365. };
  49366. }
  49367. /**
  49368. * Draco compression (https://google.github.io/draco/)
  49369. *
  49370. * This class wraps the Draco module.
  49371. *
  49372. * **Encoder**
  49373. *
  49374. * The encoder is not currently implemented.
  49375. *
  49376. * **Decoder**
  49377. *
  49378. * 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.
  49379. *
  49380. * To update the configuration, use the following code:
  49381. * ```javascript
  49382. * DracoCompression.Configuration = {
  49383. * decoder: {
  49384. * wasmUrl: "<url to the WebAssembly library>",
  49385. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49386. * fallbackUrl: "<url to the fallback JavaScript library>",
  49387. * }
  49388. * };
  49389. * ```
  49390. *
  49391. * 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.
  49392. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49393. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49394. *
  49395. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49396. * ```javascript
  49397. * var dracoCompression = new DracoCompression();
  49398. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49399. * [VertexBuffer.PositionKind]: 0
  49400. * });
  49401. * ```
  49402. *
  49403. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49404. */
  49405. export class DracoCompression implements IDisposable {
  49406. private static _DecoderModulePromise;
  49407. /**
  49408. * The configuration. Defaults to the following urls:
  49409. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49410. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49411. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49412. */
  49413. static Configuration: IDracoCompressionConfiguration;
  49414. /**
  49415. * Returns true if the decoder is available.
  49416. */
  49417. static readonly DecoderAvailable: boolean;
  49418. /**
  49419. * Constructor
  49420. */
  49421. constructor();
  49422. /**
  49423. * Stop all async operations and release resources.
  49424. */
  49425. dispose(): void;
  49426. /**
  49427. * Decode Draco compressed mesh data to vertex data.
  49428. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49429. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49430. * @returns A promise that resolves with the decoded vertex data
  49431. */
  49432. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49433. [kind: string]: number;
  49434. }): Promise<VertexData>;
  49435. private static _GetDecoderModule;
  49436. private static _LoadScriptAsync;
  49437. private static _LoadFileAsync;
  49438. }
  49439. }
  49440. declare module "babylonjs/Meshes/Compression/index" {
  49441. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49442. }
  49443. declare module "babylonjs/Meshes/csg" {
  49444. import { Nullable } from "babylonjs/types";
  49445. import { Scene } from "babylonjs/scene";
  49446. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49447. import { Mesh } from "babylonjs/Meshes/mesh";
  49448. import { Material } from "babylonjs/Materials/material";
  49449. /**
  49450. * Class for building Constructive Solid Geometry
  49451. */
  49452. export class CSG {
  49453. private polygons;
  49454. /**
  49455. * The world matrix
  49456. */
  49457. matrix: Matrix;
  49458. /**
  49459. * Stores the position
  49460. */
  49461. position: Vector3;
  49462. /**
  49463. * Stores the rotation
  49464. */
  49465. rotation: Vector3;
  49466. /**
  49467. * Stores the rotation quaternion
  49468. */
  49469. rotationQuaternion: Nullable<Quaternion>;
  49470. /**
  49471. * Stores the scaling vector
  49472. */
  49473. scaling: Vector3;
  49474. /**
  49475. * Convert the Mesh to CSG
  49476. * @param mesh The Mesh to convert to CSG
  49477. * @returns A new CSG from the Mesh
  49478. */
  49479. static FromMesh(mesh: Mesh): CSG;
  49480. /**
  49481. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49482. * @param polygons Polygons used to construct a CSG solid
  49483. */
  49484. private static FromPolygons;
  49485. /**
  49486. * Clones, or makes a deep copy, of the CSG
  49487. * @returns A new CSG
  49488. */
  49489. clone(): CSG;
  49490. /**
  49491. * Unions this CSG with another CSG
  49492. * @param csg The CSG to union against this CSG
  49493. * @returns The unioned CSG
  49494. */
  49495. union(csg: CSG): CSG;
  49496. /**
  49497. * Unions this CSG with another CSG in place
  49498. * @param csg The CSG to union against this CSG
  49499. */
  49500. unionInPlace(csg: CSG): void;
  49501. /**
  49502. * Subtracts this CSG with another CSG
  49503. * @param csg The CSG to subtract against this CSG
  49504. * @returns A new CSG
  49505. */
  49506. subtract(csg: CSG): CSG;
  49507. /**
  49508. * Subtracts this CSG with another CSG in place
  49509. * @param csg The CSG to subtact against this CSG
  49510. */
  49511. subtractInPlace(csg: CSG): void;
  49512. /**
  49513. * Intersect this CSG with another CSG
  49514. * @param csg The CSG to intersect against this CSG
  49515. * @returns A new CSG
  49516. */
  49517. intersect(csg: CSG): CSG;
  49518. /**
  49519. * Intersects this CSG with another CSG in place
  49520. * @param csg The CSG to intersect against this CSG
  49521. */
  49522. intersectInPlace(csg: CSG): void;
  49523. /**
  49524. * Return a new CSG solid with solid and empty space switched. This solid is
  49525. * not modified.
  49526. * @returns A new CSG solid with solid and empty space switched
  49527. */
  49528. inverse(): CSG;
  49529. /**
  49530. * Inverses the CSG in place
  49531. */
  49532. inverseInPlace(): void;
  49533. /**
  49534. * This is used to keep meshes transformations so they can be restored
  49535. * when we build back a Babylon Mesh
  49536. * NB : All CSG operations are performed in world coordinates
  49537. * @param csg The CSG to copy the transform attributes from
  49538. * @returns This CSG
  49539. */
  49540. copyTransformAttributes(csg: CSG): CSG;
  49541. /**
  49542. * Build Raw mesh from CSG
  49543. * Coordinates here are in world space
  49544. * @param name The name of the mesh geometry
  49545. * @param scene The Scene
  49546. * @param keepSubMeshes Specifies if the submeshes should be kept
  49547. * @returns A new Mesh
  49548. */
  49549. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49550. /**
  49551. * Build Mesh from CSG taking material and transforms into account
  49552. * @param name The name of the Mesh
  49553. * @param material The material of the Mesh
  49554. * @param scene The Scene
  49555. * @param keepSubMeshes Specifies if submeshes should be kept
  49556. * @returns The new Mesh
  49557. */
  49558. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49559. }
  49560. }
  49561. declare module "babylonjs/Meshes/trailMesh" {
  49562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49563. import { Mesh } from "babylonjs/Meshes/mesh";
  49564. import { Scene } from "babylonjs/scene";
  49565. /**
  49566. * Class used to create a trail following a mesh
  49567. */
  49568. export class TrailMesh extends Mesh {
  49569. private _generator;
  49570. private _autoStart;
  49571. private _running;
  49572. private _diameter;
  49573. private _length;
  49574. private _sectionPolygonPointsCount;
  49575. private _sectionVectors;
  49576. private _sectionNormalVectors;
  49577. private _beforeRenderObserver;
  49578. /**
  49579. * @constructor
  49580. * @param name The value used by scene.getMeshByName() to do a lookup.
  49581. * @param generator The mesh to generate a trail.
  49582. * @param scene The scene to add this mesh to.
  49583. * @param diameter Diameter of trailing mesh. Default is 1.
  49584. * @param length Length of trailing mesh. Default is 60.
  49585. * @param autoStart Automatically start trailing mesh. Default true.
  49586. */
  49587. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49588. /**
  49589. * "TrailMesh"
  49590. * @returns "TrailMesh"
  49591. */
  49592. getClassName(): string;
  49593. private _createMesh;
  49594. /**
  49595. * Start trailing mesh.
  49596. */
  49597. start(): void;
  49598. /**
  49599. * Stop trailing mesh.
  49600. */
  49601. stop(): void;
  49602. /**
  49603. * Update trailing mesh geometry.
  49604. */
  49605. update(): void;
  49606. /**
  49607. * Returns a new TrailMesh object.
  49608. * @param name is a string, the name given to the new mesh
  49609. * @param newGenerator use new generator object for cloned trail mesh
  49610. * @returns a new mesh
  49611. */
  49612. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49613. /**
  49614. * Serializes this trail mesh
  49615. * @param serializationObject object to write serialization to
  49616. */
  49617. serialize(serializationObject: any): void;
  49618. /**
  49619. * Parses a serialized trail mesh
  49620. * @param parsedMesh the serialized mesh
  49621. * @param scene the scene to create the trail mesh in
  49622. * @returns the created trail mesh
  49623. */
  49624. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49625. }
  49626. }
  49627. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49628. import { Nullable } from "babylonjs/types";
  49629. import { Scene } from "babylonjs/scene";
  49630. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49631. import { Mesh } from "babylonjs/Meshes/mesh";
  49632. /**
  49633. * Class containing static functions to help procedurally build meshes
  49634. */
  49635. export class RibbonBuilder {
  49636. /**
  49637. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49638. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49639. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49640. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49641. * * 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
  49642. * * 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
  49643. * * 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
  49644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49647. * * 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
  49648. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49649. * * 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
  49650. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49652. * @param name defines the name of the mesh
  49653. * @param options defines the options used to create the mesh
  49654. * @param scene defines the hosting scene
  49655. * @returns the ribbon mesh
  49656. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49658. */
  49659. static CreateRibbon(name: string, options: {
  49660. pathArray: Vector3[][];
  49661. closeArray?: boolean;
  49662. closePath?: boolean;
  49663. offset?: number;
  49664. updatable?: boolean;
  49665. sideOrientation?: number;
  49666. frontUVs?: Vector4;
  49667. backUVs?: Vector4;
  49668. instance?: Mesh;
  49669. invertUV?: boolean;
  49670. uvs?: Vector2[];
  49671. colors?: Color4[];
  49672. }, scene?: Nullable<Scene>): Mesh;
  49673. }
  49674. }
  49675. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49676. import { Vector4 } from "babylonjs/Maths/math";
  49677. import { Mesh } from "babylonjs/Meshes/mesh";
  49678. /**
  49679. * Class containing static functions to help procedurally build meshes
  49680. */
  49681. export class TorusKnotBuilder {
  49682. /**
  49683. * Creates a torus knot mesh
  49684. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49685. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49686. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49687. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49691. * @param name defines the name of the mesh
  49692. * @param options defines the options used to create the mesh
  49693. * @param scene defines the hosting scene
  49694. * @returns the torus knot mesh
  49695. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49696. */
  49697. static CreateTorusKnot(name: string, options: {
  49698. radius?: number;
  49699. tube?: number;
  49700. radialSegments?: number;
  49701. tubularSegments?: number;
  49702. p?: number;
  49703. q?: number;
  49704. updatable?: boolean;
  49705. sideOrientation?: number;
  49706. frontUVs?: Vector4;
  49707. backUVs?: Vector4;
  49708. }, scene: any): Mesh;
  49709. }
  49710. }
  49711. declare module "babylonjs/Meshes/polygonMesh" {
  49712. import { Scene } from "babylonjs/scene";
  49713. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49714. import { Mesh } from "babylonjs/Meshes/mesh";
  49715. /**
  49716. * Polygon
  49717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49718. */
  49719. export class Polygon {
  49720. /**
  49721. * Creates a rectangle
  49722. * @param xmin bottom X coord
  49723. * @param ymin bottom Y coord
  49724. * @param xmax top X coord
  49725. * @param ymax top Y coord
  49726. * @returns points that make the resulting rectation
  49727. */
  49728. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49729. /**
  49730. * Creates a circle
  49731. * @param radius radius of circle
  49732. * @param cx scale in x
  49733. * @param cy scale in y
  49734. * @param numberOfSides number of sides that make up the circle
  49735. * @returns points that make the resulting circle
  49736. */
  49737. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49738. /**
  49739. * Creates a polygon from input string
  49740. * @param input Input polygon data
  49741. * @returns the parsed points
  49742. */
  49743. static Parse(input: string): Vector2[];
  49744. /**
  49745. * Starts building a polygon from x and y coordinates
  49746. * @param x x coordinate
  49747. * @param y y coordinate
  49748. * @returns the started path2
  49749. */
  49750. static StartingAt(x: number, y: number): Path2;
  49751. }
  49752. /**
  49753. * Builds a polygon
  49754. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49755. */
  49756. export class PolygonMeshBuilder {
  49757. private _points;
  49758. private _outlinepoints;
  49759. private _holes;
  49760. private _name;
  49761. private _scene;
  49762. private _epoints;
  49763. private _eholes;
  49764. private _addToepoint;
  49765. /**
  49766. * Babylon reference to the earcut plugin.
  49767. */
  49768. bjsEarcut: any;
  49769. /**
  49770. * Creates a PolygonMeshBuilder
  49771. * @param name name of the builder
  49772. * @param contours Path of the polygon
  49773. * @param scene scene to add to
  49774. * @param earcutInjection can be used to inject your own earcut reference
  49775. */
  49776. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49777. /**
  49778. * Adds a whole within the polygon
  49779. * @param hole Array of points defining the hole
  49780. * @returns this
  49781. */
  49782. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49783. /**
  49784. * Creates the polygon
  49785. * @param updatable If the mesh should be updatable
  49786. * @param depth The depth of the mesh created
  49787. * @returns the created mesh
  49788. */
  49789. build(updatable?: boolean, depth?: number): Mesh;
  49790. /**
  49791. * Adds a side to the polygon
  49792. * @param positions points that make the polygon
  49793. * @param normals normals of the polygon
  49794. * @param uvs uvs of the polygon
  49795. * @param indices indices of the polygon
  49796. * @param bounds bounds of the polygon
  49797. * @param points points of the polygon
  49798. * @param depth depth of the polygon
  49799. * @param flip flip of the polygon
  49800. */
  49801. private addSide;
  49802. }
  49803. }
  49804. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49805. import { Scene } from "babylonjs/scene";
  49806. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49807. import { Mesh } from "babylonjs/Meshes/mesh";
  49808. /**
  49809. * Class containing static functions to help procedurally build meshes
  49810. */
  49811. export class PolygonBuilder {
  49812. /**
  49813. * Creates a polygon mesh
  49814. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49815. * * 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
  49816. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49819. * * Remember you can only change the shape positions, not their number when updating a polygon
  49820. * @param name defines the name of the mesh
  49821. * @param options defines the options used to create the mesh
  49822. * @param scene defines the hosting scene
  49823. * @param earcutInjection can be used to inject your own earcut reference
  49824. * @returns the polygon mesh
  49825. */
  49826. static CreatePolygon(name: string, options: {
  49827. shape: Vector3[];
  49828. holes?: Vector3[][];
  49829. depth?: number;
  49830. faceUV?: Vector4[];
  49831. faceColors?: Color4[];
  49832. updatable?: boolean;
  49833. sideOrientation?: number;
  49834. frontUVs?: Vector4;
  49835. backUVs?: Vector4;
  49836. }, scene: Scene, earcutInjection?: any): Mesh;
  49837. /**
  49838. * Creates an extruded polygon mesh, with depth in the Y direction.
  49839. * * 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)
  49840. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49841. * @param name defines the name of the mesh
  49842. * @param options defines the options used to create the mesh
  49843. * @param scene defines the hosting scene
  49844. * @param earcutInjection can be used to inject your own earcut reference
  49845. * @returns the polygon mesh
  49846. */
  49847. static ExtrudePolygon(name: string, options: {
  49848. shape: Vector3[];
  49849. holes?: Vector3[][];
  49850. depth?: number;
  49851. faceUV?: Vector4[];
  49852. faceColors?: Color4[];
  49853. updatable?: boolean;
  49854. sideOrientation?: number;
  49855. frontUVs?: Vector4;
  49856. backUVs?: Vector4;
  49857. }, scene: Scene, earcutInjection?: any): Mesh;
  49858. }
  49859. }
  49860. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49861. import { Nullable } from "babylonjs/types";
  49862. import { Scene } from "babylonjs/scene";
  49863. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49864. import { Mesh } from "babylonjs/Meshes/mesh";
  49865. /**
  49866. * Class containing static functions to help procedurally build meshes
  49867. */
  49868. export class ShapeBuilder {
  49869. /**
  49870. * 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.
  49871. * * 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.
  49872. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49873. * * 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.
  49874. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49875. * * 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
  49876. * * 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
  49877. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49882. * @param name defines the name of the mesh
  49883. * @param options defines the options used to create the mesh
  49884. * @param scene defines the hosting scene
  49885. * @returns the extruded shape mesh
  49886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49888. */
  49889. static ExtrudeShape(name: string, options: {
  49890. shape: Vector3[];
  49891. path: Vector3[];
  49892. scale?: number;
  49893. rotation?: number;
  49894. cap?: number;
  49895. updatable?: boolean;
  49896. sideOrientation?: number;
  49897. frontUVs?: Vector4;
  49898. backUVs?: Vector4;
  49899. instance?: Mesh;
  49900. invertUV?: boolean;
  49901. }, scene?: Nullable<Scene>): Mesh;
  49902. /**
  49903. * Creates an custom extruded shape mesh.
  49904. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49905. * * 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.
  49906. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49907. * * 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
  49908. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49909. * * 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
  49910. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49911. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49912. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49913. * * 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
  49914. * * 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
  49915. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49920. * @param name defines the name of the mesh
  49921. * @param options defines the options used to create the mesh
  49922. * @param scene defines the hosting scene
  49923. * @returns the custom extruded shape mesh
  49924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49927. */
  49928. static ExtrudeShapeCustom(name: string, options: {
  49929. shape: Vector3[];
  49930. path: Vector3[];
  49931. scaleFunction?: any;
  49932. rotationFunction?: any;
  49933. ribbonCloseArray?: boolean;
  49934. ribbonClosePath?: boolean;
  49935. cap?: number;
  49936. updatable?: boolean;
  49937. sideOrientation?: number;
  49938. frontUVs?: Vector4;
  49939. backUVs?: Vector4;
  49940. instance?: Mesh;
  49941. invertUV?: boolean;
  49942. }, scene: Scene): Mesh;
  49943. private static _ExtrudeShapeGeneric;
  49944. }
  49945. }
  49946. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49947. import { Scene } from "babylonjs/scene";
  49948. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49949. import { Mesh } from "babylonjs/Meshes/mesh";
  49950. /**
  49951. * Class containing static functions to help procedurally build meshes
  49952. */
  49953. export class LatheBuilder {
  49954. /**
  49955. * Creates lathe mesh.
  49956. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49957. * * 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
  49958. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49959. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49960. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49961. * * 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
  49962. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49963. * * 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
  49964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49968. * @param name defines the name of the mesh
  49969. * @param options defines the options used to create the mesh
  49970. * @param scene defines the hosting scene
  49971. * @returns the lathe mesh
  49972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49973. */
  49974. static CreateLathe(name: string, options: {
  49975. shape: Vector3[];
  49976. radius?: number;
  49977. tessellation?: number;
  49978. clip?: number;
  49979. arc?: number;
  49980. closed?: boolean;
  49981. updatable?: boolean;
  49982. sideOrientation?: number;
  49983. frontUVs?: Vector4;
  49984. backUVs?: Vector4;
  49985. cap?: number;
  49986. invertUV?: boolean;
  49987. }, scene: Scene): Mesh;
  49988. }
  49989. }
  49990. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49991. import { Scene } from "babylonjs/scene";
  49992. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49993. import { Mesh } from "babylonjs/Meshes/mesh";
  49994. /**
  49995. * Class containing static functions to help procedurally build meshes
  49996. */
  49997. export class TubeBuilder {
  49998. /**
  49999. * Creates a tube mesh.
  50000. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50001. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50002. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50003. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50004. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50005. * * 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)
  50006. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50007. * * 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
  50008. * * 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
  50009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50013. * @param name defines the name of the mesh
  50014. * @param options defines the options used to create the mesh
  50015. * @param scene defines the hosting scene
  50016. * @returns the tube mesh
  50017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50018. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50019. */
  50020. static CreateTube(name: string, options: {
  50021. path: Vector3[];
  50022. radius?: number;
  50023. tessellation?: number;
  50024. radiusFunction?: {
  50025. (i: number, distance: number): number;
  50026. };
  50027. cap?: number;
  50028. arc?: number;
  50029. updatable?: boolean;
  50030. sideOrientation?: number;
  50031. frontUVs?: Vector4;
  50032. backUVs?: Vector4;
  50033. instance?: Mesh;
  50034. invertUV?: boolean;
  50035. }, scene: Scene): Mesh;
  50036. }
  50037. }
  50038. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50039. import { Scene } from "babylonjs/scene";
  50040. import { Vector4 } from "babylonjs/Maths/math";
  50041. import { Mesh } from "babylonjs/Meshes/mesh";
  50042. /**
  50043. * Class containing static functions to help procedurally build meshes
  50044. */
  50045. export class IcoSphereBuilder {
  50046. /**
  50047. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50048. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50049. * * 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`)
  50050. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50051. * * 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
  50052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50055. * @param name defines the name of the mesh
  50056. * @param options defines the options used to create the mesh
  50057. * @param scene defines the hosting scene
  50058. * @returns the icosahedron mesh
  50059. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50060. */
  50061. static CreateIcoSphere(name: string, options: {
  50062. radius?: number;
  50063. radiusX?: number;
  50064. radiusY?: number;
  50065. radiusZ?: number;
  50066. flat?: boolean;
  50067. subdivisions?: number;
  50068. sideOrientation?: number;
  50069. frontUVs?: Vector4;
  50070. backUVs?: Vector4;
  50071. updatable?: boolean;
  50072. }, scene: Scene): Mesh;
  50073. }
  50074. }
  50075. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50076. import { Vector3 } from "babylonjs/Maths/math";
  50077. import { Mesh } from "babylonjs/Meshes/mesh";
  50078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50079. /**
  50080. * Class containing static functions to help procedurally build meshes
  50081. */
  50082. export class DecalBuilder {
  50083. /**
  50084. * Creates a decal mesh.
  50085. * 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
  50086. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50087. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50088. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50089. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50090. * @param name defines the name of the mesh
  50091. * @param sourceMesh defines the mesh where the decal must be applied
  50092. * @param options defines the options used to create the mesh
  50093. * @param scene defines the hosting scene
  50094. * @returns the decal mesh
  50095. * @see https://doc.babylonjs.com/how_to/decals
  50096. */
  50097. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50098. position?: Vector3;
  50099. normal?: Vector3;
  50100. size?: Vector3;
  50101. angle?: number;
  50102. }): Mesh;
  50103. }
  50104. }
  50105. declare module "babylonjs/Meshes/meshBuilder" {
  50106. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50107. import { Nullable } from "babylonjs/types";
  50108. import { Scene } from "babylonjs/scene";
  50109. import { Mesh } from "babylonjs/Meshes/mesh";
  50110. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50111. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50113. /**
  50114. * Class containing static functions to help procedurally build meshes
  50115. */
  50116. export class MeshBuilder {
  50117. /**
  50118. * Creates a box mesh
  50119. * * The parameter `size` sets the size (float) of each box side (default 1)
  50120. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50121. * * 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)
  50122. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50126. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50127. * @param name defines the name of the mesh
  50128. * @param options defines the options used to create the mesh
  50129. * @param scene defines the hosting scene
  50130. * @returns the box mesh
  50131. */
  50132. static CreateBox(name: string, options: {
  50133. size?: number;
  50134. width?: number;
  50135. height?: number;
  50136. depth?: number;
  50137. faceUV?: Vector4[];
  50138. faceColors?: Color4[];
  50139. sideOrientation?: number;
  50140. frontUVs?: Vector4;
  50141. backUVs?: Vector4;
  50142. updatable?: boolean;
  50143. }, scene?: Nullable<Scene>): Mesh;
  50144. /**
  50145. * Creates a sphere mesh
  50146. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50147. * * 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`)
  50148. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50149. * * 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
  50150. * * 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)
  50151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50154. * @param name defines the name of the mesh
  50155. * @param options defines the options used to create the mesh
  50156. * @param scene defines the hosting scene
  50157. * @returns the sphere mesh
  50158. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50159. */
  50160. static CreateSphere(name: string, options: {
  50161. segments?: number;
  50162. diameter?: number;
  50163. diameterX?: number;
  50164. diameterY?: number;
  50165. diameterZ?: number;
  50166. arc?: number;
  50167. slice?: number;
  50168. sideOrientation?: number;
  50169. frontUVs?: Vector4;
  50170. backUVs?: Vector4;
  50171. updatable?: boolean;
  50172. }, scene: any): Mesh;
  50173. /**
  50174. * Creates a plane polygonal mesh. By default, this is a disc
  50175. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50176. * * 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
  50177. * * 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
  50178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50181. * @param name defines the name of the mesh
  50182. * @param options defines the options used to create the mesh
  50183. * @param scene defines the hosting scene
  50184. * @returns the plane polygonal mesh
  50185. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50186. */
  50187. static CreateDisc(name: string, options: {
  50188. radius?: number;
  50189. tessellation?: number;
  50190. arc?: number;
  50191. updatable?: boolean;
  50192. sideOrientation?: number;
  50193. frontUVs?: Vector4;
  50194. backUVs?: Vector4;
  50195. }, scene?: Nullable<Scene>): Mesh;
  50196. /**
  50197. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50198. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50199. * * 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`)
  50200. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50201. * * 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
  50202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50205. * @param name defines the name of the mesh
  50206. * @param options defines the options used to create the mesh
  50207. * @param scene defines the hosting scene
  50208. * @returns the icosahedron mesh
  50209. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50210. */
  50211. static CreateIcoSphere(name: string, options: {
  50212. radius?: number;
  50213. radiusX?: number;
  50214. radiusY?: number;
  50215. radiusZ?: number;
  50216. flat?: boolean;
  50217. subdivisions?: number;
  50218. sideOrientation?: number;
  50219. frontUVs?: Vector4;
  50220. backUVs?: Vector4;
  50221. updatable?: boolean;
  50222. }, scene: Scene): Mesh;
  50223. /**
  50224. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50225. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50226. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50227. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50228. * * 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
  50229. * * 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
  50230. * * 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
  50231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50234. * * 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
  50235. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50236. * * 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
  50237. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50239. * @param name defines the name of the mesh
  50240. * @param options defines the options used to create the mesh
  50241. * @param scene defines the hosting scene
  50242. * @returns the ribbon mesh
  50243. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50245. */
  50246. static CreateRibbon(name: string, options: {
  50247. pathArray: Vector3[][];
  50248. closeArray?: boolean;
  50249. closePath?: boolean;
  50250. offset?: number;
  50251. updatable?: boolean;
  50252. sideOrientation?: number;
  50253. frontUVs?: Vector4;
  50254. backUVs?: Vector4;
  50255. instance?: Mesh;
  50256. invertUV?: boolean;
  50257. uvs?: Vector2[];
  50258. colors?: Color4[];
  50259. }, scene?: Nullable<Scene>): Mesh;
  50260. /**
  50261. * Creates a cylinder or a cone mesh
  50262. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50263. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50264. * * 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.
  50265. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50266. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50267. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50268. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50269. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50270. * * 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).
  50271. * * 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
  50272. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50273. * * 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
  50274. * * 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.
  50275. * * If `enclose` is false, a ring surface is one element.
  50276. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50277. * * 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
  50278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50281. * @param name defines the name of the mesh
  50282. * @param options defines the options used to create the mesh
  50283. * @param scene defines the hosting scene
  50284. * @returns the cylinder mesh
  50285. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50286. */
  50287. static CreateCylinder(name: string, options: {
  50288. height?: number;
  50289. diameterTop?: number;
  50290. diameterBottom?: number;
  50291. diameter?: number;
  50292. tessellation?: number;
  50293. subdivisions?: number;
  50294. arc?: number;
  50295. faceColors?: Color4[];
  50296. faceUV?: Vector4[];
  50297. updatable?: boolean;
  50298. hasRings?: boolean;
  50299. enclose?: boolean;
  50300. sideOrientation?: number;
  50301. frontUVs?: Vector4;
  50302. backUVs?: Vector4;
  50303. }, scene: any): Mesh;
  50304. /**
  50305. * Creates a torus mesh
  50306. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50307. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50308. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50312. * @param name defines the name of the mesh
  50313. * @param options defines the options used to create the mesh
  50314. * @param scene defines the hosting scene
  50315. * @returns the torus mesh
  50316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50317. */
  50318. static CreateTorus(name: string, options: {
  50319. diameter?: number;
  50320. thickness?: number;
  50321. tessellation?: number;
  50322. updatable?: boolean;
  50323. sideOrientation?: number;
  50324. frontUVs?: Vector4;
  50325. backUVs?: Vector4;
  50326. }, scene: any): Mesh;
  50327. /**
  50328. * Creates a torus knot mesh
  50329. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50330. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50331. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50332. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50336. * @param name defines the name of the mesh
  50337. * @param options defines the options used to create the mesh
  50338. * @param scene defines the hosting scene
  50339. * @returns the torus knot mesh
  50340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50341. */
  50342. static CreateTorusKnot(name: string, options: {
  50343. radius?: number;
  50344. tube?: number;
  50345. radialSegments?: number;
  50346. tubularSegments?: number;
  50347. p?: number;
  50348. q?: number;
  50349. updatable?: boolean;
  50350. sideOrientation?: number;
  50351. frontUVs?: Vector4;
  50352. backUVs?: Vector4;
  50353. }, scene: any): Mesh;
  50354. /**
  50355. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50356. * * 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
  50357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50358. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50359. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50360. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50361. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50362. * * 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
  50363. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50366. * @param name defines the name of the new line system
  50367. * @param options defines the options used to create the line system
  50368. * @param scene defines the hosting scene
  50369. * @returns a new line system mesh
  50370. */
  50371. static CreateLineSystem(name: string, options: {
  50372. lines: Vector3[][];
  50373. updatable?: boolean;
  50374. instance?: Nullable<LinesMesh>;
  50375. colors?: Nullable<Color4[][]>;
  50376. useVertexAlpha?: boolean;
  50377. }, scene: Nullable<Scene>): LinesMesh;
  50378. /**
  50379. * Creates a line mesh
  50380. * 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
  50381. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50382. * * The parameter `points` is an array successive Vector3
  50383. * * 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
  50384. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50385. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50386. * * When updating an instance, remember that only point positions can change, not the number of points
  50387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50389. * @param name defines the name of the new line system
  50390. * @param options defines the options used to create the line system
  50391. * @param scene defines the hosting scene
  50392. * @returns a new line mesh
  50393. */
  50394. static CreateLines(name: string, options: {
  50395. points: Vector3[];
  50396. updatable?: boolean;
  50397. instance?: Nullable<LinesMesh>;
  50398. colors?: Color4[];
  50399. useVertexAlpha?: boolean;
  50400. }, scene?: Nullable<Scene>): LinesMesh;
  50401. /**
  50402. * Creates a dashed line mesh
  50403. * * 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
  50404. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50405. * * The parameter `points` is an array successive Vector3
  50406. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50407. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50408. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50409. * * 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
  50410. * * When updating an instance, remember that only point positions can change, not the number of points
  50411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50412. * @param name defines the name of the mesh
  50413. * @param options defines the options used to create the mesh
  50414. * @param scene defines the hosting scene
  50415. * @returns the dashed line mesh
  50416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50417. */
  50418. static CreateDashedLines(name: string, options: {
  50419. points: Vector3[];
  50420. dashSize?: number;
  50421. gapSize?: number;
  50422. dashNb?: number;
  50423. updatable?: boolean;
  50424. instance?: LinesMesh;
  50425. }, scene?: Nullable<Scene>): LinesMesh;
  50426. /**
  50427. * 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.
  50428. * * 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.
  50429. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50430. * * 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.
  50431. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50432. * * 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
  50433. * * 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
  50434. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50439. * @param name defines the name of the mesh
  50440. * @param options defines the options used to create the mesh
  50441. * @param scene defines the hosting scene
  50442. * @returns the extruded shape mesh
  50443. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50445. */
  50446. static ExtrudeShape(name: string, options: {
  50447. shape: Vector3[];
  50448. path: Vector3[];
  50449. scale?: number;
  50450. rotation?: number;
  50451. cap?: number;
  50452. updatable?: boolean;
  50453. sideOrientation?: number;
  50454. frontUVs?: Vector4;
  50455. backUVs?: Vector4;
  50456. instance?: Mesh;
  50457. invertUV?: boolean;
  50458. }, scene?: Nullable<Scene>): Mesh;
  50459. /**
  50460. * Creates an custom extruded shape mesh.
  50461. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50462. * * 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.
  50463. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50464. * * 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
  50465. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50466. * * 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
  50467. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50468. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50469. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50470. * * 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
  50471. * * 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
  50472. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50475. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50477. * @param name defines the name of the mesh
  50478. * @param options defines the options used to create the mesh
  50479. * @param scene defines the hosting scene
  50480. * @returns the custom extruded shape mesh
  50481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50484. */
  50485. static ExtrudeShapeCustom(name: string, options: {
  50486. shape: Vector3[];
  50487. path: Vector3[];
  50488. scaleFunction?: any;
  50489. rotationFunction?: any;
  50490. ribbonCloseArray?: boolean;
  50491. ribbonClosePath?: boolean;
  50492. cap?: number;
  50493. updatable?: boolean;
  50494. sideOrientation?: number;
  50495. frontUVs?: Vector4;
  50496. backUVs?: Vector4;
  50497. instance?: Mesh;
  50498. invertUV?: boolean;
  50499. }, scene: Scene): Mesh;
  50500. /**
  50501. * Creates lathe mesh.
  50502. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50503. * * 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
  50504. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50505. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50506. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50507. * * 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
  50508. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50509. * * 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
  50510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50514. * @param name defines the name of the mesh
  50515. * @param options defines the options used to create the mesh
  50516. * @param scene defines the hosting scene
  50517. * @returns the lathe mesh
  50518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50519. */
  50520. static CreateLathe(name: string, options: {
  50521. shape: Vector3[];
  50522. radius?: number;
  50523. tessellation?: number;
  50524. clip?: number;
  50525. arc?: number;
  50526. closed?: boolean;
  50527. updatable?: boolean;
  50528. sideOrientation?: number;
  50529. frontUVs?: Vector4;
  50530. backUVs?: Vector4;
  50531. cap?: number;
  50532. invertUV?: boolean;
  50533. }, scene: Scene): Mesh;
  50534. /**
  50535. * Creates a plane mesh
  50536. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50537. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50538. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50542. * @param name defines the name of the mesh
  50543. * @param options defines the options used to create the mesh
  50544. * @param scene defines the hosting scene
  50545. * @returns the plane mesh
  50546. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50547. */
  50548. static CreatePlane(name: string, options: {
  50549. size?: number;
  50550. width?: number;
  50551. height?: number;
  50552. sideOrientation?: number;
  50553. frontUVs?: Vector4;
  50554. backUVs?: Vector4;
  50555. updatable?: boolean;
  50556. sourcePlane?: Plane;
  50557. }, scene: Scene): Mesh;
  50558. /**
  50559. * Creates a ground mesh
  50560. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50561. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50563. * @param name defines the name of the mesh
  50564. * @param options defines the options used to create the mesh
  50565. * @param scene defines the hosting scene
  50566. * @returns the ground mesh
  50567. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50568. */
  50569. static CreateGround(name: string, options: {
  50570. width?: number;
  50571. height?: number;
  50572. subdivisions?: number;
  50573. subdivisionsX?: number;
  50574. subdivisionsY?: number;
  50575. updatable?: boolean;
  50576. }, scene: any): Mesh;
  50577. /**
  50578. * Creates a tiled ground mesh
  50579. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50580. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50581. * * 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
  50582. * * 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
  50583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50584. * @param name defines the name of the mesh
  50585. * @param options defines the options used to create the mesh
  50586. * @param scene defines the hosting scene
  50587. * @returns the tiled ground mesh
  50588. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50589. */
  50590. static CreateTiledGround(name: string, options: {
  50591. xmin: number;
  50592. zmin: number;
  50593. xmax: number;
  50594. zmax: number;
  50595. subdivisions?: {
  50596. w: number;
  50597. h: number;
  50598. };
  50599. precision?: {
  50600. w: number;
  50601. h: number;
  50602. };
  50603. updatable?: boolean;
  50604. }, scene: Scene): Mesh;
  50605. /**
  50606. * Creates a ground mesh from a height map
  50607. * * The parameter `url` sets the URL of the height map image resource.
  50608. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50609. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50610. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50611. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50612. * * 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.
  50613. * * 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).
  50614. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50616. * @param name defines the name of the mesh
  50617. * @param url defines the url to the height map
  50618. * @param options defines the options used to create the mesh
  50619. * @param scene defines the hosting scene
  50620. * @returns the ground mesh
  50621. * @see https://doc.babylonjs.com/babylon101/height_map
  50622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50623. */
  50624. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50625. width?: number;
  50626. height?: number;
  50627. subdivisions?: number;
  50628. minHeight?: number;
  50629. maxHeight?: number;
  50630. colorFilter?: Color3;
  50631. alphaFilter?: number;
  50632. updatable?: boolean;
  50633. onReady?: (mesh: GroundMesh) => void;
  50634. }, scene: Scene): GroundMesh;
  50635. /**
  50636. * Creates a polygon mesh
  50637. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50638. * * 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
  50639. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50642. * * Remember you can only change the shape positions, not their number when updating a polygon
  50643. * @param name defines the name of the mesh
  50644. * @param options defines the options used to create the mesh
  50645. * @param scene defines the hosting scene
  50646. * @param earcutInjection can be used to inject your own earcut reference
  50647. * @returns the polygon mesh
  50648. */
  50649. static CreatePolygon(name: string, options: {
  50650. shape: Vector3[];
  50651. holes?: Vector3[][];
  50652. depth?: number;
  50653. faceUV?: Vector4[];
  50654. faceColors?: Color4[];
  50655. updatable?: boolean;
  50656. sideOrientation?: number;
  50657. frontUVs?: Vector4;
  50658. backUVs?: Vector4;
  50659. }, scene: Scene, earcutInjection?: any): Mesh;
  50660. /**
  50661. * Creates an extruded polygon mesh, with depth in the Y direction.
  50662. * * 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)
  50663. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50664. * @param name defines the name of the mesh
  50665. * @param options defines the options used to create the mesh
  50666. * @param scene defines the hosting scene
  50667. * @param earcutInjection can be used to inject your own earcut reference
  50668. * @returns the polygon mesh
  50669. */
  50670. static ExtrudePolygon(name: string, options: {
  50671. shape: Vector3[];
  50672. holes?: Vector3[][];
  50673. depth?: number;
  50674. faceUV?: Vector4[];
  50675. faceColors?: Color4[];
  50676. updatable?: boolean;
  50677. sideOrientation?: number;
  50678. frontUVs?: Vector4;
  50679. backUVs?: Vector4;
  50680. }, scene: Scene, earcutInjection?: any): Mesh;
  50681. /**
  50682. * Creates a tube mesh.
  50683. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50684. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50685. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50686. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50687. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50688. * * 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)
  50689. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50690. * * 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
  50691. * * 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
  50692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50696. * @param name defines the name of the mesh
  50697. * @param options defines the options used to create the mesh
  50698. * @param scene defines the hosting scene
  50699. * @returns the tube mesh
  50700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50701. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50702. */
  50703. static CreateTube(name: string, options: {
  50704. path: Vector3[];
  50705. radius?: number;
  50706. tessellation?: number;
  50707. radiusFunction?: {
  50708. (i: number, distance: number): number;
  50709. };
  50710. cap?: number;
  50711. arc?: number;
  50712. updatable?: boolean;
  50713. sideOrientation?: number;
  50714. frontUVs?: Vector4;
  50715. backUVs?: Vector4;
  50716. instance?: Mesh;
  50717. invertUV?: boolean;
  50718. }, scene: Scene): Mesh;
  50719. /**
  50720. * Creates a polyhedron mesh
  50721. * * 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
  50722. * * The parameter `size` (positive float, default 1) sets the polygon size
  50723. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50724. * * 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`
  50725. * * 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
  50726. * * 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)`)
  50727. * * 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
  50728. * * 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
  50729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50732. * @param name defines the name of the mesh
  50733. * @param options defines the options used to create the mesh
  50734. * @param scene defines the hosting scene
  50735. * @returns the polyhedron mesh
  50736. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50737. */
  50738. static CreatePolyhedron(name: string, options: {
  50739. type?: number;
  50740. size?: number;
  50741. sizeX?: number;
  50742. sizeY?: number;
  50743. sizeZ?: number;
  50744. custom?: any;
  50745. faceUV?: Vector4[];
  50746. faceColors?: Color4[];
  50747. flat?: boolean;
  50748. updatable?: boolean;
  50749. sideOrientation?: number;
  50750. frontUVs?: Vector4;
  50751. backUVs?: Vector4;
  50752. }, scene: Scene): Mesh;
  50753. /**
  50754. * Creates a decal mesh.
  50755. * 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
  50756. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50757. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50758. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50759. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50760. * @param name defines the name of the mesh
  50761. * @param sourceMesh defines the mesh where the decal must be applied
  50762. * @param options defines the options used to create the mesh
  50763. * @param scene defines the hosting scene
  50764. * @returns the decal mesh
  50765. * @see https://doc.babylonjs.com/how_to/decals
  50766. */
  50767. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50768. position?: Vector3;
  50769. normal?: Vector3;
  50770. size?: Vector3;
  50771. angle?: number;
  50772. }): Mesh;
  50773. }
  50774. }
  50775. declare module "babylonjs/Meshes/meshSimplification" {
  50776. import { Mesh } from "babylonjs/Meshes/mesh";
  50777. /**
  50778. * A simplifier interface for future simplification implementations
  50779. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50780. */
  50781. export interface ISimplifier {
  50782. /**
  50783. * Simplification of a given mesh according to the given settings.
  50784. * Since this requires computation, it is assumed that the function runs async.
  50785. * @param settings The settings of the simplification, including quality and distance
  50786. * @param successCallback A callback that will be called after the mesh was simplified.
  50787. * @param errorCallback in case of an error, this callback will be called. optional.
  50788. */
  50789. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50790. }
  50791. /**
  50792. * Expected simplification settings.
  50793. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50795. */
  50796. export interface ISimplificationSettings {
  50797. /**
  50798. * Gets or sets the expected quality
  50799. */
  50800. quality: number;
  50801. /**
  50802. * Gets or sets the distance when this optimized version should be used
  50803. */
  50804. distance: number;
  50805. /**
  50806. * Gets an already optimized mesh
  50807. */
  50808. optimizeMesh?: boolean;
  50809. }
  50810. /**
  50811. * Class used to specify simplification options
  50812. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50813. */
  50814. export class SimplificationSettings implements ISimplificationSettings {
  50815. /** expected quality */
  50816. quality: number;
  50817. /** distance when this optimized version should be used */
  50818. distance: number;
  50819. /** already optimized mesh */
  50820. optimizeMesh?: boolean | undefined;
  50821. /**
  50822. * Creates a SimplificationSettings
  50823. * @param quality expected quality
  50824. * @param distance distance when this optimized version should be used
  50825. * @param optimizeMesh already optimized mesh
  50826. */
  50827. constructor(
  50828. /** expected quality */
  50829. quality: number,
  50830. /** distance when this optimized version should be used */
  50831. distance: number,
  50832. /** already optimized mesh */
  50833. optimizeMesh?: boolean | undefined);
  50834. }
  50835. /**
  50836. * Interface used to define a simplification task
  50837. */
  50838. export interface ISimplificationTask {
  50839. /**
  50840. * Array of settings
  50841. */
  50842. settings: Array<ISimplificationSettings>;
  50843. /**
  50844. * Simplification type
  50845. */
  50846. simplificationType: SimplificationType;
  50847. /**
  50848. * Mesh to simplify
  50849. */
  50850. mesh: Mesh;
  50851. /**
  50852. * Callback called on success
  50853. */
  50854. successCallback?: () => void;
  50855. /**
  50856. * Defines if parallel processing can be used
  50857. */
  50858. parallelProcessing: boolean;
  50859. }
  50860. /**
  50861. * Queue used to order the simplification tasks
  50862. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50863. */
  50864. export class SimplificationQueue {
  50865. private _simplificationArray;
  50866. /**
  50867. * Gets a boolean indicating that the process is still running
  50868. */
  50869. running: boolean;
  50870. /**
  50871. * Creates a new queue
  50872. */
  50873. constructor();
  50874. /**
  50875. * Adds a new simplification task
  50876. * @param task defines a task to add
  50877. */
  50878. addTask(task: ISimplificationTask): void;
  50879. /**
  50880. * Execute next task
  50881. */
  50882. executeNext(): void;
  50883. /**
  50884. * Execute a simplification task
  50885. * @param task defines the task to run
  50886. */
  50887. runSimplification(task: ISimplificationTask): void;
  50888. private getSimplifier;
  50889. }
  50890. /**
  50891. * The implemented types of simplification
  50892. * At the moment only Quadratic Error Decimation is implemented
  50893. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50894. */
  50895. export enum SimplificationType {
  50896. /** Quadratic error decimation */
  50897. QUADRATIC = 0
  50898. }
  50899. }
  50900. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50901. import { Scene } from "babylonjs/scene";
  50902. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50903. import { ISceneComponent } from "babylonjs/sceneComponent";
  50904. module "babylonjs/scene" {
  50905. interface Scene {
  50906. /** @hidden (Backing field) */
  50907. _simplificationQueue: SimplificationQueue;
  50908. /**
  50909. * Gets or sets the simplification queue attached to the scene
  50910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50911. */
  50912. simplificationQueue: SimplificationQueue;
  50913. }
  50914. }
  50915. module "babylonjs/Meshes/mesh" {
  50916. interface Mesh {
  50917. /**
  50918. * Simplify the mesh according to the given array of settings.
  50919. * Function will return immediately and will simplify async
  50920. * @param settings a collection of simplification settings
  50921. * @param parallelProcessing should all levels calculate parallel or one after the other
  50922. * @param simplificationType the type of simplification to run
  50923. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50924. * @returns the current mesh
  50925. */
  50926. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50927. }
  50928. }
  50929. /**
  50930. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50931. * created in a scene
  50932. */
  50933. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50934. /**
  50935. * The component name helpfull to identify the component in the list of scene components.
  50936. */
  50937. readonly name: string;
  50938. /**
  50939. * The scene the component belongs to.
  50940. */
  50941. scene: Scene;
  50942. /**
  50943. * Creates a new instance of the component for the given scene
  50944. * @param scene Defines the scene to register the component in
  50945. */
  50946. constructor(scene: Scene);
  50947. /**
  50948. * Registers the component in a given scene
  50949. */
  50950. register(): void;
  50951. /**
  50952. * Rebuilds the elements related to this component in case of
  50953. * context lost for instance.
  50954. */
  50955. rebuild(): void;
  50956. /**
  50957. * Disposes the component and the associated ressources
  50958. */
  50959. dispose(): void;
  50960. private _beforeCameraUpdate;
  50961. }
  50962. }
  50963. declare module "babylonjs/Meshes/Builders/index" {
  50964. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50965. export * from "babylonjs/Meshes/Builders/discBuilder";
  50966. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50967. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50968. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50969. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50970. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50971. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50972. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50973. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50974. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50975. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50976. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50977. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50978. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50979. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50980. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50981. }
  50982. declare module "babylonjs/Meshes/index" {
  50983. export * from "babylonjs/Meshes/abstractMesh";
  50984. export * from "babylonjs/Meshes/buffer";
  50985. export * from "babylonjs/Meshes/Compression/index";
  50986. export * from "babylonjs/Meshes/csg";
  50987. export * from "babylonjs/Meshes/geometry";
  50988. export * from "babylonjs/Meshes/groundMesh";
  50989. export * from "babylonjs/Meshes/trailMesh";
  50990. export * from "babylonjs/Meshes/instancedMesh";
  50991. export * from "babylonjs/Meshes/linesMesh";
  50992. export * from "babylonjs/Meshes/mesh";
  50993. export * from "babylonjs/Meshes/mesh.vertexData";
  50994. export * from "babylonjs/Meshes/meshBuilder";
  50995. export * from "babylonjs/Meshes/meshSimplification";
  50996. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50997. export * from "babylonjs/Meshes/polygonMesh";
  50998. export * from "babylonjs/Meshes/subMesh";
  50999. export * from "babylonjs/Meshes/transformNode";
  51000. export * from "babylonjs/Meshes/Builders/index";
  51001. }
  51002. declare module "babylonjs/Morph/index" {
  51003. export * from "babylonjs/Morph/morphTarget";
  51004. export * from "babylonjs/Morph/morphTargetManager";
  51005. }
  51006. declare module "babylonjs/Offline/database" {
  51007. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51008. /**
  51009. * Class used to enable access to IndexedDB
  51010. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51011. */
  51012. export class Database implements IOfflineProvider {
  51013. private _callbackManifestChecked;
  51014. private _currentSceneUrl;
  51015. private _db;
  51016. private _enableSceneOffline;
  51017. private _enableTexturesOffline;
  51018. private _manifestVersionFound;
  51019. private _mustUpdateRessources;
  51020. private _hasReachedQuota;
  51021. private _isSupported;
  51022. private _idbFactory;
  51023. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51024. private static IsUASupportingBlobStorage;
  51025. /**
  51026. * Gets a boolean indicating if Database storate is enabled (off by default)
  51027. */
  51028. static IDBStorageEnabled: boolean;
  51029. /**
  51030. * Gets a boolean indicating if scene must be saved in the database
  51031. */
  51032. readonly enableSceneOffline: boolean;
  51033. /**
  51034. * Gets a boolean indicating if textures must be saved in the database
  51035. */
  51036. readonly enableTexturesOffline: boolean;
  51037. /**
  51038. * Creates a new Database
  51039. * @param urlToScene defines the url to load the scene
  51040. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51041. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51042. */
  51043. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51044. private static _ParseURL;
  51045. private static _ReturnFullUrlLocation;
  51046. private _checkManifestFile;
  51047. /**
  51048. * Open the database and make it available
  51049. * @param successCallback defines the callback to call on success
  51050. * @param errorCallback defines the callback to call on error
  51051. */
  51052. open(successCallback: () => void, errorCallback: () => void): void;
  51053. /**
  51054. * Loads an image from the database
  51055. * @param url defines the url to load from
  51056. * @param image defines the target DOM image
  51057. */
  51058. loadImage(url: string, image: HTMLImageElement): void;
  51059. private _loadImageFromDBAsync;
  51060. private _saveImageIntoDBAsync;
  51061. private _checkVersionFromDB;
  51062. private _loadVersionFromDBAsync;
  51063. private _saveVersionIntoDBAsync;
  51064. /**
  51065. * Loads a file from database
  51066. * @param url defines the URL to load from
  51067. * @param sceneLoaded defines a callback to call on success
  51068. * @param progressCallBack defines a callback to call when progress changed
  51069. * @param errorCallback defines a callback to call on error
  51070. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51071. */
  51072. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51073. private _loadFileAsync;
  51074. private _saveFileAsync;
  51075. /**
  51076. * Validates if xhr data is correct
  51077. * @param xhr defines the request to validate
  51078. * @param dataType defines the expected data type
  51079. * @returns true if data is correct
  51080. */
  51081. private static _ValidateXHRData;
  51082. }
  51083. }
  51084. declare module "babylonjs/Offline/index" {
  51085. export * from "babylonjs/Offline/database";
  51086. export * from "babylonjs/Offline/IOfflineProvider";
  51087. }
  51088. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51089. /** @hidden */
  51090. export var gpuUpdateParticlesPixelShader: {
  51091. name: string;
  51092. shader: string;
  51093. };
  51094. }
  51095. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51096. /** @hidden */
  51097. export var gpuUpdateParticlesVertexShader: {
  51098. name: string;
  51099. shader: string;
  51100. };
  51101. }
  51102. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51103. /** @hidden */
  51104. export var clipPlaneFragmentDeclaration2: {
  51105. name: string;
  51106. shader: string;
  51107. };
  51108. }
  51109. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51110. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51111. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51113. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51114. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51115. /** @hidden */
  51116. export var gpuRenderParticlesPixelShader: {
  51117. name: string;
  51118. shader: string;
  51119. };
  51120. }
  51121. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51122. /** @hidden */
  51123. export var clipPlaneVertexDeclaration2: {
  51124. name: string;
  51125. shader: string;
  51126. };
  51127. }
  51128. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51129. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51130. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51131. /** @hidden */
  51132. export var gpuRenderParticlesVertexShader: {
  51133. name: string;
  51134. shader: string;
  51135. };
  51136. }
  51137. declare module "babylonjs/Particles/gpuParticleSystem" {
  51138. import { Nullable } from "babylonjs/types";
  51139. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51140. import { Observable } from "babylonjs/Misc/observable";
  51141. import { Color4, Color3 } from "babylonjs/Maths/math";
  51142. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51143. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51144. import { Scene, IDisposable } from "babylonjs/scene";
  51145. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51146. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51147. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51148. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51149. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51150. /**
  51151. * This represents a GPU particle system in Babylon
  51152. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51153. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51154. */
  51155. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51156. /**
  51157. * The layer mask we are rendering the particles through.
  51158. */
  51159. layerMask: number;
  51160. private _capacity;
  51161. private _activeCount;
  51162. private _currentActiveCount;
  51163. private _accumulatedCount;
  51164. private _renderEffect;
  51165. private _updateEffect;
  51166. private _buffer0;
  51167. private _buffer1;
  51168. private _spriteBuffer;
  51169. private _updateVAO;
  51170. private _renderVAO;
  51171. private _targetIndex;
  51172. private _sourceBuffer;
  51173. private _targetBuffer;
  51174. private _engine;
  51175. private _currentRenderId;
  51176. private _started;
  51177. private _stopped;
  51178. private _timeDelta;
  51179. private _randomTexture;
  51180. private _randomTexture2;
  51181. private _attributesStrideSize;
  51182. private _updateEffectOptions;
  51183. private _randomTextureSize;
  51184. private _actualFrame;
  51185. private readonly _rawTextureWidth;
  51186. /**
  51187. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51188. */
  51189. static readonly IsSupported: boolean;
  51190. /**
  51191. * An event triggered when the system is disposed.
  51192. */
  51193. onDisposeObservable: Observable<GPUParticleSystem>;
  51194. /**
  51195. * Gets the maximum number of particles active at the same time.
  51196. * @returns The max number of active particles.
  51197. */
  51198. getCapacity(): number;
  51199. /**
  51200. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51201. * to override the particles.
  51202. */
  51203. forceDepthWrite: boolean;
  51204. /**
  51205. * Gets or set the number of active particles
  51206. */
  51207. activeParticleCount: number;
  51208. private _preWarmDone;
  51209. /**
  51210. * Is this system ready to be used/rendered
  51211. * @return true if the system is ready
  51212. */
  51213. isReady(): boolean;
  51214. /**
  51215. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51216. * @returns True if it has been started, otherwise false.
  51217. */
  51218. isStarted(): boolean;
  51219. /**
  51220. * Starts the particle system and begins to emit
  51221. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51222. */
  51223. start(delay?: number): void;
  51224. /**
  51225. * Stops the particle system.
  51226. */
  51227. stop(): void;
  51228. /**
  51229. * Remove all active particles
  51230. */
  51231. reset(): void;
  51232. /**
  51233. * Returns the string "GPUParticleSystem"
  51234. * @returns a string containing the class name
  51235. */
  51236. getClassName(): string;
  51237. private _colorGradientsTexture;
  51238. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51239. /**
  51240. * Adds a new color gradient
  51241. * @param gradient defines the gradient to use (between 0 and 1)
  51242. * @param color1 defines the color to affect to the specified gradient
  51243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51244. * @returns the current particle system
  51245. */
  51246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51247. /**
  51248. * Remove a specific color gradient
  51249. * @param gradient defines the gradient to remove
  51250. * @returns the current particle system
  51251. */
  51252. removeColorGradient(gradient: number): GPUParticleSystem;
  51253. private _angularSpeedGradientsTexture;
  51254. private _sizeGradientsTexture;
  51255. private _velocityGradientsTexture;
  51256. private _limitVelocityGradientsTexture;
  51257. private _dragGradientsTexture;
  51258. private _addFactorGradient;
  51259. /**
  51260. * Adds a new size gradient
  51261. * @param gradient defines the gradient to use (between 0 and 1)
  51262. * @param factor defines the size factor to affect to the specified gradient
  51263. * @returns the current particle system
  51264. */
  51265. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51266. /**
  51267. * Remove a specific size gradient
  51268. * @param gradient defines the gradient to remove
  51269. * @returns the current particle system
  51270. */
  51271. removeSizeGradient(gradient: number): GPUParticleSystem;
  51272. /**
  51273. * Adds a new angular speed gradient
  51274. * @param gradient defines the gradient to use (between 0 and 1)
  51275. * @param factor defines the angular speed to affect to the specified gradient
  51276. * @returns the current particle system
  51277. */
  51278. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51279. /**
  51280. * Remove a specific angular speed gradient
  51281. * @param gradient defines the gradient to remove
  51282. * @returns the current particle system
  51283. */
  51284. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51285. /**
  51286. * Adds a new velocity gradient
  51287. * @param gradient defines the gradient to use (between 0 and 1)
  51288. * @param factor defines the velocity to affect to the specified gradient
  51289. * @returns the current particle system
  51290. */
  51291. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51292. /**
  51293. * Remove a specific velocity gradient
  51294. * @param gradient defines the gradient to remove
  51295. * @returns the current particle system
  51296. */
  51297. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51298. /**
  51299. * Adds a new limit velocity gradient
  51300. * @param gradient defines the gradient to use (between 0 and 1)
  51301. * @param factor defines the limit velocity value to affect to the specified gradient
  51302. * @returns the current particle system
  51303. */
  51304. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51305. /**
  51306. * Remove a specific limit velocity gradient
  51307. * @param gradient defines the gradient to remove
  51308. * @returns the current particle system
  51309. */
  51310. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51311. /**
  51312. * Adds a new drag gradient
  51313. * @param gradient defines the gradient to use (between 0 and 1)
  51314. * @param factor defines the drag value to affect to the specified gradient
  51315. * @returns the current particle system
  51316. */
  51317. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51318. /**
  51319. * Remove a specific drag gradient
  51320. * @param gradient defines the gradient to remove
  51321. * @returns the current particle system
  51322. */
  51323. removeDragGradient(gradient: number): GPUParticleSystem;
  51324. /**
  51325. * Not supported by GPUParticleSystem
  51326. * @param gradient defines the gradient to use (between 0 and 1)
  51327. * @param factor defines the emit rate value to affect to the specified gradient
  51328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51329. * @returns the current particle system
  51330. */
  51331. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51332. /**
  51333. * Not supported by GPUParticleSystem
  51334. * @param gradient defines the gradient to remove
  51335. * @returns the current particle system
  51336. */
  51337. removeEmitRateGradient(gradient: number): IParticleSystem;
  51338. /**
  51339. * Not supported by GPUParticleSystem
  51340. * @param gradient defines the gradient to use (between 0 and 1)
  51341. * @param factor defines the start size value to affect to the specified gradient
  51342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51343. * @returns the current particle system
  51344. */
  51345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51346. /**
  51347. * Not supported by GPUParticleSystem
  51348. * @param gradient defines the gradient to remove
  51349. * @returns the current particle system
  51350. */
  51351. removeStartSizeGradient(gradient: number): IParticleSystem;
  51352. /**
  51353. * Not supported by GPUParticleSystem
  51354. * @param gradient defines the gradient to use (between 0 and 1)
  51355. * @param min defines the color remap minimal range
  51356. * @param max defines the color remap maximal range
  51357. * @returns the current particle system
  51358. */
  51359. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51360. /**
  51361. * Not supported by GPUParticleSystem
  51362. * @param gradient defines the gradient to remove
  51363. * @returns the current particle system
  51364. */
  51365. removeColorRemapGradient(): IParticleSystem;
  51366. /**
  51367. * Not supported by GPUParticleSystem
  51368. * @param gradient defines the gradient to use (between 0 and 1)
  51369. * @param min defines the alpha remap minimal range
  51370. * @param max defines the alpha remap maximal range
  51371. * @returns the current particle system
  51372. */
  51373. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51374. /**
  51375. * Not supported by GPUParticleSystem
  51376. * @param gradient defines the gradient to remove
  51377. * @returns the current particle system
  51378. */
  51379. removeAlphaRemapGradient(): IParticleSystem;
  51380. /**
  51381. * Not supported by GPUParticleSystem
  51382. * @param gradient defines the gradient to use (between 0 and 1)
  51383. * @param color defines the color to affect to the specified gradient
  51384. * @returns the current particle system
  51385. */
  51386. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51387. /**
  51388. * Not supported by GPUParticleSystem
  51389. * @param gradient defines the gradient to remove
  51390. * @returns the current particle system
  51391. */
  51392. removeRampGradient(): IParticleSystem;
  51393. /**
  51394. * Not supported by GPUParticleSystem
  51395. * @returns the list of ramp gradients
  51396. */
  51397. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51398. /**
  51399. * Not supported by GPUParticleSystem
  51400. * Gets or sets a boolean indicating that ramp gradients must be used
  51401. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51402. */
  51403. useRampGradients: boolean;
  51404. /**
  51405. * Not supported by GPUParticleSystem
  51406. * @param gradient defines the gradient to use (between 0 and 1)
  51407. * @param factor defines the life time factor to affect to the specified gradient
  51408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51409. * @returns the current particle system
  51410. */
  51411. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51412. /**
  51413. * Not supported by GPUParticleSystem
  51414. * @param gradient defines the gradient to remove
  51415. * @returns the current particle system
  51416. */
  51417. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51418. /**
  51419. * Instantiates a GPU particle system.
  51420. * 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.
  51421. * @param name The name of the particle system
  51422. * @param options The options used to create the system
  51423. * @param scene The scene the particle system belongs to
  51424. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51425. */
  51426. constructor(name: string, options: Partial<{
  51427. capacity: number;
  51428. randomTextureSize: number;
  51429. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51430. protected _reset(): void;
  51431. private _createUpdateVAO;
  51432. private _createRenderVAO;
  51433. private _initialize;
  51434. /** @hidden */
  51435. _recreateUpdateEffect(): void;
  51436. /** @hidden */
  51437. _recreateRenderEffect(): void;
  51438. /**
  51439. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51440. * @param preWarm defines if we are in the pre-warmimg phase
  51441. */
  51442. animate(preWarm?: boolean): void;
  51443. private _createFactorGradientTexture;
  51444. private _createSizeGradientTexture;
  51445. private _createAngularSpeedGradientTexture;
  51446. private _createVelocityGradientTexture;
  51447. private _createLimitVelocityGradientTexture;
  51448. private _createDragGradientTexture;
  51449. private _createColorGradientTexture;
  51450. /**
  51451. * Renders the particle system in its current state
  51452. * @param preWarm defines if the system should only update the particles but not render them
  51453. * @returns the current number of particles
  51454. */
  51455. render(preWarm?: boolean): number;
  51456. /**
  51457. * Rebuilds the particle system
  51458. */
  51459. rebuild(): void;
  51460. private _releaseBuffers;
  51461. private _releaseVAOs;
  51462. /**
  51463. * Disposes the particle system and free the associated resources
  51464. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51465. */
  51466. dispose(disposeTexture?: boolean): void;
  51467. /**
  51468. * Clones the particle system.
  51469. * @param name The name of the cloned object
  51470. * @param newEmitter The new emitter to use
  51471. * @returns the cloned particle system
  51472. */
  51473. clone(name: string, newEmitter: any): GPUParticleSystem;
  51474. /**
  51475. * Serializes the particle system to a JSON object.
  51476. * @returns the JSON object
  51477. */
  51478. serialize(): any;
  51479. /**
  51480. * Parses a JSON object to create a GPU particle system.
  51481. * @param parsedParticleSystem The JSON object to parse
  51482. * @param scene The scene to create the particle system in
  51483. * @param rootUrl The root url to use to load external dependencies like texture
  51484. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51485. * @returns the parsed GPU particle system
  51486. */
  51487. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51488. }
  51489. }
  51490. declare module "babylonjs/Particles/particleSystemSet" {
  51491. import { Nullable } from "babylonjs/types";
  51492. import { Color3 } from "babylonjs/Maths/math";
  51493. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51495. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51496. import { Scene, IDisposable } from "babylonjs/scene";
  51497. /**
  51498. * Represents a set of particle systems working together to create a specific effect
  51499. */
  51500. export class ParticleSystemSet implements IDisposable {
  51501. private _emitterCreationOptions;
  51502. private _emitterNode;
  51503. /**
  51504. * Gets the particle system list
  51505. */
  51506. systems: IParticleSystem[];
  51507. /**
  51508. * Gets the emitter node used with this set
  51509. */
  51510. readonly emitterNode: Nullable<TransformNode>;
  51511. /**
  51512. * Creates a new emitter mesh as a sphere
  51513. * @param options defines the options used to create the sphere
  51514. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51515. * @param scene defines the hosting scene
  51516. */
  51517. setEmitterAsSphere(options: {
  51518. diameter: number;
  51519. segments: number;
  51520. color: Color3;
  51521. }, renderingGroupId: number, scene: Scene): void;
  51522. /**
  51523. * Starts all particle systems of the set
  51524. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51525. */
  51526. start(emitter?: AbstractMesh): void;
  51527. /**
  51528. * Release all associated resources
  51529. */
  51530. dispose(): void;
  51531. /**
  51532. * Serialize the set into a JSON compatible object
  51533. * @returns a JSON compatible representation of the set
  51534. */
  51535. serialize(): any;
  51536. /**
  51537. * Parse a new ParticleSystemSet from a serialized source
  51538. * @param data defines a JSON compatible representation of the set
  51539. * @param scene defines the hosting scene
  51540. * @param gpu defines if we want GPU particles or CPU particles
  51541. * @returns a new ParticleSystemSet
  51542. */
  51543. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51544. }
  51545. }
  51546. declare module "babylonjs/Particles/particleHelper" {
  51547. import { Nullable } from "babylonjs/types";
  51548. import { Scene } from "babylonjs/scene";
  51549. import { Vector3 } from "babylonjs/Maths/math";
  51550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51551. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51552. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51553. /**
  51554. * This class is made for on one-liner static method to help creating particle system set.
  51555. */
  51556. export class ParticleHelper {
  51557. /**
  51558. * Gets or sets base Assets URL
  51559. */
  51560. static BaseAssetsUrl: string;
  51561. /**
  51562. * Create a default particle system that you can tweak
  51563. * @param emitter defines the emitter to use
  51564. * @param capacity defines the system capacity (default is 500 particles)
  51565. * @param scene defines the hosting scene
  51566. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51567. * @returns the new Particle system
  51568. */
  51569. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51570. /**
  51571. * This is the main static method (one-liner) of this helper to create different particle systems
  51572. * @param type This string represents the type to the particle system to create
  51573. * @param scene The scene where the particle system should live
  51574. * @param gpu If the system will use gpu
  51575. * @returns the ParticleSystemSet created
  51576. */
  51577. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51578. /**
  51579. * Static function used to export a particle system to a ParticleSystemSet variable.
  51580. * Please note that the emitter shape is not exported
  51581. * @param systems defines the particle systems to export
  51582. * @returns the created particle system set
  51583. */
  51584. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51585. }
  51586. }
  51587. declare module "babylonjs/Particles/particleSystemComponent" {
  51588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51589. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51590. import "babylonjs/Shaders/particles.vertex";
  51591. module "babylonjs/Engines/engine" {
  51592. interface Engine {
  51593. /**
  51594. * Create an effect to use with particle systems.
  51595. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51596. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51597. * @param uniformsNames defines a list of attribute names
  51598. * @param samplers defines an array of string used to represent textures
  51599. * @param defines defines the string containing the defines to use to compile the shaders
  51600. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51601. * @param onCompiled defines a function to call when the effect creation is successful
  51602. * @param onError defines a function to call when the effect creation has failed
  51603. * @returns the new Effect
  51604. */
  51605. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51606. }
  51607. }
  51608. module "babylonjs/Meshes/mesh" {
  51609. interface Mesh {
  51610. /**
  51611. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51612. * @returns an array of IParticleSystem
  51613. */
  51614. getEmittedParticleSystems(): IParticleSystem[];
  51615. /**
  51616. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51617. * @returns an array of IParticleSystem
  51618. */
  51619. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51620. }
  51621. }
  51622. /**
  51623. * @hidden
  51624. */
  51625. export var _IDoNeedToBeInTheBuild: number;
  51626. }
  51627. declare module "babylonjs/Particles/index" {
  51628. export * from "babylonjs/Particles/baseParticleSystem";
  51629. export * from "babylonjs/Particles/EmitterTypes/index";
  51630. export * from "babylonjs/Particles/gpuParticleSystem";
  51631. export * from "babylonjs/Particles/IParticleSystem";
  51632. export * from "babylonjs/Particles/particle";
  51633. export * from "babylonjs/Particles/particleHelper";
  51634. export * from "babylonjs/Particles/particleSystem";
  51635. export * from "babylonjs/Particles/particleSystemComponent";
  51636. export * from "babylonjs/Particles/particleSystemSet";
  51637. export * from "babylonjs/Particles/solidParticle";
  51638. export * from "babylonjs/Particles/solidParticleSystem";
  51639. export * from "babylonjs/Particles/subEmitter";
  51640. }
  51641. declare module "babylonjs/Physics/physicsEngineComponent" {
  51642. import { Nullable } from "babylonjs/types";
  51643. import { Observable, Observer } from "babylonjs/Misc/observable";
  51644. import { Vector3 } from "babylonjs/Maths/math";
  51645. import { Mesh } from "babylonjs/Meshes/mesh";
  51646. import { ISceneComponent } from "babylonjs/sceneComponent";
  51647. import { Scene } from "babylonjs/scene";
  51648. import { Node } from "babylonjs/node";
  51649. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51650. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51651. module "babylonjs/scene" {
  51652. interface Scene {
  51653. /** @hidden (Backing field) */
  51654. _physicsEngine: Nullable<IPhysicsEngine>;
  51655. /**
  51656. * Gets the current physics engine
  51657. * @returns a IPhysicsEngine or null if none attached
  51658. */
  51659. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51660. /**
  51661. * Enables physics to the current scene
  51662. * @param gravity defines the scene's gravity for the physics engine
  51663. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51664. * @return a boolean indicating if the physics engine was initialized
  51665. */
  51666. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51667. /**
  51668. * Disables and disposes the physics engine associated with the scene
  51669. */
  51670. disablePhysicsEngine(): void;
  51671. /**
  51672. * Gets a boolean indicating if there is an active physics engine
  51673. * @returns a boolean indicating if there is an active physics engine
  51674. */
  51675. isPhysicsEnabled(): boolean;
  51676. /**
  51677. * Deletes a physics compound impostor
  51678. * @param compound defines the compound to delete
  51679. */
  51680. deleteCompoundImpostor(compound: any): void;
  51681. /**
  51682. * An event triggered when physic simulation is about to be run
  51683. */
  51684. onBeforePhysicsObservable: Observable<Scene>;
  51685. /**
  51686. * An event triggered when physic simulation has been done
  51687. */
  51688. onAfterPhysicsObservable: Observable<Scene>;
  51689. }
  51690. }
  51691. module "babylonjs/Meshes/abstractMesh" {
  51692. interface AbstractMesh {
  51693. /** @hidden */
  51694. _physicsImpostor: Nullable<PhysicsImpostor>;
  51695. /**
  51696. * Gets or sets impostor used for physic simulation
  51697. * @see http://doc.babylonjs.com/features/physics_engine
  51698. */
  51699. physicsImpostor: Nullable<PhysicsImpostor>;
  51700. /**
  51701. * Gets the current physics impostor
  51702. * @see http://doc.babylonjs.com/features/physics_engine
  51703. * @returns a physics impostor or null
  51704. */
  51705. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51706. /** Apply a physic impulse to the mesh
  51707. * @param force defines the force to apply
  51708. * @param contactPoint defines where to apply the force
  51709. * @returns the current mesh
  51710. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51711. */
  51712. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51713. /**
  51714. * Creates a physic joint between two meshes
  51715. * @param otherMesh defines the other mesh to use
  51716. * @param pivot1 defines the pivot to use on this mesh
  51717. * @param pivot2 defines the pivot to use on the other mesh
  51718. * @param options defines additional options (can be plugin dependent)
  51719. * @returns the current mesh
  51720. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51721. */
  51722. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51723. /** @hidden */
  51724. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51725. }
  51726. }
  51727. /**
  51728. * Defines the physics engine scene component responsible to manage a physics engine
  51729. */
  51730. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51731. /**
  51732. * The component name helpful to identify the component in the list of scene components.
  51733. */
  51734. readonly name: string;
  51735. /**
  51736. * The scene the component belongs to.
  51737. */
  51738. scene: Scene;
  51739. /**
  51740. * Creates a new instance of the component for the given scene
  51741. * @param scene Defines the scene to register the component in
  51742. */
  51743. constructor(scene: Scene);
  51744. /**
  51745. * Registers the component in a given scene
  51746. */
  51747. register(): void;
  51748. /**
  51749. * Rebuilds the elements related to this component in case of
  51750. * context lost for instance.
  51751. */
  51752. rebuild(): void;
  51753. /**
  51754. * Disposes the component and the associated ressources
  51755. */
  51756. dispose(): void;
  51757. }
  51758. }
  51759. declare module "babylonjs/Physics/physicsHelper" {
  51760. import { Nullable } from "babylonjs/types";
  51761. import { Vector3 } from "babylonjs/Maths/math";
  51762. import { Mesh } from "babylonjs/Meshes/mesh";
  51763. import { Ray } from "babylonjs/Culling/ray";
  51764. import { Scene } from "babylonjs/scene";
  51765. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51766. /**
  51767. * A helper for physics simulations
  51768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51769. */
  51770. export class PhysicsHelper {
  51771. private _scene;
  51772. private _physicsEngine;
  51773. /**
  51774. * Initializes the Physics helper
  51775. * @param scene Babylon.js scene
  51776. */
  51777. constructor(scene: Scene);
  51778. /**
  51779. * Applies a radial explosion impulse
  51780. * @param origin the origin of the explosion
  51781. * @param radius the explosion radius
  51782. * @param strength the explosion strength
  51783. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51784. * @returns A physics radial explosion event, or null
  51785. */
  51786. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51787. /**
  51788. * Applies a radial explosion force
  51789. * @param origin the origin of the explosion
  51790. * @param radius the explosion radius
  51791. * @param strength the explosion strength
  51792. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51793. * @returns A physics radial explosion event, or null
  51794. */
  51795. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51796. /**
  51797. * Creates a gravitational field
  51798. * @param origin the origin of the explosion
  51799. * @param radius the explosion radius
  51800. * @param strength the explosion strength
  51801. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51802. * @returns A physics gravitational field event, or null
  51803. */
  51804. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51805. /**
  51806. * Creates a physics updraft event
  51807. * @param origin the origin of the updraft
  51808. * @param radius the radius of the updraft
  51809. * @param strength the strength of the updraft
  51810. * @param height the height of the updraft
  51811. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51812. * @returns A physics updraft event, or null
  51813. */
  51814. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51815. /**
  51816. * Creates a physics vortex event
  51817. * @param origin the of the vortex
  51818. * @param radius the radius of the vortex
  51819. * @param strength the strength of the vortex
  51820. * @param height the height of the vortex
  51821. * @returns a Physics vortex event, or null
  51822. * A physics vortex event or null
  51823. */
  51824. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51825. }
  51826. /**
  51827. * Represents a physics radial explosion event
  51828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51829. */
  51830. export class PhysicsRadialExplosionEvent {
  51831. private _scene;
  51832. private _sphere;
  51833. private _sphereOptions;
  51834. private _rays;
  51835. private _dataFetched;
  51836. /**
  51837. * Initializes a radial explosioin event
  51838. * @param scene BabylonJS scene
  51839. */
  51840. constructor(scene: Scene);
  51841. /**
  51842. * Returns the data related to the radial explosion event (sphere & rays).
  51843. * @returns The radial explosion event data
  51844. */
  51845. getData(): PhysicsRadialExplosionEventData;
  51846. /**
  51847. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51848. * @param impostor A physics imposter
  51849. * @param origin the origin of the explosion
  51850. * @param radius the explosion radius
  51851. * @param strength the explosion strength
  51852. * @param falloff possible options: Constant & Linear
  51853. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51854. */
  51855. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51856. /**
  51857. * Disposes the sphere.
  51858. * @param force Specifies if the sphere should be disposed by force
  51859. */
  51860. dispose(force?: boolean): void;
  51861. /*** Helpers ***/
  51862. private _prepareSphere;
  51863. private _intersectsWithSphere;
  51864. }
  51865. /**
  51866. * Represents a gravitational field event
  51867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51868. */
  51869. export class PhysicsGravitationalFieldEvent {
  51870. private _physicsHelper;
  51871. private _scene;
  51872. private _origin;
  51873. private _radius;
  51874. private _strength;
  51875. private _falloff;
  51876. private _tickCallback;
  51877. private _sphere;
  51878. private _dataFetched;
  51879. /**
  51880. * Initializes the physics gravitational field event
  51881. * @param physicsHelper A physics helper
  51882. * @param scene BabylonJS scene
  51883. * @param origin The origin position of the gravitational field event
  51884. * @param radius The radius of the gravitational field event
  51885. * @param strength The strength of the gravitational field event
  51886. * @param falloff The falloff for the gravitational field event
  51887. */
  51888. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51889. /**
  51890. * Returns the data related to the gravitational field event (sphere).
  51891. * @returns A gravitational field event
  51892. */
  51893. getData(): PhysicsGravitationalFieldEventData;
  51894. /**
  51895. * Enables the gravitational field.
  51896. */
  51897. enable(): void;
  51898. /**
  51899. * Disables the gravitational field.
  51900. */
  51901. disable(): void;
  51902. /**
  51903. * Disposes the sphere.
  51904. * @param force The force to dispose from the gravitational field event
  51905. */
  51906. dispose(force?: boolean): void;
  51907. private _tick;
  51908. }
  51909. /**
  51910. * Represents a physics updraft event
  51911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51912. */
  51913. export class PhysicsUpdraftEvent {
  51914. private _scene;
  51915. private _origin;
  51916. private _radius;
  51917. private _strength;
  51918. private _height;
  51919. private _updraftMode;
  51920. private _physicsEngine;
  51921. private _originTop;
  51922. private _originDirection;
  51923. private _tickCallback;
  51924. private _cylinder;
  51925. private _cylinderPosition;
  51926. private _dataFetched;
  51927. /**
  51928. * Initializes the physics updraft event
  51929. * @param _scene BabylonJS scene
  51930. * @param _origin The origin position of the updraft
  51931. * @param _radius The radius of the updraft
  51932. * @param _strength The strength of the updraft
  51933. * @param _height The height of the updraft
  51934. * @param _updraftMode The mode of the updraft
  51935. */
  51936. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51937. /**
  51938. * Returns the data related to the updraft event (cylinder).
  51939. * @returns A physics updraft event
  51940. */
  51941. getData(): PhysicsUpdraftEventData;
  51942. /**
  51943. * Enables the updraft.
  51944. */
  51945. enable(): void;
  51946. /**
  51947. * Disables the cortex.
  51948. */
  51949. disable(): void;
  51950. /**
  51951. * Disposes the sphere.
  51952. * @param force Specifies if the updraft should be disposed by force
  51953. */
  51954. dispose(force?: boolean): void;
  51955. private getImpostorForceAndContactPoint;
  51956. private _tick;
  51957. /*** Helpers ***/
  51958. private _prepareCylinder;
  51959. private _intersectsWithCylinder;
  51960. }
  51961. /**
  51962. * Represents a physics vortex event
  51963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51964. */
  51965. export class PhysicsVortexEvent {
  51966. private _scene;
  51967. private _origin;
  51968. private _radius;
  51969. private _strength;
  51970. private _height;
  51971. private _physicsEngine;
  51972. private _originTop;
  51973. private _centripetalForceThreshold;
  51974. private _updraftMultiplier;
  51975. private _tickCallback;
  51976. private _cylinder;
  51977. private _cylinderPosition;
  51978. private _dataFetched;
  51979. /**
  51980. * Initializes the physics vortex event
  51981. * @param _scene The BabylonJS scene
  51982. * @param _origin The origin position of the vortex
  51983. * @param _radius The radius of the vortex
  51984. * @param _strength The strength of the vortex
  51985. * @param _height The height of the vortex
  51986. */
  51987. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51988. /**
  51989. * Returns the data related to the vortex event (cylinder).
  51990. * @returns The physics vortex event data
  51991. */
  51992. getData(): PhysicsVortexEventData;
  51993. /**
  51994. * Enables the vortex.
  51995. */
  51996. enable(): void;
  51997. /**
  51998. * Disables the cortex.
  51999. */
  52000. disable(): void;
  52001. /**
  52002. * Disposes the sphere.
  52003. * @param force
  52004. */
  52005. dispose(force?: boolean): void;
  52006. private getImpostorForceAndContactPoint;
  52007. private _tick;
  52008. /*** Helpers ***/
  52009. private _prepareCylinder;
  52010. private _intersectsWithCylinder;
  52011. }
  52012. /**
  52013. * The strenght of the force in correspondence to the distance of the affected object
  52014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52015. */
  52016. export enum PhysicsRadialImpulseFalloff {
  52017. /** Defines that impulse is constant in strength across it's whole radius */
  52018. Constant = 0,
  52019. /** DEfines that impulse gets weaker if it's further from the origin */
  52020. Linear = 1
  52021. }
  52022. /**
  52023. * The strength of the force in correspondence to the distance of the affected object
  52024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52025. */
  52026. export enum PhysicsUpdraftMode {
  52027. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52028. Center = 0,
  52029. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52030. Perpendicular = 1
  52031. }
  52032. /**
  52033. * Interface for a physics force and contact point
  52034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52035. */
  52036. export interface PhysicsForceAndContactPoint {
  52037. /**
  52038. * The force applied at the contact point
  52039. */
  52040. force: Vector3;
  52041. /**
  52042. * The contact point
  52043. */
  52044. contactPoint: Vector3;
  52045. }
  52046. /**
  52047. * Interface for radial explosion event data
  52048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52049. */
  52050. export interface PhysicsRadialExplosionEventData {
  52051. /**
  52052. * A sphere used for the radial explosion event
  52053. */
  52054. sphere: Mesh;
  52055. /**
  52056. * An array of rays for the radial explosion event
  52057. */
  52058. rays: Array<Ray>;
  52059. }
  52060. /**
  52061. * Interface for gravitational field event data
  52062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52063. */
  52064. export interface PhysicsGravitationalFieldEventData {
  52065. /**
  52066. * A sphere mesh used for the gravitational field event
  52067. */
  52068. sphere: Mesh;
  52069. }
  52070. /**
  52071. * Interface for updraft event data
  52072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52073. */
  52074. export interface PhysicsUpdraftEventData {
  52075. /**
  52076. * A cylinder used for the updraft event
  52077. */
  52078. cylinder: Mesh;
  52079. }
  52080. /**
  52081. * Interface for vortex event data
  52082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52083. */
  52084. export interface PhysicsVortexEventData {
  52085. /**
  52086. * A cylinder used for the vortex event
  52087. */
  52088. cylinder: Mesh;
  52089. }
  52090. }
  52091. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52092. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52093. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52094. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52095. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52096. import { Nullable } from "babylonjs/types";
  52097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52098. /**
  52099. * AmmoJS Physics plugin
  52100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52101. * @see https://github.com/kripken/ammo.js/
  52102. */
  52103. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52104. private _useDeltaForWorldStep;
  52105. /**
  52106. * Reference to the Ammo library
  52107. */
  52108. bjsAMMO: any;
  52109. /**
  52110. * Created ammoJS world which physics bodies are added to
  52111. */
  52112. world: any;
  52113. /**
  52114. * Name of the plugin
  52115. */
  52116. name: string;
  52117. private _timeStep;
  52118. private _fixedTimeStep;
  52119. private _maxSteps;
  52120. private _tmpQuaternion;
  52121. private _tmpAmmoTransform;
  52122. private _tmpAmmoQuaternion;
  52123. private _tmpAmmoConcreteContactResultCallback;
  52124. private _collisionConfiguration;
  52125. private _dispatcher;
  52126. private _overlappingPairCache;
  52127. private _solver;
  52128. private _tmpAmmoVectorA;
  52129. private _tmpAmmoVectorB;
  52130. private _tmpAmmoVectorC;
  52131. private _tmpContactCallbackResult;
  52132. private static readonly DISABLE_COLLISION_FLAG;
  52133. private static readonly KINEMATIC_FLAG;
  52134. private static readonly DISABLE_DEACTIVATION_FLAG;
  52135. /**
  52136. * Initializes the ammoJS plugin
  52137. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52138. * @param ammoInjection can be used to inject your own ammo reference
  52139. */
  52140. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52141. /**
  52142. * Sets the gravity of the physics world (m/(s^2))
  52143. * @param gravity Gravity to set
  52144. */
  52145. setGravity(gravity: Vector3): void;
  52146. /**
  52147. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52148. * @param timeStep timestep to use in seconds
  52149. */
  52150. setTimeStep(timeStep: number): void;
  52151. /**
  52152. * 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)
  52153. * @param fixedTimeStep fixedTimeStep to use in seconds
  52154. */
  52155. setFixedTimeStep(fixedTimeStep: number): void;
  52156. /**
  52157. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52158. * @param maxSteps the maximum number of steps by the physics engine per frame
  52159. */
  52160. setMaxSteps(maxSteps: number): void;
  52161. /**
  52162. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52163. * @returns the current timestep in seconds
  52164. */
  52165. getTimeStep(): number;
  52166. private _isImpostorInContact;
  52167. private _isImpostorPairInContact;
  52168. private _stepSimulation;
  52169. /**
  52170. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52171. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52172. * After the step the babylon meshes are set to the position of the physics imposters
  52173. * @param delta amount of time to step forward
  52174. * @param impostors array of imposters to update before/after the step
  52175. */
  52176. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52177. private _tmpVector;
  52178. private _tmpMatrix;
  52179. /**
  52180. * Applies an implulse on the imposter
  52181. * @param impostor imposter to apply impulse
  52182. * @param force amount of force to be applied to the imposter
  52183. * @param contactPoint the location to apply the impulse on the imposter
  52184. */
  52185. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52186. /**
  52187. * Applies a force on the imposter
  52188. * @param impostor imposter to apply force
  52189. * @param force amount of force to be applied to the imposter
  52190. * @param contactPoint the location to apply the force on the imposter
  52191. */
  52192. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52193. /**
  52194. * Creates a physics body using the plugin
  52195. * @param impostor the imposter to create the physics body on
  52196. */
  52197. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52198. /**
  52199. * Removes the physics body from the imposter and disposes of the body's memory
  52200. * @param impostor imposter to remove the physics body from
  52201. */
  52202. removePhysicsBody(impostor: PhysicsImpostor): void;
  52203. /**
  52204. * Generates a joint
  52205. * @param impostorJoint the imposter joint to create the joint with
  52206. */
  52207. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52208. /**
  52209. * Removes a joint
  52210. * @param impostorJoint the imposter joint to remove the joint from
  52211. */
  52212. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52213. private _addMeshVerts;
  52214. private _createShape;
  52215. /**
  52216. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52217. * @param impostor imposter containing the physics body and babylon object
  52218. */
  52219. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52220. /**
  52221. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52222. * @param impostor imposter containing the physics body and babylon object
  52223. * @param newPosition new position
  52224. * @param newRotation new rotation
  52225. */
  52226. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52227. /**
  52228. * If this plugin is supported
  52229. * @returns true if its supported
  52230. */
  52231. isSupported(): boolean;
  52232. /**
  52233. * Sets the linear velocity of the physics body
  52234. * @param impostor imposter to set the velocity on
  52235. * @param velocity velocity to set
  52236. */
  52237. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52238. /**
  52239. * Sets the angular velocity of the physics body
  52240. * @param impostor imposter to set the velocity on
  52241. * @param velocity velocity to set
  52242. */
  52243. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52244. /**
  52245. * gets the linear velocity
  52246. * @param impostor imposter to get linear velocity from
  52247. * @returns linear velocity
  52248. */
  52249. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52250. /**
  52251. * gets the angular velocity
  52252. * @param impostor imposter to get angular velocity from
  52253. * @returns angular velocity
  52254. */
  52255. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52256. /**
  52257. * Sets the mass of physics body
  52258. * @param impostor imposter to set the mass on
  52259. * @param mass mass to set
  52260. */
  52261. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52262. /**
  52263. * Gets the mass of the physics body
  52264. * @param impostor imposter to get the mass from
  52265. * @returns mass
  52266. */
  52267. getBodyMass(impostor: PhysicsImpostor): number;
  52268. /**
  52269. * Gets friction of the impostor
  52270. * @param impostor impostor to get friction from
  52271. * @returns friction value
  52272. */
  52273. getBodyFriction(impostor: PhysicsImpostor): number;
  52274. /**
  52275. * Sets friction of the impostor
  52276. * @param impostor impostor to set friction on
  52277. * @param friction friction value
  52278. */
  52279. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52280. /**
  52281. * Gets restitution of the impostor
  52282. * @param impostor impostor to get restitution from
  52283. * @returns restitution value
  52284. */
  52285. getBodyRestitution(impostor: PhysicsImpostor): number;
  52286. /**
  52287. * Sets resitution of the impostor
  52288. * @param impostor impostor to set resitution on
  52289. * @param restitution resitution value
  52290. */
  52291. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52292. /**
  52293. * Sleeps the physics body and stops it from being active
  52294. * @param impostor impostor to sleep
  52295. */
  52296. sleepBody(impostor: PhysicsImpostor): void;
  52297. /**
  52298. * Activates the physics body
  52299. * @param impostor impostor to activate
  52300. */
  52301. wakeUpBody(impostor: PhysicsImpostor): void;
  52302. /**
  52303. * Updates the distance parameters of the joint
  52304. * @param joint joint to update
  52305. * @param maxDistance maximum distance of the joint
  52306. * @param minDistance minimum distance of the joint
  52307. */
  52308. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52309. /**
  52310. * Sets a motor on the joint
  52311. * @param joint joint to set motor on
  52312. * @param speed speed of the motor
  52313. * @param maxForce maximum force of the motor
  52314. * @param motorIndex index of the motor
  52315. */
  52316. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52317. /**
  52318. * Sets the motors limit
  52319. * @param joint joint to set limit on
  52320. * @param upperLimit upper limit
  52321. * @param lowerLimit lower limit
  52322. */
  52323. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52324. /**
  52325. * Syncs the position and rotation of a mesh with the impostor
  52326. * @param mesh mesh to sync
  52327. * @param impostor impostor to update the mesh with
  52328. */
  52329. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52330. /**
  52331. * Gets the radius of the impostor
  52332. * @param impostor impostor to get radius from
  52333. * @returns the radius
  52334. */
  52335. getRadius(impostor: PhysicsImpostor): number;
  52336. /**
  52337. * Gets the box size of the impostor
  52338. * @param impostor impostor to get box size from
  52339. * @param result the resulting box size
  52340. */
  52341. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52342. /**
  52343. * Disposes of the impostor
  52344. */
  52345. dispose(): void;
  52346. }
  52347. }
  52348. declare module "babylonjs/Physics/Plugins/index" {
  52349. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52350. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52351. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52352. }
  52353. declare module "babylonjs/Physics/index" {
  52354. export * from "babylonjs/Physics/IPhysicsEngine";
  52355. export * from "babylonjs/Physics/physicsEngine";
  52356. export * from "babylonjs/Physics/physicsEngineComponent";
  52357. export * from "babylonjs/Physics/physicsHelper";
  52358. export * from "babylonjs/Physics/physicsImpostor";
  52359. export * from "babylonjs/Physics/physicsJoint";
  52360. export * from "babylonjs/Physics/Plugins/index";
  52361. }
  52362. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52363. /** @hidden */
  52364. export var blackAndWhitePixelShader: {
  52365. name: string;
  52366. shader: string;
  52367. };
  52368. }
  52369. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52371. import { Camera } from "babylonjs/Cameras/camera";
  52372. import { Engine } from "babylonjs/Engines/engine";
  52373. import "babylonjs/Shaders/blackAndWhite.fragment";
  52374. /**
  52375. * Post process used to render in black and white
  52376. */
  52377. export class BlackAndWhitePostProcess extends PostProcess {
  52378. /**
  52379. * Linear about to convert he result to black and white (default: 1)
  52380. */
  52381. degree: number;
  52382. /**
  52383. * Creates a black and white post process
  52384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52385. * @param name The name of the effect.
  52386. * @param options The required width/height ratio to downsize to before computing the render pass.
  52387. * @param camera The camera to apply the render pass to.
  52388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52389. * @param engine The engine which the post process will be applied. (default: current engine)
  52390. * @param reusable If the post process can be reused on the same frame. (default: false)
  52391. */
  52392. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52393. }
  52394. }
  52395. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52396. import { Nullable } from "babylonjs/types";
  52397. import { Camera } from "babylonjs/Cameras/camera";
  52398. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52399. import { Engine } from "babylonjs/Engines/engine";
  52400. /**
  52401. * This represents a set of one or more post processes in Babylon.
  52402. * A post process can be used to apply a shader to a texture after it is rendered.
  52403. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52404. */
  52405. export class PostProcessRenderEffect {
  52406. private _postProcesses;
  52407. private _getPostProcesses;
  52408. private _singleInstance;
  52409. private _cameras;
  52410. private _indicesForCamera;
  52411. /**
  52412. * Name of the effect
  52413. * @hidden
  52414. */
  52415. _name: string;
  52416. /**
  52417. * Instantiates a post process render effect.
  52418. * A post process can be used to apply a shader to a texture after it is rendered.
  52419. * @param engine The engine the effect is tied to
  52420. * @param name The name of the effect
  52421. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52422. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52423. */
  52424. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52425. /**
  52426. * Checks if all the post processes in the effect are supported.
  52427. */
  52428. readonly isSupported: boolean;
  52429. /**
  52430. * Updates the current state of the effect
  52431. * @hidden
  52432. */
  52433. _update(): void;
  52434. /**
  52435. * Attaches the effect on cameras
  52436. * @param cameras The camera to attach to.
  52437. * @hidden
  52438. */
  52439. _attachCameras(cameras: Camera): void;
  52440. /**
  52441. * Attaches the effect on cameras
  52442. * @param cameras The camera to attach to.
  52443. * @hidden
  52444. */
  52445. _attachCameras(cameras: Camera[]): void;
  52446. /**
  52447. * Detatches the effect on cameras
  52448. * @param cameras The camera to detatch from.
  52449. * @hidden
  52450. */
  52451. _detachCameras(cameras: Camera): void;
  52452. /**
  52453. * Detatches the effect on cameras
  52454. * @param cameras The camera to detatch from.
  52455. * @hidden
  52456. */
  52457. _detachCameras(cameras: Camera[]): void;
  52458. /**
  52459. * Enables the effect on given cameras
  52460. * @param cameras The camera to enable.
  52461. * @hidden
  52462. */
  52463. _enable(cameras: Camera): void;
  52464. /**
  52465. * Enables the effect on given cameras
  52466. * @param cameras The camera to enable.
  52467. * @hidden
  52468. */
  52469. _enable(cameras: Nullable<Camera[]>): void;
  52470. /**
  52471. * Disables the effect on the given cameras
  52472. * @param cameras The camera to disable.
  52473. * @hidden
  52474. */
  52475. _disable(cameras: Camera): void;
  52476. /**
  52477. * Disables the effect on the given cameras
  52478. * @param cameras The camera to disable.
  52479. * @hidden
  52480. */
  52481. _disable(cameras: Nullable<Camera[]>): void;
  52482. /**
  52483. * Gets a list of the post processes contained in the effect.
  52484. * @param camera The camera to get the post processes on.
  52485. * @returns The list of the post processes in the effect.
  52486. */
  52487. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52488. }
  52489. }
  52490. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52491. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52492. /** @hidden */
  52493. export var extractHighlightsPixelShader: {
  52494. name: string;
  52495. shader: string;
  52496. };
  52497. }
  52498. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52499. import { Nullable } from "babylonjs/types";
  52500. import { Camera } from "babylonjs/Cameras/camera";
  52501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52502. import { Engine } from "babylonjs/Engines/engine";
  52503. import "babylonjs/Shaders/extractHighlights.fragment";
  52504. /**
  52505. * 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.
  52506. */
  52507. export class ExtractHighlightsPostProcess extends PostProcess {
  52508. /**
  52509. * The luminance threshold, pixels below this value will be set to black.
  52510. */
  52511. threshold: number;
  52512. /** @hidden */
  52513. _exposure: number;
  52514. /**
  52515. * Post process which has the input texture to be used when performing highlight extraction
  52516. * @hidden
  52517. */
  52518. _inputPostProcess: Nullable<PostProcess>;
  52519. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52520. }
  52521. }
  52522. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52523. /** @hidden */
  52524. export var bloomMergePixelShader: {
  52525. name: string;
  52526. shader: string;
  52527. };
  52528. }
  52529. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52530. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52531. import { Nullable } from "babylonjs/types";
  52532. import { Engine } from "babylonjs/Engines/engine";
  52533. import { Camera } from "babylonjs/Cameras/camera";
  52534. import "babylonjs/Shaders/bloomMerge.fragment";
  52535. /**
  52536. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52537. */
  52538. export class BloomMergePostProcess extends PostProcess {
  52539. /** Weight of the bloom to be added to the original input. */
  52540. weight: number;
  52541. /**
  52542. * Creates a new instance of @see BloomMergePostProcess
  52543. * @param name The name of the effect.
  52544. * @param originalFromInput Post process which's input will be used for the merge.
  52545. * @param blurred Blurred highlights post process which's output will be used.
  52546. * @param weight Weight of the bloom to be added to the original input.
  52547. * @param options The required width/height ratio to downsize to before computing the render pass.
  52548. * @param camera The camera to apply the render pass to.
  52549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52550. * @param engine The engine which the post process will be applied. (default: current engine)
  52551. * @param reusable If the post process can be reused on the same frame. (default: false)
  52552. * @param textureType Type of textures used when performing the post process. (default: 0)
  52553. * @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)
  52554. */
  52555. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52556. /** Weight of the bloom to be added to the original input. */
  52557. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52558. }
  52559. }
  52560. declare module "babylonjs/PostProcesses/bloomEffect" {
  52561. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52563. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52564. import { Camera } from "babylonjs/Cameras/camera";
  52565. import { Scene } from "babylonjs/scene";
  52566. /**
  52567. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52568. */
  52569. export class BloomEffect extends PostProcessRenderEffect {
  52570. private bloomScale;
  52571. /**
  52572. * @hidden Internal
  52573. */
  52574. _effects: Array<PostProcess>;
  52575. /**
  52576. * @hidden Internal
  52577. */
  52578. _downscale: ExtractHighlightsPostProcess;
  52579. private _blurX;
  52580. private _blurY;
  52581. private _merge;
  52582. /**
  52583. * The luminance threshold to find bright areas of the image to bloom.
  52584. */
  52585. threshold: number;
  52586. /**
  52587. * The strength of the bloom.
  52588. */
  52589. weight: number;
  52590. /**
  52591. * Specifies the size of the bloom blur kernel, relative to the final output size
  52592. */
  52593. kernel: number;
  52594. /**
  52595. * Creates a new instance of @see BloomEffect
  52596. * @param scene The scene the effect belongs to.
  52597. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52598. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52599. * @param bloomWeight The the strength of bloom.
  52600. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52601. * @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)
  52602. */
  52603. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52604. /**
  52605. * Disposes each of the internal effects for a given camera.
  52606. * @param camera The camera to dispose the effect on.
  52607. */
  52608. disposeEffects(camera: Camera): void;
  52609. /**
  52610. * @hidden Internal
  52611. */
  52612. _updateEffects(): void;
  52613. /**
  52614. * Internal
  52615. * @returns if all the contained post processes are ready.
  52616. * @hidden
  52617. */
  52618. _isReady(): boolean;
  52619. }
  52620. }
  52621. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52622. /** @hidden */
  52623. export var chromaticAberrationPixelShader: {
  52624. name: string;
  52625. shader: string;
  52626. };
  52627. }
  52628. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52629. import { Vector2 } from "babylonjs/Maths/math";
  52630. import { Nullable } from "babylonjs/types";
  52631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52632. import { Camera } from "babylonjs/Cameras/camera";
  52633. import { Engine } from "babylonjs/Engines/engine";
  52634. import "babylonjs/Shaders/chromaticAberration.fragment";
  52635. /**
  52636. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52637. */
  52638. export class ChromaticAberrationPostProcess extends PostProcess {
  52639. /**
  52640. * The amount of seperation of rgb channels (default: 30)
  52641. */
  52642. aberrationAmount: number;
  52643. /**
  52644. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52645. */
  52646. radialIntensity: number;
  52647. /**
  52648. * 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))
  52649. */
  52650. direction: Vector2;
  52651. /**
  52652. * 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))
  52653. */
  52654. centerPosition: Vector2;
  52655. /**
  52656. * Creates a new instance ChromaticAberrationPostProcess
  52657. * @param name The name of the effect.
  52658. * @param screenWidth The width of the screen to apply the effect on.
  52659. * @param screenHeight The height of the screen to apply the effect on.
  52660. * @param options The required width/height ratio to downsize to before computing the render pass.
  52661. * @param camera The camera to apply the render pass to.
  52662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52663. * @param engine The engine which the post process will be applied. (default: current engine)
  52664. * @param reusable If the post process can be reused on the same frame. (default: false)
  52665. * @param textureType Type of textures used when performing the post process. (default: 0)
  52666. * @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)
  52667. */
  52668. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52669. }
  52670. }
  52671. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52672. /** @hidden */
  52673. export var circleOfConfusionPixelShader: {
  52674. name: string;
  52675. shader: string;
  52676. };
  52677. }
  52678. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52679. import { Nullable } from "babylonjs/types";
  52680. import { Engine } from "babylonjs/Engines/engine";
  52681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52683. import { Camera } from "babylonjs/Cameras/camera";
  52684. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52685. /**
  52686. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52687. */
  52688. export class CircleOfConfusionPostProcess extends PostProcess {
  52689. /**
  52690. * 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.
  52691. */
  52692. lensSize: number;
  52693. /**
  52694. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52695. */
  52696. fStop: number;
  52697. /**
  52698. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52699. */
  52700. focusDistance: number;
  52701. /**
  52702. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52703. */
  52704. focalLength: number;
  52705. private _depthTexture;
  52706. /**
  52707. * Creates a new instance CircleOfConfusionPostProcess
  52708. * @param name The name of the effect.
  52709. * @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.
  52710. * @param options The required width/height ratio to downsize to before computing the render pass.
  52711. * @param camera The camera to apply the render pass to.
  52712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52713. * @param engine The engine which the post process will be applied. (default: current engine)
  52714. * @param reusable If the post process can be reused on the same frame. (default: false)
  52715. * @param textureType Type of textures used when performing the post process. (default: 0)
  52716. * @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)
  52717. */
  52718. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52719. /**
  52720. * 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.
  52721. */
  52722. depthTexture: RenderTargetTexture;
  52723. }
  52724. }
  52725. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52726. /** @hidden */
  52727. export var colorCorrectionPixelShader: {
  52728. name: string;
  52729. shader: string;
  52730. };
  52731. }
  52732. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52733. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52734. import { Engine } from "babylonjs/Engines/engine";
  52735. import { Camera } from "babylonjs/Cameras/camera";
  52736. import "babylonjs/Shaders/colorCorrection.fragment";
  52737. /**
  52738. *
  52739. * This post-process allows the modification of rendered colors by using
  52740. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52741. *
  52742. * The object needs to be provided an url to a texture containing the color
  52743. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52744. * Use an image editing software to tweak the LUT to match your needs.
  52745. *
  52746. * For an example of a color LUT, see here:
  52747. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52748. * For explanations on color grading, see here:
  52749. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52750. *
  52751. */
  52752. export class ColorCorrectionPostProcess extends PostProcess {
  52753. private _colorTableTexture;
  52754. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52755. }
  52756. }
  52757. declare module "babylonjs/Shaders/convolution.fragment" {
  52758. /** @hidden */
  52759. export var convolutionPixelShader: {
  52760. name: string;
  52761. shader: string;
  52762. };
  52763. }
  52764. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52765. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52766. import { Nullable } from "babylonjs/types";
  52767. import { Camera } from "babylonjs/Cameras/camera";
  52768. import { Engine } from "babylonjs/Engines/engine";
  52769. import "babylonjs/Shaders/convolution.fragment";
  52770. /**
  52771. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52772. * input texture to perform effects such as edge detection or sharpening
  52773. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52774. */
  52775. export class ConvolutionPostProcess extends PostProcess {
  52776. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52777. kernel: number[];
  52778. /**
  52779. * Creates a new instance ConvolutionPostProcess
  52780. * @param name The name of the effect.
  52781. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52782. * @param options The required width/height ratio to downsize to before computing the render pass.
  52783. * @param camera The camera to apply the render pass to.
  52784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52785. * @param engine The engine which the post process will be applied. (default: current engine)
  52786. * @param reusable If the post process can be reused on the same frame. (default: false)
  52787. * @param textureType Type of textures used when performing the post process. (default: 0)
  52788. */
  52789. constructor(name: string,
  52790. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52791. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52792. /**
  52793. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52794. */
  52795. static EdgeDetect0Kernel: number[];
  52796. /**
  52797. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52798. */
  52799. static EdgeDetect1Kernel: number[];
  52800. /**
  52801. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52802. */
  52803. static EdgeDetect2Kernel: number[];
  52804. /**
  52805. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52806. */
  52807. static SharpenKernel: number[];
  52808. /**
  52809. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52810. */
  52811. static EmbossKernel: number[];
  52812. /**
  52813. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52814. */
  52815. static GaussianKernel: number[];
  52816. }
  52817. }
  52818. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52819. import { Nullable } from "babylonjs/types";
  52820. import { Vector2 } from "babylonjs/Maths/math";
  52821. import { Camera } from "babylonjs/Cameras/camera";
  52822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52823. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52824. import { Engine } from "babylonjs/Engines/engine";
  52825. import { Scene } from "babylonjs/scene";
  52826. /**
  52827. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52828. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52829. * based on samples that have a large difference in distance than the center pixel.
  52830. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52831. */
  52832. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52833. direction: Vector2;
  52834. /**
  52835. * Creates a new instance CircleOfConfusionPostProcess
  52836. * @param name The name of the effect.
  52837. * @param scene The scene the effect belongs to.
  52838. * @param direction The direction the blur should be applied.
  52839. * @param kernel The size of the kernel used to blur.
  52840. * @param options The required width/height ratio to downsize to before computing the render pass.
  52841. * @param camera The camera to apply the render pass to.
  52842. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52843. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52845. * @param engine The engine which the post process will be applied. (default: current engine)
  52846. * @param reusable If the post process can be reused on the same frame. (default: false)
  52847. * @param textureType Type of textures used when performing the post process. (default: 0)
  52848. * @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)
  52849. */
  52850. 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);
  52851. }
  52852. }
  52853. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52854. /** @hidden */
  52855. export var depthOfFieldMergePixelShader: {
  52856. name: string;
  52857. shader: string;
  52858. };
  52859. }
  52860. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52861. import { Nullable } from "babylonjs/types";
  52862. import { Camera } from "babylonjs/Cameras/camera";
  52863. import { Effect } from "babylonjs/Materials/effect";
  52864. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52865. import { Engine } from "babylonjs/Engines/engine";
  52866. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52867. /**
  52868. * Options to be set when merging outputs from the default pipeline.
  52869. */
  52870. export class DepthOfFieldMergePostProcessOptions {
  52871. /**
  52872. * The original image to merge on top of
  52873. */
  52874. originalFromInput: PostProcess;
  52875. /**
  52876. * Parameters to perform the merge of the depth of field effect
  52877. */
  52878. depthOfField?: {
  52879. circleOfConfusion: PostProcess;
  52880. blurSteps: Array<PostProcess>;
  52881. };
  52882. /**
  52883. * Parameters to perform the merge of bloom effect
  52884. */
  52885. bloom?: {
  52886. blurred: PostProcess;
  52887. weight: number;
  52888. };
  52889. }
  52890. /**
  52891. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52892. */
  52893. export class DepthOfFieldMergePostProcess extends PostProcess {
  52894. private blurSteps;
  52895. /**
  52896. * Creates a new instance of DepthOfFieldMergePostProcess
  52897. * @param name The name of the effect.
  52898. * @param originalFromInput Post process which's input will be used for the merge.
  52899. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52900. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52901. * @param options The required width/height ratio to downsize to before computing the render pass.
  52902. * @param camera The camera to apply the render pass to.
  52903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52904. * @param engine The engine which the post process will be applied. (default: current engine)
  52905. * @param reusable If the post process can be reused on the same frame. (default: false)
  52906. * @param textureType Type of textures used when performing the post process. (default: 0)
  52907. * @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)
  52908. */
  52909. 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);
  52910. /**
  52911. * Updates the effect with the current post process compile time values and recompiles the shader.
  52912. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52913. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52914. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52915. * @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
  52916. * @param onCompiled Called when the shader has been compiled.
  52917. * @param onError Called if there is an error when compiling a shader.
  52918. */
  52919. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52920. }
  52921. }
  52922. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52923. import { Nullable } from "babylonjs/types";
  52924. import { Camera } from "babylonjs/Cameras/camera";
  52925. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52927. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52928. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52929. import { Scene } from "babylonjs/scene";
  52930. /**
  52931. * Specifies the level of max blur that should be applied when using the depth of field effect
  52932. */
  52933. export enum DepthOfFieldEffectBlurLevel {
  52934. /**
  52935. * Subtle blur
  52936. */
  52937. Low = 0,
  52938. /**
  52939. * Medium blur
  52940. */
  52941. Medium = 1,
  52942. /**
  52943. * Large blur
  52944. */
  52945. High = 2
  52946. }
  52947. /**
  52948. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52949. */
  52950. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52951. private _circleOfConfusion;
  52952. /**
  52953. * @hidden Internal, blurs from high to low
  52954. */
  52955. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52956. private _depthOfFieldBlurY;
  52957. private _dofMerge;
  52958. /**
  52959. * @hidden Internal post processes in depth of field effect
  52960. */
  52961. _effects: Array<PostProcess>;
  52962. /**
  52963. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52964. */
  52965. focalLength: number;
  52966. /**
  52967. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52968. */
  52969. fStop: number;
  52970. /**
  52971. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52972. */
  52973. focusDistance: number;
  52974. /**
  52975. * 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.
  52976. */
  52977. lensSize: number;
  52978. /**
  52979. * Creates a new instance DepthOfFieldEffect
  52980. * @param scene The scene the effect belongs to.
  52981. * @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.
  52982. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52983. * @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)
  52984. */
  52985. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52986. /**
  52987. * 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.
  52988. */
  52989. depthTexture: RenderTargetTexture;
  52990. /**
  52991. * Disposes each of the internal effects for a given camera.
  52992. * @param camera The camera to dispose the effect on.
  52993. */
  52994. disposeEffects(camera: Camera): void;
  52995. /**
  52996. * @hidden Internal
  52997. */
  52998. _updateEffects(): void;
  52999. /**
  53000. * Internal
  53001. * @returns if all the contained post processes are ready.
  53002. * @hidden
  53003. */
  53004. _isReady(): boolean;
  53005. }
  53006. }
  53007. declare module "babylonjs/Shaders/displayPass.fragment" {
  53008. /** @hidden */
  53009. export var displayPassPixelShader: {
  53010. name: string;
  53011. shader: string;
  53012. };
  53013. }
  53014. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53015. import { Nullable } from "babylonjs/types";
  53016. import { Camera } from "babylonjs/Cameras/camera";
  53017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53018. import { Engine } from "babylonjs/Engines/engine";
  53019. import "babylonjs/Shaders/displayPass.fragment";
  53020. /**
  53021. * DisplayPassPostProcess which produces an output the same as it's input
  53022. */
  53023. export class DisplayPassPostProcess extends PostProcess {
  53024. /**
  53025. * Creates the DisplayPassPostProcess
  53026. * @param name The name of the effect.
  53027. * @param options The required width/height ratio to downsize to before computing the render pass.
  53028. * @param camera The camera to apply the render pass to.
  53029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53030. * @param engine The engine which the post process will be applied. (default: current engine)
  53031. * @param reusable If the post process can be reused on the same frame. (default: false)
  53032. */
  53033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53034. }
  53035. }
  53036. declare module "babylonjs/Shaders/filter.fragment" {
  53037. /** @hidden */
  53038. export var filterPixelShader: {
  53039. name: string;
  53040. shader: string;
  53041. };
  53042. }
  53043. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53044. import { Nullable } from "babylonjs/types";
  53045. import { Matrix } from "babylonjs/Maths/math";
  53046. import { Camera } from "babylonjs/Cameras/camera";
  53047. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53048. import { Engine } from "babylonjs/Engines/engine";
  53049. import "babylonjs/Shaders/filter.fragment";
  53050. /**
  53051. * Applies a kernel filter to the image
  53052. */
  53053. export class FilterPostProcess extends PostProcess {
  53054. /** The matrix to be applied to the image */
  53055. kernelMatrix: Matrix;
  53056. /**
  53057. *
  53058. * @param name The name of the effect.
  53059. * @param kernelMatrix The matrix to be applied to the image
  53060. * @param options The required width/height ratio to downsize to before computing the render pass.
  53061. * @param camera The camera to apply the render pass to.
  53062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53063. * @param engine The engine which the post process will be applied. (default: current engine)
  53064. * @param reusable If the post process can be reused on the same frame. (default: false)
  53065. */
  53066. constructor(name: string,
  53067. /** The matrix to be applied to the image */
  53068. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53069. }
  53070. }
  53071. declare module "babylonjs/Shaders/fxaa.fragment" {
  53072. /** @hidden */
  53073. export var fxaaPixelShader: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module "babylonjs/Shaders/fxaa.vertex" {
  53079. /** @hidden */
  53080. export var fxaaVertexShader: {
  53081. name: string;
  53082. shader: string;
  53083. };
  53084. }
  53085. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53086. import { Nullable } from "babylonjs/types";
  53087. import { Camera } from "babylonjs/Cameras/camera";
  53088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53089. import { Engine } from "babylonjs/Engines/engine";
  53090. import "babylonjs/Shaders/fxaa.fragment";
  53091. import "babylonjs/Shaders/fxaa.vertex";
  53092. /**
  53093. * Fxaa post process
  53094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53095. */
  53096. export class FxaaPostProcess extends PostProcess {
  53097. /** @hidden */
  53098. texelWidth: number;
  53099. /** @hidden */
  53100. texelHeight: number;
  53101. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53102. private _getDefines;
  53103. }
  53104. }
  53105. declare module "babylonjs/Shaders/grain.fragment" {
  53106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53107. /** @hidden */
  53108. export var grainPixelShader: {
  53109. name: string;
  53110. shader: string;
  53111. };
  53112. }
  53113. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53114. import { Nullable } from "babylonjs/types";
  53115. import { Camera } from "babylonjs/Cameras/camera";
  53116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53117. import { Engine } from "babylonjs/Engines/engine";
  53118. import "babylonjs/Shaders/grain.fragment";
  53119. /**
  53120. * The GrainPostProcess adds noise to the image at mid luminance levels
  53121. */
  53122. export class GrainPostProcess extends PostProcess {
  53123. /**
  53124. * The intensity of the grain added (default: 30)
  53125. */
  53126. intensity: number;
  53127. /**
  53128. * If the grain should be randomized on every frame
  53129. */
  53130. animated: boolean;
  53131. /**
  53132. * Creates a new instance of @see GrainPostProcess
  53133. * @param name The name of the effect.
  53134. * @param options The required width/height ratio to downsize to before computing the render pass.
  53135. * @param camera The camera to apply the render pass to.
  53136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53137. * @param engine The engine which the post process will be applied. (default: current engine)
  53138. * @param reusable If the post process can be reused on the same frame. (default: false)
  53139. * @param textureType Type of textures used when performing the post process. (default: 0)
  53140. * @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)
  53141. */
  53142. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53143. }
  53144. }
  53145. declare module "babylonjs/Shaders/highlights.fragment" {
  53146. /** @hidden */
  53147. export var highlightsPixelShader: {
  53148. name: string;
  53149. shader: string;
  53150. };
  53151. }
  53152. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53153. import { Nullable } from "babylonjs/types";
  53154. import { Camera } from "babylonjs/Cameras/camera";
  53155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53156. import { Engine } from "babylonjs/Engines/engine";
  53157. import "babylonjs/Shaders/highlights.fragment";
  53158. /**
  53159. * Extracts highlights from the image
  53160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53161. */
  53162. export class HighlightsPostProcess extends PostProcess {
  53163. /**
  53164. * Extracts highlights from the image
  53165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53166. * @param name The name of the effect.
  53167. * @param options The required width/height ratio to downsize to before computing the render pass.
  53168. * @param camera The camera to apply the render pass to.
  53169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53170. * @param engine The engine which the post process will be applied. (default: current engine)
  53171. * @param reusable If the post process can be reused on the same frame. (default: false)
  53172. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53173. */
  53174. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53175. }
  53176. }
  53177. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53178. /** @hidden */
  53179. export var mrtFragmentDeclaration: {
  53180. name: string;
  53181. shader: string;
  53182. };
  53183. }
  53184. declare module "babylonjs/Shaders/geometry.fragment" {
  53185. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53186. /** @hidden */
  53187. export var geometryPixelShader: {
  53188. name: string;
  53189. shader: string;
  53190. };
  53191. }
  53192. declare module "babylonjs/Shaders/geometry.vertex" {
  53193. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53194. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53195. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53196. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53197. /** @hidden */
  53198. export var geometryVertexShader: {
  53199. name: string;
  53200. shader: string;
  53201. };
  53202. }
  53203. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53204. import { Matrix } from "babylonjs/Maths/math";
  53205. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53206. import { Mesh } from "babylonjs/Meshes/mesh";
  53207. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53208. import { Effect } from "babylonjs/Materials/effect";
  53209. import { Scene } from "babylonjs/scene";
  53210. import "babylonjs/Shaders/geometry.fragment";
  53211. import "babylonjs/Shaders/geometry.vertex";
  53212. /**
  53213. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53214. */
  53215. export class GeometryBufferRenderer {
  53216. /**
  53217. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53218. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53219. */
  53220. static readonly POSITION_TEXTURE_TYPE: number;
  53221. /**
  53222. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53223. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53224. */
  53225. static readonly VELOCITY_TEXTURE_TYPE: number;
  53226. /**
  53227. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53228. * in order to compute objects velocities when enableVelocity is set to "true"
  53229. * @hidden
  53230. */
  53231. _previousTransformationMatrices: {
  53232. [index: number]: Matrix;
  53233. };
  53234. private _scene;
  53235. private _multiRenderTarget;
  53236. private _ratio;
  53237. private _enablePosition;
  53238. private _enableVelocity;
  53239. private _positionIndex;
  53240. private _velocityIndex;
  53241. protected _effect: Effect;
  53242. protected _cachedDefines: string;
  53243. /**
  53244. * Set the render list (meshes to be rendered) used in the G buffer.
  53245. */
  53246. renderList: Mesh[];
  53247. /**
  53248. * Gets wether or not G buffer are supported by the running hardware.
  53249. * This requires draw buffer supports
  53250. */
  53251. readonly isSupported: boolean;
  53252. /**
  53253. * Returns the index of the given texture type in the G-Buffer textures array
  53254. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53255. * @returns the index of the given texture type in the G-Buffer textures array
  53256. */
  53257. getTextureIndex(textureType: number): number;
  53258. /**
  53259. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53260. */
  53261. /**
  53262. * Sets whether or not objects positions are enabled for the G buffer.
  53263. */
  53264. enablePosition: boolean;
  53265. /**
  53266. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53267. */
  53268. /**
  53269. * Sets wether or not objects velocities are enabled for the G buffer.
  53270. */
  53271. enableVelocity: boolean;
  53272. /**
  53273. * Gets the scene associated with the buffer.
  53274. */
  53275. readonly scene: Scene;
  53276. /**
  53277. * Gets the ratio used by the buffer during its creation.
  53278. * How big is the buffer related to the main canvas.
  53279. */
  53280. readonly ratio: number;
  53281. /** @hidden */
  53282. static _SceneComponentInitialization: (scene: Scene) => void;
  53283. /**
  53284. * Creates a new G Buffer for the scene
  53285. * @param scene The scene the buffer belongs to
  53286. * @param ratio How big is the buffer related to the main canvas.
  53287. */
  53288. constructor(scene: Scene, ratio?: number);
  53289. /**
  53290. * Checks wether everything is ready to render a submesh to the G buffer.
  53291. * @param subMesh the submesh to check readiness for
  53292. * @param useInstances is the mesh drawn using instance or not
  53293. * @returns true if ready otherwise false
  53294. */
  53295. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53296. /**
  53297. * Gets the current underlying G Buffer.
  53298. * @returns the buffer
  53299. */
  53300. getGBuffer(): MultiRenderTarget;
  53301. /**
  53302. * Gets the number of samples used to render the buffer (anti aliasing).
  53303. */
  53304. /**
  53305. * Sets the number of samples used to render the buffer (anti aliasing).
  53306. */
  53307. samples: number;
  53308. /**
  53309. * Disposes the renderer and frees up associated resources.
  53310. */
  53311. dispose(): void;
  53312. protected _createRenderTargets(): void;
  53313. }
  53314. }
  53315. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53316. /** @hidden */
  53317. export var motionBlurPixelShader: {
  53318. name: string;
  53319. shader: string;
  53320. };
  53321. }
  53322. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53323. import { Nullable } from "babylonjs/types";
  53324. import { Camera } from "babylonjs/Cameras/camera";
  53325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53326. import { Scene } from "babylonjs/scene";
  53327. import "babylonjs/Shaders/motionBlur.fragment";
  53328. import { Engine } from "babylonjs/Engines/engine";
  53329. /**
  53330. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53331. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53332. * As an example, all you have to do is to create the post-process:
  53333. * var mb = new BABYLON.MotionBlurPostProcess(
  53334. * 'mb', // The name of the effect.
  53335. * scene, // The scene containing the objects to blur according to their velocity.
  53336. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53337. * camera // The camera to apply the render pass to.
  53338. * );
  53339. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53340. */
  53341. export class MotionBlurPostProcess extends PostProcess {
  53342. /**
  53343. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53344. */
  53345. motionStrength: number;
  53346. /**
  53347. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53348. */
  53349. /**
  53350. * Sets the number of iterations to be used for motion blur quality
  53351. */
  53352. motionBlurSamples: number;
  53353. private _motionBlurSamples;
  53354. private _geometryBufferRenderer;
  53355. /**
  53356. * Creates a new instance MotionBlurPostProcess
  53357. * @param name The name of the effect.
  53358. * @param scene The scene containing the objects to blur according to their velocity.
  53359. * @param options The required width/height ratio to downsize to before computing the render pass.
  53360. * @param camera The camera to apply the render pass to.
  53361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53362. * @param engine The engine which the post process will be applied. (default: current engine)
  53363. * @param reusable If the post process can be reused on the same frame. (default: false)
  53364. * @param textureType Type of textures used when performing the post process. (default: 0)
  53365. * @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)
  53366. */
  53367. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53368. /**
  53369. * Disposes the post process.
  53370. * @param camera The camera to dispose the post process on.
  53371. */
  53372. dispose(camera?: Camera): void;
  53373. }
  53374. }
  53375. declare module "babylonjs/Shaders/refraction.fragment" {
  53376. /** @hidden */
  53377. export var refractionPixelShader: {
  53378. name: string;
  53379. shader: string;
  53380. };
  53381. }
  53382. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53383. import { Color3 } from "babylonjs/Maths/math";
  53384. import { Camera } from "babylonjs/Cameras/camera";
  53385. import { Texture } from "babylonjs/Materials/Textures/texture";
  53386. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53387. import { Engine } from "babylonjs/Engines/engine";
  53388. import "babylonjs/Shaders/refraction.fragment";
  53389. /**
  53390. * Post process which applies a refractin texture
  53391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53392. */
  53393. export class RefractionPostProcess extends PostProcess {
  53394. /** the base color of the refraction (used to taint the rendering) */
  53395. color: Color3;
  53396. /** simulated refraction depth */
  53397. depth: number;
  53398. /** the coefficient of the base color (0 to remove base color tainting) */
  53399. colorLevel: number;
  53400. private _refTexture;
  53401. private _ownRefractionTexture;
  53402. /**
  53403. * Gets or sets the refraction texture
  53404. * Please note that you are responsible for disposing the texture if you set it manually
  53405. */
  53406. refractionTexture: Texture;
  53407. /**
  53408. * Initializes the RefractionPostProcess
  53409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53410. * @param name The name of the effect.
  53411. * @param refractionTextureUrl Url of the refraction texture to use
  53412. * @param color the base color of the refraction (used to taint the rendering)
  53413. * @param depth simulated refraction depth
  53414. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53415. * @param camera The camera to apply the render pass to.
  53416. * @param options The required width/height ratio to downsize to before computing the render pass.
  53417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53418. * @param engine The engine which the post process will be applied. (default: current engine)
  53419. * @param reusable If the post process can be reused on the same frame. (default: false)
  53420. */
  53421. constructor(name: string, refractionTextureUrl: string,
  53422. /** the base color of the refraction (used to taint the rendering) */
  53423. color: Color3,
  53424. /** simulated refraction depth */
  53425. depth: number,
  53426. /** the coefficient of the base color (0 to remove base color tainting) */
  53427. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53428. /**
  53429. * Disposes of the post process
  53430. * @param camera Camera to dispose post process on
  53431. */
  53432. dispose(camera: Camera): void;
  53433. }
  53434. }
  53435. declare module "babylonjs/Shaders/sharpen.fragment" {
  53436. /** @hidden */
  53437. export var sharpenPixelShader: {
  53438. name: string;
  53439. shader: string;
  53440. };
  53441. }
  53442. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53443. import { Nullable } from "babylonjs/types";
  53444. import { Camera } from "babylonjs/Cameras/camera";
  53445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53446. import "babylonjs/Shaders/sharpen.fragment";
  53447. import { Engine } from "babylonjs/Engines/engine";
  53448. /**
  53449. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53450. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53451. */
  53452. export class SharpenPostProcess extends PostProcess {
  53453. /**
  53454. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53455. */
  53456. colorAmount: number;
  53457. /**
  53458. * How much sharpness should be applied (default: 0.3)
  53459. */
  53460. edgeAmount: number;
  53461. /**
  53462. * Creates a new instance ConvolutionPostProcess
  53463. * @param name The name of the effect.
  53464. * @param options The required width/height ratio to downsize to before computing the render pass.
  53465. * @param camera The camera to apply the render pass to.
  53466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53467. * @param engine The engine which the post process will be applied. (default: current engine)
  53468. * @param reusable If the post process can be reused on the same frame. (default: false)
  53469. * @param textureType Type of textures used when performing the post process. (default: 0)
  53470. * @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)
  53471. */
  53472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53473. }
  53474. }
  53475. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53476. import { Nullable } from "babylonjs/types";
  53477. import { Camera } from "babylonjs/Cameras/camera";
  53478. import { Engine } from "babylonjs/Engines/engine";
  53479. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53480. /**
  53481. * PostProcessRenderPipeline
  53482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53483. */
  53484. export class PostProcessRenderPipeline {
  53485. private engine;
  53486. private _renderEffects;
  53487. private _renderEffectsForIsolatedPass;
  53488. /**
  53489. * @hidden
  53490. */
  53491. protected _cameras: Camera[];
  53492. /** @hidden */
  53493. _name: string;
  53494. /**
  53495. * Gets pipeline name
  53496. */
  53497. readonly name: string;
  53498. /**
  53499. * Initializes a PostProcessRenderPipeline
  53500. * @param engine engine to add the pipeline to
  53501. * @param name name of the pipeline
  53502. */
  53503. constructor(engine: Engine, name: string);
  53504. /**
  53505. * Gets the class name
  53506. * @returns "PostProcessRenderPipeline"
  53507. */
  53508. getClassName(): string;
  53509. /**
  53510. * If all the render effects in the pipeline are supported
  53511. */
  53512. readonly isSupported: boolean;
  53513. /**
  53514. * Adds an effect to the pipeline
  53515. * @param renderEffect the effect to add
  53516. */
  53517. addEffect(renderEffect: PostProcessRenderEffect): void;
  53518. /** @hidden */
  53519. _rebuild(): void;
  53520. /** @hidden */
  53521. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53522. /** @hidden */
  53523. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53524. /** @hidden */
  53525. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53526. /** @hidden */
  53527. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53528. /** @hidden */
  53529. _attachCameras(cameras: Camera, unique: boolean): void;
  53530. /** @hidden */
  53531. _attachCameras(cameras: Camera[], unique: boolean): void;
  53532. /** @hidden */
  53533. _detachCameras(cameras: Camera): void;
  53534. /** @hidden */
  53535. _detachCameras(cameras: Nullable<Camera[]>): void;
  53536. /** @hidden */
  53537. _update(): void;
  53538. /** @hidden */
  53539. _reset(): void;
  53540. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53541. /**
  53542. * Disposes of the pipeline
  53543. */
  53544. dispose(): void;
  53545. }
  53546. }
  53547. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53548. import { IAnimatable } from "babylonjs/Misc/tools";
  53549. import { Camera } from "babylonjs/Cameras/camera";
  53550. import { IDisposable } from "babylonjs/scene";
  53551. import { Scene } from "babylonjs/scene";
  53552. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53553. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53554. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53555. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53556. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53557. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53558. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53559. import { Animation } from "babylonjs/Animations/animation";
  53560. /**
  53561. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53562. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53563. */
  53564. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53565. private _scene;
  53566. private _camerasToBeAttached;
  53567. /**
  53568. * ID of the sharpen post process,
  53569. */
  53570. private readonly SharpenPostProcessId;
  53571. /**
  53572. * @ignore
  53573. * ID of the image processing post process;
  53574. */
  53575. readonly ImageProcessingPostProcessId: string;
  53576. /**
  53577. * @ignore
  53578. * ID of the Fast Approximate Anti-Aliasing post process;
  53579. */
  53580. readonly FxaaPostProcessId: string;
  53581. /**
  53582. * ID of the chromatic aberration post process,
  53583. */
  53584. private readonly ChromaticAberrationPostProcessId;
  53585. /**
  53586. * ID of the grain post process
  53587. */
  53588. private readonly GrainPostProcessId;
  53589. /**
  53590. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53591. */
  53592. sharpen: SharpenPostProcess;
  53593. private _sharpenEffect;
  53594. private bloom;
  53595. /**
  53596. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53597. */
  53598. depthOfField: DepthOfFieldEffect;
  53599. /**
  53600. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53601. */
  53602. fxaa: FxaaPostProcess;
  53603. /**
  53604. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53605. */
  53606. imageProcessing: ImageProcessingPostProcess;
  53607. /**
  53608. * Chromatic aberration post process which will shift rgb colors in the image
  53609. */
  53610. chromaticAberration: ChromaticAberrationPostProcess;
  53611. private _chromaticAberrationEffect;
  53612. /**
  53613. * Grain post process which add noise to the image
  53614. */
  53615. grain: GrainPostProcess;
  53616. private _grainEffect;
  53617. /**
  53618. * Glow post process which adds a glow to emissive areas of the image
  53619. */
  53620. private _glowLayer;
  53621. /**
  53622. * Animations which can be used to tweak settings over a period of time
  53623. */
  53624. animations: Animation[];
  53625. private _imageProcessingConfigurationObserver;
  53626. private _sharpenEnabled;
  53627. private _bloomEnabled;
  53628. private _depthOfFieldEnabled;
  53629. private _depthOfFieldBlurLevel;
  53630. private _fxaaEnabled;
  53631. private _imageProcessingEnabled;
  53632. private _defaultPipelineTextureType;
  53633. private _bloomScale;
  53634. private _chromaticAberrationEnabled;
  53635. private _grainEnabled;
  53636. private _buildAllowed;
  53637. /**
  53638. * Gets active scene
  53639. */
  53640. readonly scene: Scene;
  53641. /**
  53642. * Enable or disable the sharpen process from the pipeline
  53643. */
  53644. sharpenEnabled: boolean;
  53645. private _resizeObserver;
  53646. private _hardwareScaleLevel;
  53647. private _bloomKernel;
  53648. /**
  53649. * Specifies the size of the bloom blur kernel, relative to the final output size
  53650. */
  53651. bloomKernel: number;
  53652. /**
  53653. * Specifies the weight of the bloom in the final rendering
  53654. */
  53655. private _bloomWeight;
  53656. /**
  53657. * Specifies the luma threshold for the area that will be blurred by the bloom
  53658. */
  53659. private _bloomThreshold;
  53660. private _hdr;
  53661. /**
  53662. * The strength of the bloom.
  53663. */
  53664. bloomWeight: number;
  53665. /**
  53666. * The strength of the bloom.
  53667. */
  53668. bloomThreshold: number;
  53669. /**
  53670. * The scale of the bloom, lower value will provide better performance.
  53671. */
  53672. bloomScale: number;
  53673. /**
  53674. * Enable or disable the bloom from the pipeline
  53675. */
  53676. bloomEnabled: boolean;
  53677. private _rebuildBloom;
  53678. /**
  53679. * If the depth of field is enabled.
  53680. */
  53681. depthOfFieldEnabled: boolean;
  53682. /**
  53683. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53684. */
  53685. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53686. /**
  53687. * If the anti aliasing is enabled.
  53688. */
  53689. fxaaEnabled: boolean;
  53690. private _samples;
  53691. /**
  53692. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53693. */
  53694. samples: number;
  53695. /**
  53696. * If image processing is enabled.
  53697. */
  53698. imageProcessingEnabled: boolean;
  53699. /**
  53700. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53701. */
  53702. glowLayerEnabled: boolean;
  53703. /**
  53704. * Enable or disable the chromaticAberration process from the pipeline
  53705. */
  53706. chromaticAberrationEnabled: boolean;
  53707. /**
  53708. * Enable or disable the grain process from the pipeline
  53709. */
  53710. grainEnabled: boolean;
  53711. /**
  53712. * @constructor
  53713. * @param name - The rendering pipeline name (default: "")
  53714. * @param hdr - If high dynamic range textures should be used (default: true)
  53715. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53716. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53717. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53718. */
  53719. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53720. /**
  53721. * Get the class name
  53722. * @returns "DefaultRenderingPipeline"
  53723. */
  53724. getClassName(): string;
  53725. /**
  53726. * Force the compilation of the entire pipeline.
  53727. */
  53728. prepare(): void;
  53729. private _hasCleared;
  53730. private _prevPostProcess;
  53731. private _prevPrevPostProcess;
  53732. private _setAutoClearAndTextureSharing;
  53733. private _depthOfFieldSceneObserver;
  53734. private _buildPipeline;
  53735. private _disposePostProcesses;
  53736. /**
  53737. * Adds a camera to the pipeline
  53738. * @param camera the camera to be added
  53739. */
  53740. addCamera(camera: Camera): void;
  53741. /**
  53742. * Removes a camera from the pipeline
  53743. * @param camera the camera to remove
  53744. */
  53745. removeCamera(camera: Camera): void;
  53746. /**
  53747. * Dispose of the pipeline and stop all post processes
  53748. */
  53749. dispose(): void;
  53750. /**
  53751. * Serialize the rendering pipeline (Used when exporting)
  53752. * @returns the serialized object
  53753. */
  53754. serialize(): any;
  53755. /**
  53756. * Parse the serialized pipeline
  53757. * @param source Source pipeline.
  53758. * @param scene The scene to load the pipeline to.
  53759. * @param rootUrl The URL of the serialized pipeline.
  53760. * @returns An instantiated pipeline from the serialized object.
  53761. */
  53762. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53763. }
  53764. }
  53765. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53766. /** @hidden */
  53767. export var lensHighlightsPixelShader: {
  53768. name: string;
  53769. shader: string;
  53770. };
  53771. }
  53772. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53773. /** @hidden */
  53774. export var depthOfFieldPixelShader: {
  53775. name: string;
  53776. shader: string;
  53777. };
  53778. }
  53779. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53780. import { Camera } from "babylonjs/Cameras/camera";
  53781. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53782. import { Scene } from "babylonjs/scene";
  53783. import "babylonjs/Shaders/chromaticAberration.fragment";
  53784. import "babylonjs/Shaders/lensHighlights.fragment";
  53785. import "babylonjs/Shaders/depthOfField.fragment";
  53786. /**
  53787. * BABYLON.JS Chromatic Aberration GLSL Shader
  53788. * Author: Olivier Guyot
  53789. * Separates very slightly R, G and B colors on the edges of the screen
  53790. * Inspired by Francois Tarlier & Martins Upitis
  53791. */
  53792. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53793. /**
  53794. * @ignore
  53795. * The chromatic aberration PostProcess id in the pipeline
  53796. */
  53797. LensChromaticAberrationEffect: string;
  53798. /**
  53799. * @ignore
  53800. * The highlights enhancing PostProcess id in the pipeline
  53801. */
  53802. HighlightsEnhancingEffect: string;
  53803. /**
  53804. * @ignore
  53805. * The depth-of-field PostProcess id in the pipeline
  53806. */
  53807. LensDepthOfFieldEffect: string;
  53808. private _scene;
  53809. private _depthTexture;
  53810. private _grainTexture;
  53811. private _chromaticAberrationPostProcess;
  53812. private _highlightsPostProcess;
  53813. private _depthOfFieldPostProcess;
  53814. private _edgeBlur;
  53815. private _grainAmount;
  53816. private _chromaticAberration;
  53817. private _distortion;
  53818. private _highlightsGain;
  53819. private _highlightsThreshold;
  53820. private _dofDistance;
  53821. private _dofAperture;
  53822. private _dofDarken;
  53823. private _dofPentagon;
  53824. private _blurNoise;
  53825. /**
  53826. * @constructor
  53827. *
  53828. * Effect parameters are as follow:
  53829. * {
  53830. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53831. * edge_blur: number; // from 0 to x (1 for realism)
  53832. * distortion: number; // from 0 to x (1 for realism)
  53833. * grain_amount: number; // from 0 to 1
  53834. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53835. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53836. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53837. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53838. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53839. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53840. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53841. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53842. * }
  53843. * Note: if an effect parameter is unset, effect is disabled
  53844. *
  53845. * @param name The rendering pipeline name
  53846. * @param parameters - An object containing all parameters (see above)
  53847. * @param scene The scene linked to this pipeline
  53848. * @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)
  53849. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53850. */
  53851. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53852. /**
  53853. * Sets the amount of blur at the edges
  53854. * @param amount blur amount
  53855. */
  53856. setEdgeBlur(amount: number): void;
  53857. /**
  53858. * Sets edge blur to 0
  53859. */
  53860. disableEdgeBlur(): void;
  53861. /**
  53862. * Sets the amout of grain
  53863. * @param amount Amount of grain
  53864. */
  53865. setGrainAmount(amount: number): void;
  53866. /**
  53867. * Set grain amount to 0
  53868. */
  53869. disableGrain(): void;
  53870. /**
  53871. * Sets the chromatic aberration amount
  53872. * @param amount amount of chromatic aberration
  53873. */
  53874. setChromaticAberration(amount: number): void;
  53875. /**
  53876. * Sets chromatic aberration amount to 0
  53877. */
  53878. disableChromaticAberration(): void;
  53879. /**
  53880. * Sets the EdgeDistortion amount
  53881. * @param amount amount of EdgeDistortion
  53882. */
  53883. setEdgeDistortion(amount: number): void;
  53884. /**
  53885. * Sets edge distortion to 0
  53886. */
  53887. disableEdgeDistortion(): void;
  53888. /**
  53889. * Sets the FocusDistance amount
  53890. * @param amount amount of FocusDistance
  53891. */
  53892. setFocusDistance(amount: number): void;
  53893. /**
  53894. * Disables depth of field
  53895. */
  53896. disableDepthOfField(): void;
  53897. /**
  53898. * Sets the Aperture amount
  53899. * @param amount amount of Aperture
  53900. */
  53901. setAperture(amount: number): void;
  53902. /**
  53903. * Sets the DarkenOutOfFocus amount
  53904. * @param amount amount of DarkenOutOfFocus
  53905. */
  53906. setDarkenOutOfFocus(amount: number): void;
  53907. /**
  53908. * Creates a pentagon bokeh effect
  53909. */
  53910. enablePentagonBokeh(): void;
  53911. /**
  53912. * Disables the pentagon bokeh effect
  53913. */
  53914. disablePentagonBokeh(): void;
  53915. /**
  53916. * Enables noise blur
  53917. */
  53918. enableNoiseBlur(): void;
  53919. /**
  53920. * Disables noise blur
  53921. */
  53922. disableNoiseBlur(): void;
  53923. /**
  53924. * Sets the HighlightsGain amount
  53925. * @param amount amount of HighlightsGain
  53926. */
  53927. setHighlightsGain(amount: number): void;
  53928. /**
  53929. * Sets the HighlightsThreshold amount
  53930. * @param amount amount of HighlightsThreshold
  53931. */
  53932. setHighlightsThreshold(amount: number): void;
  53933. /**
  53934. * Disables highlights
  53935. */
  53936. disableHighlights(): void;
  53937. /**
  53938. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53939. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53940. */
  53941. dispose(disableDepthRender?: boolean): void;
  53942. private _createChromaticAberrationPostProcess;
  53943. private _createHighlightsPostProcess;
  53944. private _createDepthOfFieldPostProcess;
  53945. private _createGrainTexture;
  53946. }
  53947. }
  53948. declare module "babylonjs/Shaders/ssao2.fragment" {
  53949. /** @hidden */
  53950. export var ssao2PixelShader: {
  53951. name: string;
  53952. shader: string;
  53953. };
  53954. }
  53955. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53956. /** @hidden */
  53957. export var ssaoCombinePixelShader: {
  53958. name: string;
  53959. shader: string;
  53960. };
  53961. }
  53962. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53963. import { Camera } from "babylonjs/Cameras/camera";
  53964. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53965. import { Scene } from "babylonjs/scene";
  53966. import "babylonjs/Shaders/ssao2.fragment";
  53967. import "babylonjs/Shaders/ssaoCombine.fragment";
  53968. /**
  53969. * Render pipeline to produce ssao effect
  53970. */
  53971. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53972. /**
  53973. * @ignore
  53974. * The PassPostProcess id in the pipeline that contains the original scene color
  53975. */
  53976. SSAOOriginalSceneColorEffect: string;
  53977. /**
  53978. * @ignore
  53979. * The SSAO PostProcess id in the pipeline
  53980. */
  53981. SSAORenderEffect: string;
  53982. /**
  53983. * @ignore
  53984. * The horizontal blur PostProcess id in the pipeline
  53985. */
  53986. SSAOBlurHRenderEffect: string;
  53987. /**
  53988. * @ignore
  53989. * The vertical blur PostProcess id in the pipeline
  53990. */
  53991. SSAOBlurVRenderEffect: string;
  53992. /**
  53993. * @ignore
  53994. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53995. */
  53996. SSAOCombineRenderEffect: string;
  53997. /**
  53998. * The output strength of the SSAO post-process. Default value is 1.0.
  53999. */
  54000. totalStrength: number;
  54001. /**
  54002. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54003. */
  54004. maxZ: number;
  54005. /**
  54006. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54007. */
  54008. minZAspect: number;
  54009. private _samples;
  54010. /**
  54011. * Number of samples used for the SSAO calculations. Default value is 8
  54012. */
  54013. samples: number;
  54014. private _textureSamples;
  54015. /**
  54016. * Number of samples to use for antialiasing
  54017. */
  54018. textureSamples: number;
  54019. /**
  54020. * Ratio object used for SSAO ratio and blur ratio
  54021. */
  54022. private _ratio;
  54023. /**
  54024. * Dynamically generated sphere sampler.
  54025. */
  54026. private _sampleSphere;
  54027. /**
  54028. * Blur filter offsets
  54029. */
  54030. private _samplerOffsets;
  54031. private _expensiveBlur;
  54032. /**
  54033. * If bilateral blur should be used
  54034. */
  54035. expensiveBlur: boolean;
  54036. /**
  54037. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54038. */
  54039. radius: number;
  54040. /**
  54041. * The base color of the SSAO post-process
  54042. * The final result is "base + ssao" between [0, 1]
  54043. */
  54044. base: number;
  54045. /**
  54046. * Support test.
  54047. */
  54048. static readonly IsSupported: boolean;
  54049. private _scene;
  54050. private _depthTexture;
  54051. private _normalTexture;
  54052. private _randomTexture;
  54053. private _originalColorPostProcess;
  54054. private _ssaoPostProcess;
  54055. private _blurHPostProcess;
  54056. private _blurVPostProcess;
  54057. private _ssaoCombinePostProcess;
  54058. private _firstUpdate;
  54059. /**
  54060. * Gets active scene
  54061. */
  54062. readonly scene: Scene;
  54063. /**
  54064. * @constructor
  54065. * @param name The rendering pipeline name
  54066. * @param scene The scene linked to this pipeline
  54067. * @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 }
  54068. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54069. */
  54070. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54071. /**
  54072. * Get the class name
  54073. * @returns "SSAO2RenderingPipeline"
  54074. */
  54075. getClassName(): string;
  54076. /**
  54077. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54078. */
  54079. dispose(disableGeometryBufferRenderer?: boolean): void;
  54080. private _createBlurPostProcess;
  54081. /** @hidden */
  54082. _rebuild(): void;
  54083. private _bits;
  54084. private _radicalInverse_VdC;
  54085. private _hammersley;
  54086. private _hemisphereSample_uniform;
  54087. private _generateHemisphere;
  54088. private _createSSAOPostProcess;
  54089. private _createSSAOCombinePostProcess;
  54090. private _createRandomTexture;
  54091. /**
  54092. * Serialize the rendering pipeline (Used when exporting)
  54093. * @returns the serialized object
  54094. */
  54095. serialize(): any;
  54096. /**
  54097. * Parse the serialized pipeline
  54098. * @param source Source pipeline.
  54099. * @param scene The scene to load the pipeline to.
  54100. * @param rootUrl The URL of the serialized pipeline.
  54101. * @returns An instantiated pipeline from the serialized object.
  54102. */
  54103. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54104. }
  54105. }
  54106. declare module "babylonjs/Shaders/ssao.fragment" {
  54107. /** @hidden */
  54108. export var ssaoPixelShader: {
  54109. name: string;
  54110. shader: string;
  54111. };
  54112. }
  54113. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54114. import { Camera } from "babylonjs/Cameras/camera";
  54115. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54116. import { Scene } from "babylonjs/scene";
  54117. import "babylonjs/Shaders/ssao.fragment";
  54118. import "babylonjs/Shaders/ssaoCombine.fragment";
  54119. /**
  54120. * Render pipeline to produce ssao effect
  54121. */
  54122. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54123. /**
  54124. * @ignore
  54125. * The PassPostProcess id in the pipeline that contains the original scene color
  54126. */
  54127. SSAOOriginalSceneColorEffect: string;
  54128. /**
  54129. * @ignore
  54130. * The SSAO PostProcess id in the pipeline
  54131. */
  54132. SSAORenderEffect: string;
  54133. /**
  54134. * @ignore
  54135. * The horizontal blur PostProcess id in the pipeline
  54136. */
  54137. SSAOBlurHRenderEffect: string;
  54138. /**
  54139. * @ignore
  54140. * The vertical blur PostProcess id in the pipeline
  54141. */
  54142. SSAOBlurVRenderEffect: string;
  54143. /**
  54144. * @ignore
  54145. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54146. */
  54147. SSAOCombineRenderEffect: string;
  54148. /**
  54149. * The output strength of the SSAO post-process. Default value is 1.0.
  54150. */
  54151. totalStrength: number;
  54152. /**
  54153. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54154. */
  54155. radius: number;
  54156. /**
  54157. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54158. * Must not be equal to fallOff and superior to fallOff.
  54159. * Default value is 0.0075
  54160. */
  54161. area: number;
  54162. /**
  54163. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54164. * Must not be equal to area and inferior to area.
  54165. * Default value is 0.000001
  54166. */
  54167. fallOff: number;
  54168. /**
  54169. * The base color of the SSAO post-process
  54170. * The final result is "base + ssao" between [0, 1]
  54171. */
  54172. base: number;
  54173. private _scene;
  54174. private _depthTexture;
  54175. private _randomTexture;
  54176. private _originalColorPostProcess;
  54177. private _ssaoPostProcess;
  54178. private _blurHPostProcess;
  54179. private _blurVPostProcess;
  54180. private _ssaoCombinePostProcess;
  54181. private _firstUpdate;
  54182. /**
  54183. * Gets active scene
  54184. */
  54185. readonly scene: Scene;
  54186. /**
  54187. * @constructor
  54188. * @param name - The rendering pipeline name
  54189. * @param scene - The scene linked to this pipeline
  54190. * @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 }
  54191. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54192. */
  54193. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54194. /**
  54195. * Get the class name
  54196. * @returns "SSAORenderingPipeline"
  54197. */
  54198. getClassName(): string;
  54199. /**
  54200. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54201. */
  54202. dispose(disableDepthRender?: boolean): void;
  54203. private _createBlurPostProcess;
  54204. /** @hidden */
  54205. _rebuild(): void;
  54206. private _createSSAOPostProcess;
  54207. private _createSSAOCombinePostProcess;
  54208. private _createRandomTexture;
  54209. }
  54210. }
  54211. declare module "babylonjs/Shaders/standard.fragment" {
  54212. /** @hidden */
  54213. export var standardPixelShader: {
  54214. name: string;
  54215. shader: string;
  54216. };
  54217. }
  54218. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54219. import { Nullable } from "babylonjs/types";
  54220. import { IAnimatable } from "babylonjs/Misc/tools";
  54221. import { Camera } from "babylonjs/Cameras/camera";
  54222. import { Texture } from "babylonjs/Materials/Textures/texture";
  54223. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54224. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54225. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54226. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54227. import { IDisposable } from "babylonjs/scene";
  54228. import { SpotLight } from "babylonjs/Lights/spotLight";
  54229. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54230. import { Scene } from "babylonjs/scene";
  54231. import { Animation } from "babylonjs/Animations/animation";
  54232. import "babylonjs/Shaders/standard.fragment";
  54233. /**
  54234. * Standard rendering pipeline
  54235. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54236. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54237. */
  54238. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54239. /**
  54240. * Public members
  54241. */
  54242. /**
  54243. * Post-process which contains the original scene color before the pipeline applies all the effects
  54244. */
  54245. originalPostProcess: Nullable<PostProcess>;
  54246. /**
  54247. * Post-process used to down scale an image x4
  54248. */
  54249. downSampleX4PostProcess: Nullable<PostProcess>;
  54250. /**
  54251. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54252. */
  54253. brightPassPostProcess: Nullable<PostProcess>;
  54254. /**
  54255. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54256. */
  54257. blurHPostProcesses: PostProcess[];
  54258. /**
  54259. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54260. */
  54261. blurVPostProcesses: PostProcess[];
  54262. /**
  54263. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54264. */
  54265. textureAdderPostProcess: Nullable<PostProcess>;
  54266. /**
  54267. * Post-process used to create volumetric lighting effect
  54268. */
  54269. volumetricLightPostProcess: Nullable<PostProcess>;
  54270. /**
  54271. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54272. */
  54273. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54274. /**
  54275. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54276. */
  54277. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54278. /**
  54279. * Post-process used to merge the volumetric light effect and the real scene color
  54280. */
  54281. volumetricLightMergePostProces: Nullable<PostProcess>;
  54282. /**
  54283. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54284. */
  54285. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54286. /**
  54287. * Base post-process used to calculate the average luminance of the final image for HDR
  54288. */
  54289. luminancePostProcess: Nullable<PostProcess>;
  54290. /**
  54291. * Post-processes used to create down sample post-processes in order to get
  54292. * the average luminance of the final image for HDR
  54293. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54294. */
  54295. luminanceDownSamplePostProcesses: PostProcess[];
  54296. /**
  54297. * Post-process used to create a HDR effect (light adaptation)
  54298. */
  54299. hdrPostProcess: Nullable<PostProcess>;
  54300. /**
  54301. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54302. */
  54303. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54304. /**
  54305. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54306. */
  54307. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54308. /**
  54309. * Post-process used to merge the final HDR post-process and the real scene color
  54310. */
  54311. hdrFinalPostProcess: Nullable<PostProcess>;
  54312. /**
  54313. * Post-process used to create a lens flare effect
  54314. */
  54315. lensFlarePostProcess: Nullable<PostProcess>;
  54316. /**
  54317. * Post-process that merges the result of the lens flare post-process and the real scene color
  54318. */
  54319. lensFlareComposePostProcess: Nullable<PostProcess>;
  54320. /**
  54321. * Post-process used to create a motion blur effect
  54322. */
  54323. motionBlurPostProcess: Nullable<PostProcess>;
  54324. /**
  54325. * Post-process used to create a depth of field effect
  54326. */
  54327. depthOfFieldPostProcess: Nullable<PostProcess>;
  54328. /**
  54329. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54330. */
  54331. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54332. /**
  54333. * Represents the brightness threshold in order to configure the illuminated surfaces
  54334. */
  54335. brightThreshold: number;
  54336. /**
  54337. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54338. */
  54339. blurWidth: number;
  54340. /**
  54341. * Sets if the blur for highlighted surfaces must be only horizontal
  54342. */
  54343. horizontalBlur: boolean;
  54344. /**
  54345. * Sets the overall exposure used by the pipeline
  54346. */
  54347. exposure: number;
  54348. /**
  54349. * Texture used typically to simulate "dirty" on camera lens
  54350. */
  54351. lensTexture: Nullable<Texture>;
  54352. /**
  54353. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54354. */
  54355. volumetricLightCoefficient: number;
  54356. /**
  54357. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54358. */
  54359. volumetricLightPower: number;
  54360. /**
  54361. * Used the set the blur intensity to smooth the volumetric lights
  54362. */
  54363. volumetricLightBlurScale: number;
  54364. /**
  54365. * Light (spot or directional) used to generate the volumetric lights rays
  54366. * The source light must have a shadow generate so the pipeline can get its
  54367. * depth map
  54368. */
  54369. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54370. /**
  54371. * For eye adaptation, represents the minimum luminance the eye can see
  54372. */
  54373. hdrMinimumLuminance: number;
  54374. /**
  54375. * For eye adaptation, represents the decrease luminance speed
  54376. */
  54377. hdrDecreaseRate: number;
  54378. /**
  54379. * For eye adaptation, represents the increase luminance speed
  54380. */
  54381. hdrIncreaseRate: number;
  54382. /**
  54383. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54384. */
  54385. lensColorTexture: Nullable<Texture>;
  54386. /**
  54387. * The overall strengh for the lens flare effect
  54388. */
  54389. lensFlareStrength: number;
  54390. /**
  54391. * Dispersion coefficient for lens flare ghosts
  54392. */
  54393. lensFlareGhostDispersal: number;
  54394. /**
  54395. * Main lens flare halo width
  54396. */
  54397. lensFlareHaloWidth: number;
  54398. /**
  54399. * Based on the lens distortion effect, defines how much the lens flare result
  54400. * is distorted
  54401. */
  54402. lensFlareDistortionStrength: number;
  54403. /**
  54404. * Lens star texture must be used to simulate rays on the flares and is available
  54405. * in the documentation
  54406. */
  54407. lensStarTexture: Nullable<Texture>;
  54408. /**
  54409. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54410. * flare effect by taking account of the dirt texture
  54411. */
  54412. lensFlareDirtTexture: Nullable<Texture>;
  54413. /**
  54414. * Represents the focal length for the depth of field effect
  54415. */
  54416. depthOfFieldDistance: number;
  54417. /**
  54418. * Represents the blur intensity for the blurred part of the depth of field effect
  54419. */
  54420. depthOfFieldBlurWidth: number;
  54421. /**
  54422. * For motion blur, defines how much the image is blurred by the movement
  54423. */
  54424. motionStrength: number;
  54425. /**
  54426. * List of animations for the pipeline (IAnimatable implementation)
  54427. */
  54428. animations: Animation[];
  54429. /**
  54430. * Private members
  54431. */
  54432. private _scene;
  54433. private _currentDepthOfFieldSource;
  54434. private _basePostProcess;
  54435. private _hdrCurrentLuminance;
  54436. private _floatTextureType;
  54437. private _ratio;
  54438. private _bloomEnabled;
  54439. private _depthOfFieldEnabled;
  54440. private _vlsEnabled;
  54441. private _lensFlareEnabled;
  54442. private _hdrEnabled;
  54443. private _motionBlurEnabled;
  54444. private _fxaaEnabled;
  54445. private _motionBlurSamples;
  54446. private _volumetricLightStepsCount;
  54447. private _samples;
  54448. /**
  54449. * @ignore
  54450. * Specifies if the bloom pipeline is enabled
  54451. */
  54452. BloomEnabled: boolean;
  54453. /**
  54454. * @ignore
  54455. * Specifies if the depth of field pipeline is enabed
  54456. */
  54457. DepthOfFieldEnabled: boolean;
  54458. /**
  54459. * @ignore
  54460. * Specifies if the lens flare pipeline is enabed
  54461. */
  54462. LensFlareEnabled: boolean;
  54463. /**
  54464. * @ignore
  54465. * Specifies if the HDR pipeline is enabled
  54466. */
  54467. HDREnabled: boolean;
  54468. /**
  54469. * @ignore
  54470. * Specifies if the volumetric lights scattering effect is enabled
  54471. */
  54472. VLSEnabled: boolean;
  54473. /**
  54474. * @ignore
  54475. * Specifies if the motion blur effect is enabled
  54476. */
  54477. MotionBlurEnabled: boolean;
  54478. /**
  54479. * Specifies if anti-aliasing is enabled
  54480. */
  54481. fxaaEnabled: boolean;
  54482. /**
  54483. * Specifies the number of steps used to calculate the volumetric lights
  54484. * Typically in interval [50, 200]
  54485. */
  54486. volumetricLightStepsCount: number;
  54487. /**
  54488. * Specifies the number of samples used for the motion blur effect
  54489. * Typically in interval [16, 64]
  54490. */
  54491. motionBlurSamples: number;
  54492. /**
  54493. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54494. */
  54495. samples: number;
  54496. /**
  54497. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54498. * @constructor
  54499. * @param name The rendering pipeline name
  54500. * @param scene The scene linked to this pipeline
  54501. * @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)
  54502. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54503. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54504. */
  54505. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54506. private _buildPipeline;
  54507. private _createDownSampleX4PostProcess;
  54508. private _createBrightPassPostProcess;
  54509. private _createBlurPostProcesses;
  54510. private _createTextureAdderPostProcess;
  54511. private _createVolumetricLightPostProcess;
  54512. private _createLuminancePostProcesses;
  54513. private _createHdrPostProcess;
  54514. private _createLensFlarePostProcess;
  54515. private _createDepthOfFieldPostProcess;
  54516. private _createMotionBlurPostProcess;
  54517. private _getDepthTexture;
  54518. private _disposePostProcesses;
  54519. /**
  54520. * Dispose of the pipeline and stop all post processes
  54521. */
  54522. dispose(): void;
  54523. /**
  54524. * Serialize the rendering pipeline (Used when exporting)
  54525. * @returns the serialized object
  54526. */
  54527. serialize(): any;
  54528. /**
  54529. * Parse the serialized pipeline
  54530. * @param source Source pipeline.
  54531. * @param scene The scene to load the pipeline to.
  54532. * @param rootUrl The URL of the serialized pipeline.
  54533. * @returns An instantiated pipeline from the serialized object.
  54534. */
  54535. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54536. /**
  54537. * Luminance steps
  54538. */
  54539. static LuminanceSteps: number;
  54540. }
  54541. }
  54542. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54543. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54544. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54545. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54546. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54547. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54548. }
  54549. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54550. import { Camera } from "babylonjs/Cameras/camera";
  54551. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54552. /**
  54553. * PostProcessRenderPipelineManager class
  54554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54555. */
  54556. export class PostProcessRenderPipelineManager {
  54557. private _renderPipelines;
  54558. /**
  54559. * Initializes a PostProcessRenderPipelineManager
  54560. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54561. */
  54562. constructor();
  54563. /**
  54564. * Gets the list of supported render pipelines
  54565. */
  54566. readonly supportedPipelines: PostProcessRenderPipeline[];
  54567. /**
  54568. * Adds a pipeline to the manager
  54569. * @param renderPipeline The pipeline to add
  54570. */
  54571. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54572. /**
  54573. * Attaches a camera to the pipeline
  54574. * @param renderPipelineName The name of the pipeline to attach to
  54575. * @param cameras the camera to attach
  54576. * @param unique if the camera can be attached multiple times to the pipeline
  54577. */
  54578. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54579. /**
  54580. * Detaches a camera from the pipeline
  54581. * @param renderPipelineName The name of the pipeline to detach from
  54582. * @param cameras the camera to detach
  54583. */
  54584. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54585. /**
  54586. * Enables an effect by name on a pipeline
  54587. * @param renderPipelineName the name of the pipeline to enable the effect in
  54588. * @param renderEffectName the name of the effect to enable
  54589. * @param cameras the cameras that the effect should be enabled on
  54590. */
  54591. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54592. /**
  54593. * Disables an effect by name on a pipeline
  54594. * @param renderPipelineName the name of the pipeline to disable the effect in
  54595. * @param renderEffectName the name of the effect to disable
  54596. * @param cameras the cameras that the effect should be disabled on
  54597. */
  54598. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54599. /**
  54600. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54601. */
  54602. update(): void;
  54603. /** @hidden */
  54604. _rebuild(): void;
  54605. /**
  54606. * Disposes of the manager and pipelines
  54607. */
  54608. dispose(): void;
  54609. }
  54610. }
  54611. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54612. import { ISceneComponent } from "babylonjs/sceneComponent";
  54613. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54614. import { Scene } from "babylonjs/scene";
  54615. module "babylonjs/scene" {
  54616. interface Scene {
  54617. /** @hidden (Backing field) */
  54618. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54619. /**
  54620. * Gets the postprocess render pipeline manager
  54621. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54622. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54623. */
  54624. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54625. }
  54626. }
  54627. /**
  54628. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54629. */
  54630. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54631. /**
  54632. * The component name helpfull to identify the component in the list of scene components.
  54633. */
  54634. readonly name: string;
  54635. /**
  54636. * The scene the component belongs to.
  54637. */
  54638. scene: Scene;
  54639. /**
  54640. * Creates a new instance of the component for the given scene
  54641. * @param scene Defines the scene to register the component in
  54642. */
  54643. constructor(scene: Scene);
  54644. /**
  54645. * Registers the component in a given scene
  54646. */
  54647. register(): void;
  54648. /**
  54649. * Rebuilds the elements related to this component in case of
  54650. * context lost for instance.
  54651. */
  54652. rebuild(): void;
  54653. /**
  54654. * Disposes the component and the associated ressources
  54655. */
  54656. dispose(): void;
  54657. private _gatherRenderTargets;
  54658. }
  54659. }
  54660. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54661. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54662. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54663. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54664. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54665. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54666. }
  54667. declare module "babylonjs/Shaders/tonemap.fragment" {
  54668. /** @hidden */
  54669. export var tonemapPixelShader: {
  54670. name: string;
  54671. shader: string;
  54672. };
  54673. }
  54674. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54675. import { Camera } from "babylonjs/Cameras/camera";
  54676. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54677. import "babylonjs/Shaders/tonemap.fragment";
  54678. import { Engine } from "babylonjs/Engines/engine";
  54679. /** Defines operator used for tonemapping */
  54680. export enum TonemappingOperator {
  54681. /** Hable */
  54682. Hable = 0,
  54683. /** Reinhard */
  54684. Reinhard = 1,
  54685. /** HejiDawson */
  54686. HejiDawson = 2,
  54687. /** Photographic */
  54688. Photographic = 3
  54689. }
  54690. /**
  54691. * Defines a post process to apply tone mapping
  54692. */
  54693. export class TonemapPostProcess extends PostProcess {
  54694. private _operator;
  54695. /** Defines the required exposure adjustement */
  54696. exposureAdjustment: number;
  54697. /**
  54698. * Creates a new TonemapPostProcess
  54699. * @param name defines the name of the postprocess
  54700. * @param _operator defines the operator to use
  54701. * @param exposureAdjustment defines the required exposure adjustement
  54702. * @param camera defines the camera to use (can be null)
  54703. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54704. * @param engine defines the hosting engine (can be ignore if camera is set)
  54705. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54706. */
  54707. constructor(name: string, _operator: TonemappingOperator,
  54708. /** Defines the required exposure adjustement */
  54709. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54710. }
  54711. }
  54712. declare module "babylonjs/Shaders/depth.vertex" {
  54713. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54714. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54715. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54716. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54717. /** @hidden */
  54718. export var depthVertexShader: {
  54719. name: string;
  54720. shader: string;
  54721. };
  54722. }
  54723. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54724. /** @hidden */
  54725. export var volumetricLightScatteringPixelShader: {
  54726. name: string;
  54727. shader: string;
  54728. };
  54729. }
  54730. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54731. /** @hidden */
  54732. export var volumetricLightScatteringPassPixelShader: {
  54733. name: string;
  54734. shader: string;
  54735. };
  54736. }
  54737. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54738. import { Vector3 } from "babylonjs/Maths/math";
  54739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54740. import { Mesh } from "babylonjs/Meshes/mesh";
  54741. import { Camera } from "babylonjs/Cameras/camera";
  54742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54744. import { Scene } from "babylonjs/scene";
  54745. import "babylonjs/Meshes/Builders/planeBuilder";
  54746. import "babylonjs/Shaders/depth.vertex";
  54747. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54748. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54749. import { Engine } from "babylonjs/Engines/engine";
  54750. /**
  54751. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54752. */
  54753. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54754. private _volumetricLightScatteringPass;
  54755. private _volumetricLightScatteringRTT;
  54756. private _viewPort;
  54757. private _screenCoordinates;
  54758. private _cachedDefines;
  54759. /**
  54760. * If not undefined, the mesh position is computed from the attached node position
  54761. */
  54762. attachedNode: {
  54763. position: Vector3;
  54764. };
  54765. /**
  54766. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54767. */
  54768. customMeshPosition: Vector3;
  54769. /**
  54770. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54771. */
  54772. useCustomMeshPosition: boolean;
  54773. /**
  54774. * If the post-process should inverse the light scattering direction
  54775. */
  54776. invert: boolean;
  54777. /**
  54778. * The internal mesh used by the post-process
  54779. */
  54780. mesh: Mesh;
  54781. /**
  54782. * @hidden
  54783. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54784. */
  54785. useDiffuseColor: boolean;
  54786. /**
  54787. * Array containing the excluded meshes not rendered in the internal pass
  54788. */
  54789. excludedMeshes: AbstractMesh[];
  54790. /**
  54791. * Controls the overall intensity of the post-process
  54792. */
  54793. exposure: number;
  54794. /**
  54795. * Dissipates each sample's contribution in range [0, 1]
  54796. */
  54797. decay: number;
  54798. /**
  54799. * Controls the overall intensity of each sample
  54800. */
  54801. weight: number;
  54802. /**
  54803. * Controls the density of each sample
  54804. */
  54805. density: number;
  54806. /**
  54807. * @constructor
  54808. * @param name The post-process name
  54809. * @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)
  54810. * @param camera The camera that the post-process will be attached to
  54811. * @param mesh The mesh used to create the light scattering
  54812. * @param samples The post-process quality, default 100
  54813. * @param samplingModeThe post-process filtering mode
  54814. * @param engine The babylon engine
  54815. * @param reusable If the post-process is reusable
  54816. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54817. */
  54818. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54819. /**
  54820. * Returns the string "VolumetricLightScatteringPostProcess"
  54821. * @returns "VolumetricLightScatteringPostProcess"
  54822. */
  54823. getClassName(): string;
  54824. private _isReady;
  54825. /**
  54826. * Sets the new light position for light scattering effect
  54827. * @param position The new custom light position
  54828. */
  54829. setCustomMeshPosition(position: Vector3): void;
  54830. /**
  54831. * Returns the light position for light scattering effect
  54832. * @return Vector3 The custom light position
  54833. */
  54834. getCustomMeshPosition(): Vector3;
  54835. /**
  54836. * Disposes the internal assets and detaches the post-process from the camera
  54837. */
  54838. dispose(camera: Camera): void;
  54839. /**
  54840. * Returns the render target texture used by the post-process
  54841. * @return the render target texture used by the post-process
  54842. */
  54843. getPass(): RenderTargetTexture;
  54844. private _meshExcluded;
  54845. private _createPass;
  54846. private _updateMeshScreenCoordinates;
  54847. /**
  54848. * Creates a default mesh for the Volumeric Light Scattering post-process
  54849. * @param name The mesh name
  54850. * @param scene The scene where to create the mesh
  54851. * @return the default mesh
  54852. */
  54853. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54854. }
  54855. }
  54856. declare module "babylonjs/PostProcesses/index" {
  54857. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54858. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54859. export * from "babylonjs/PostProcesses/bloomEffect";
  54860. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54861. export * from "babylonjs/PostProcesses/blurPostProcess";
  54862. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54863. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54864. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54865. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54866. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54867. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54868. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54869. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54870. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54871. export * from "babylonjs/PostProcesses/filterPostProcess";
  54872. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54873. export * from "babylonjs/PostProcesses/grainPostProcess";
  54874. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54875. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54876. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54877. export * from "babylonjs/PostProcesses/passPostProcess";
  54878. export * from "babylonjs/PostProcesses/postProcess";
  54879. export * from "babylonjs/PostProcesses/postProcessManager";
  54880. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54881. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54882. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54883. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54884. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54885. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54886. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54887. }
  54888. declare module "babylonjs/Probes/index" {
  54889. export * from "babylonjs/Probes/reflectionProbe";
  54890. }
  54891. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54892. import { Scene } from "babylonjs/scene";
  54893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54894. import { Color3 } from "babylonjs/Maths/math";
  54895. import { SmartArray } from "babylonjs/Misc/smartArray";
  54896. import { ISceneComponent } from "babylonjs/sceneComponent";
  54897. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54898. import "babylonjs/Meshes/Builders/boxBuilder";
  54899. import "babylonjs/Shaders/color.fragment";
  54900. import "babylonjs/Shaders/color.vertex";
  54901. module "babylonjs/scene" {
  54902. interface Scene {
  54903. /** @hidden (Backing field) */
  54904. _boundingBoxRenderer: BoundingBoxRenderer;
  54905. /** @hidden (Backing field) */
  54906. _forceShowBoundingBoxes: boolean;
  54907. /**
  54908. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54909. */
  54910. forceShowBoundingBoxes: boolean;
  54911. /**
  54912. * Gets the bounding box renderer associated with the scene
  54913. * @returns a BoundingBoxRenderer
  54914. */
  54915. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54916. }
  54917. }
  54918. module "babylonjs/Meshes/abstractMesh" {
  54919. interface AbstractMesh {
  54920. /** @hidden (Backing field) */
  54921. _showBoundingBox: boolean;
  54922. /**
  54923. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54924. */
  54925. showBoundingBox: boolean;
  54926. }
  54927. }
  54928. /**
  54929. * Component responsible of rendering the bounding box of the meshes in a scene.
  54930. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54931. */
  54932. export class BoundingBoxRenderer implements ISceneComponent {
  54933. /**
  54934. * The component name helpfull to identify the component in the list of scene components.
  54935. */
  54936. readonly name: string;
  54937. /**
  54938. * The scene the component belongs to.
  54939. */
  54940. scene: Scene;
  54941. /**
  54942. * Color of the bounding box lines placed in front of an object
  54943. */
  54944. frontColor: Color3;
  54945. /**
  54946. * Color of the bounding box lines placed behind an object
  54947. */
  54948. backColor: Color3;
  54949. /**
  54950. * Defines if the renderer should show the back lines or not
  54951. */
  54952. showBackLines: boolean;
  54953. /**
  54954. * @hidden
  54955. */
  54956. renderList: SmartArray<BoundingBox>;
  54957. private _colorShader;
  54958. private _vertexBuffers;
  54959. private _indexBuffer;
  54960. /**
  54961. * Instantiates a new bounding box renderer in a scene.
  54962. * @param scene the scene the renderer renders in
  54963. */
  54964. constructor(scene: Scene);
  54965. /**
  54966. * Registers the component in a given scene
  54967. */
  54968. register(): void;
  54969. private _evaluateSubMesh;
  54970. private _activeMesh;
  54971. private _prepareRessources;
  54972. private _createIndexBuffer;
  54973. /**
  54974. * Rebuilds the elements related to this component in case of
  54975. * context lost for instance.
  54976. */
  54977. rebuild(): void;
  54978. /**
  54979. * @hidden
  54980. */
  54981. reset(): void;
  54982. /**
  54983. * Render the bounding boxes of a specific rendering group
  54984. * @param renderingGroupId defines the rendering group to render
  54985. */
  54986. render(renderingGroupId: number): void;
  54987. /**
  54988. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54989. * @param mesh Define the mesh to render the occlusion bounding box for
  54990. */
  54991. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54992. /**
  54993. * Dispose and release the resources attached to this renderer.
  54994. */
  54995. dispose(): void;
  54996. }
  54997. }
  54998. declare module "babylonjs/Shaders/depth.fragment" {
  54999. /** @hidden */
  55000. export var depthPixelShader: {
  55001. name: string;
  55002. shader: string;
  55003. };
  55004. }
  55005. declare module "babylonjs/Rendering/depthRenderer" {
  55006. import { Nullable } from "babylonjs/types";
  55007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55008. import { Scene } from "babylonjs/scene";
  55009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55010. import { Camera } from "babylonjs/Cameras/camera";
  55011. import "babylonjs/Shaders/depth.fragment";
  55012. import "babylonjs/Shaders/depth.vertex";
  55013. /**
  55014. * This represents a depth renderer in Babylon.
  55015. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55016. */
  55017. export class DepthRenderer {
  55018. private _scene;
  55019. private _depthMap;
  55020. private _effect;
  55021. private _cachedDefines;
  55022. private _camera;
  55023. /**
  55024. * Specifiess that the depth renderer will only be used within
  55025. * the camera it is created for.
  55026. * This can help forcing its rendering during the camera processing.
  55027. */
  55028. useOnlyInActiveCamera: boolean;
  55029. /** @hidden */
  55030. static _SceneComponentInitialization: (scene: Scene) => void;
  55031. /**
  55032. * Instantiates a depth renderer
  55033. * @param scene The scene the renderer belongs to
  55034. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55035. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55036. */
  55037. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55038. /**
  55039. * Creates the depth rendering effect and checks if the effect is ready.
  55040. * @param subMesh The submesh to be used to render the depth map of
  55041. * @param useInstances If multiple world instances should be used
  55042. * @returns if the depth renderer is ready to render the depth map
  55043. */
  55044. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55045. /**
  55046. * Gets the texture which the depth map will be written to.
  55047. * @returns The depth map texture
  55048. */
  55049. getDepthMap(): RenderTargetTexture;
  55050. /**
  55051. * Disposes of the depth renderer.
  55052. */
  55053. dispose(): void;
  55054. }
  55055. }
  55056. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55057. import { Nullable } from "babylonjs/types";
  55058. import { Scene } from "babylonjs/scene";
  55059. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55060. import { Camera } from "babylonjs/Cameras/camera";
  55061. import { ISceneComponent } from "babylonjs/sceneComponent";
  55062. module "babylonjs/scene" {
  55063. interface Scene {
  55064. /** @hidden (Backing field) */
  55065. _depthRenderer: {
  55066. [id: string]: DepthRenderer;
  55067. };
  55068. /**
  55069. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55070. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55071. * @returns the created depth renderer
  55072. */
  55073. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55074. /**
  55075. * Disables a depth renderer for a given camera
  55076. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55077. */
  55078. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55079. }
  55080. }
  55081. /**
  55082. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55083. * in several rendering techniques.
  55084. */
  55085. export class DepthRendererSceneComponent implements ISceneComponent {
  55086. /**
  55087. * The component name helpfull to identify the component in the list of scene components.
  55088. */
  55089. readonly name: string;
  55090. /**
  55091. * The scene the component belongs to.
  55092. */
  55093. scene: Scene;
  55094. /**
  55095. * Creates a new instance of the component for the given scene
  55096. * @param scene Defines the scene to register the component in
  55097. */
  55098. constructor(scene: Scene);
  55099. /**
  55100. * Registers the component in a given scene
  55101. */
  55102. register(): void;
  55103. /**
  55104. * Rebuilds the elements related to this component in case of
  55105. * context lost for instance.
  55106. */
  55107. rebuild(): void;
  55108. /**
  55109. * Disposes the component and the associated ressources
  55110. */
  55111. dispose(): void;
  55112. private _gatherRenderTargets;
  55113. private _gatherActiveCameraRenderTargets;
  55114. }
  55115. }
  55116. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55117. import { Nullable } from "babylonjs/types";
  55118. import { Scene } from "babylonjs/scene";
  55119. import { ISceneComponent } from "babylonjs/sceneComponent";
  55120. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55121. module "babylonjs/scene" {
  55122. interface Scene {
  55123. /** @hidden (Backing field) */
  55124. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55125. /**
  55126. * Gets or Sets the current geometry buffer associated to the scene.
  55127. */
  55128. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55129. /**
  55130. * Enables a GeometryBufferRender and associates it with the scene
  55131. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55132. * @returns the GeometryBufferRenderer
  55133. */
  55134. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55135. /**
  55136. * Disables the GeometryBufferRender associated with the scene
  55137. */
  55138. disableGeometryBufferRenderer(): void;
  55139. }
  55140. }
  55141. /**
  55142. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55143. * in several rendering techniques.
  55144. */
  55145. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55146. /**
  55147. * The component name helpful to identify the component in the list of scene components.
  55148. */
  55149. readonly name: string;
  55150. /**
  55151. * The scene the component belongs to.
  55152. */
  55153. scene: Scene;
  55154. /**
  55155. * Creates a new instance of the component for the given scene
  55156. * @param scene Defines the scene to register the component in
  55157. */
  55158. constructor(scene: Scene);
  55159. /**
  55160. * Registers the component in a given scene
  55161. */
  55162. register(): void;
  55163. /**
  55164. * Rebuilds the elements related to this component in case of
  55165. * context lost for instance.
  55166. */
  55167. rebuild(): void;
  55168. /**
  55169. * Disposes the component and the associated ressources
  55170. */
  55171. dispose(): void;
  55172. private _gatherRenderTargets;
  55173. }
  55174. }
  55175. declare module "babylonjs/Shaders/outline.fragment" {
  55176. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55177. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55178. /** @hidden */
  55179. export var outlinePixelShader: {
  55180. name: string;
  55181. shader: string;
  55182. };
  55183. }
  55184. declare module "babylonjs/Shaders/outline.vertex" {
  55185. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55186. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55187. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55188. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55189. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55190. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55191. /** @hidden */
  55192. export var outlineVertexShader: {
  55193. name: string;
  55194. shader: string;
  55195. };
  55196. }
  55197. declare module "babylonjs/Rendering/outlineRenderer" {
  55198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55199. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55200. import { Scene } from "babylonjs/scene";
  55201. import { ISceneComponent } from "babylonjs/sceneComponent";
  55202. import "babylonjs/Shaders/outline.fragment";
  55203. import "babylonjs/Shaders/outline.vertex";
  55204. module "babylonjs/scene" {
  55205. interface Scene {
  55206. /** @hidden */
  55207. _outlineRenderer: OutlineRenderer;
  55208. /**
  55209. * Gets the outline renderer associated with the scene
  55210. * @returns a OutlineRenderer
  55211. */
  55212. getOutlineRenderer(): OutlineRenderer;
  55213. }
  55214. }
  55215. module "babylonjs/Meshes/abstractMesh" {
  55216. interface AbstractMesh {
  55217. /** @hidden (Backing field) */
  55218. _renderOutline: boolean;
  55219. /**
  55220. * Gets or sets a boolean indicating if the outline must be rendered as well
  55221. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55222. */
  55223. renderOutline: boolean;
  55224. /** @hidden (Backing field) */
  55225. _renderOverlay: boolean;
  55226. /**
  55227. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55228. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55229. */
  55230. renderOverlay: boolean;
  55231. }
  55232. }
  55233. /**
  55234. * This class is responsible to draw bothe outline/overlay of meshes.
  55235. * It should not be used directly but through the available method on mesh.
  55236. */
  55237. export class OutlineRenderer implements ISceneComponent {
  55238. /**
  55239. * The name of the component. Each component must have a unique name.
  55240. */
  55241. name: string;
  55242. /**
  55243. * The scene the component belongs to.
  55244. */
  55245. scene: Scene;
  55246. /**
  55247. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55248. */
  55249. zOffset: number;
  55250. private _engine;
  55251. private _effect;
  55252. private _cachedDefines;
  55253. private _savedDepthWrite;
  55254. /**
  55255. * Instantiates a new outline renderer. (There could be only one per scene).
  55256. * @param scene Defines the scene it belongs to
  55257. */
  55258. constructor(scene: Scene);
  55259. /**
  55260. * Register the component to one instance of a scene.
  55261. */
  55262. register(): void;
  55263. /**
  55264. * Rebuilds the elements related to this component in case of
  55265. * context lost for instance.
  55266. */
  55267. rebuild(): void;
  55268. /**
  55269. * Disposes the component and the associated ressources.
  55270. */
  55271. dispose(): void;
  55272. /**
  55273. * Renders the outline in the canvas.
  55274. * @param subMesh Defines the sumesh to render
  55275. * @param batch Defines the batch of meshes in case of instances
  55276. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55277. */
  55278. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55279. /**
  55280. * Returns whether or not the outline renderer is ready for a given submesh.
  55281. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55282. * @param subMesh Defines the submesh to check readyness for
  55283. * @param useInstances Defines wheter wee are trying to render instances or not
  55284. * @returns true if ready otherwise false
  55285. */
  55286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55287. private _beforeRenderingMesh;
  55288. private _afterRenderingMesh;
  55289. }
  55290. }
  55291. declare module "babylonjs/Rendering/index" {
  55292. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55293. export * from "babylonjs/Rendering/depthRenderer";
  55294. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55295. export * from "babylonjs/Rendering/edgesRenderer";
  55296. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55297. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55298. export * from "babylonjs/Rendering/outlineRenderer";
  55299. export * from "babylonjs/Rendering/renderingGroup";
  55300. export * from "babylonjs/Rendering/renderingManager";
  55301. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55302. }
  55303. declare module "babylonjs/Sprites/index" {
  55304. export * from "babylonjs/Sprites/sprite";
  55305. export * from "babylonjs/Sprites/spriteManager";
  55306. export * from "babylonjs/Sprites/spriteSceneComponent";
  55307. }
  55308. declare module "babylonjs/Misc/assetsManager" {
  55309. import { Scene } from "babylonjs/scene";
  55310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55311. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55312. import { Skeleton } from "babylonjs/Bones/skeleton";
  55313. import { Observable } from "babylonjs/Misc/observable";
  55314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55315. import { Texture } from "babylonjs/Materials/Textures/texture";
  55316. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55317. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55318. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55319. /**
  55320. * Defines the list of states available for a task inside a AssetsManager
  55321. */
  55322. export enum AssetTaskState {
  55323. /**
  55324. * Initialization
  55325. */
  55326. INIT = 0,
  55327. /**
  55328. * Running
  55329. */
  55330. RUNNING = 1,
  55331. /**
  55332. * Done
  55333. */
  55334. DONE = 2,
  55335. /**
  55336. * Error
  55337. */
  55338. ERROR = 3
  55339. }
  55340. /**
  55341. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55342. */
  55343. export abstract class AbstractAssetTask {
  55344. /**
  55345. * Task name
  55346. */ name: string;
  55347. /**
  55348. * Callback called when the task is successful
  55349. */
  55350. onSuccess: (task: any) => void;
  55351. /**
  55352. * Callback called when the task is not successful
  55353. */
  55354. onError: (task: any, message?: string, exception?: any) => void;
  55355. /**
  55356. * Creates a new AssetsManager
  55357. * @param name defines the name of the task
  55358. */
  55359. constructor(
  55360. /**
  55361. * Task name
  55362. */ name: string);
  55363. private _isCompleted;
  55364. private _taskState;
  55365. private _errorObject;
  55366. /**
  55367. * Get if the task is completed
  55368. */
  55369. readonly isCompleted: boolean;
  55370. /**
  55371. * Gets the current state of the task
  55372. */
  55373. readonly taskState: AssetTaskState;
  55374. /**
  55375. * Gets the current error object (if task is in error)
  55376. */
  55377. readonly errorObject: {
  55378. message?: string;
  55379. exception?: any;
  55380. };
  55381. /**
  55382. * Internal only
  55383. * @hidden
  55384. */
  55385. _setErrorObject(message?: string, exception?: any): void;
  55386. /**
  55387. * Execute the current task
  55388. * @param scene defines the scene where you want your assets to be loaded
  55389. * @param onSuccess is a callback called when the task is successfully executed
  55390. * @param onError is a callback called if an error occurs
  55391. */
  55392. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55393. /**
  55394. * Execute the current task
  55395. * @param scene defines the scene where you want your assets to be loaded
  55396. * @param onSuccess is a callback called when the task is successfully executed
  55397. * @param onError is a callback called if an error occurs
  55398. */
  55399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55400. /**
  55401. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55402. * This can be used with failed tasks that have the reason for failure fixed.
  55403. */
  55404. reset(): void;
  55405. private onErrorCallback;
  55406. private onDoneCallback;
  55407. }
  55408. /**
  55409. * Define the interface used by progress events raised during assets loading
  55410. */
  55411. export interface IAssetsProgressEvent {
  55412. /**
  55413. * Defines the number of remaining tasks to process
  55414. */
  55415. remainingCount: number;
  55416. /**
  55417. * Defines the total number of tasks
  55418. */
  55419. totalCount: number;
  55420. /**
  55421. * Defines the task that was just processed
  55422. */
  55423. task: AbstractAssetTask;
  55424. }
  55425. /**
  55426. * Class used to share progress information about assets loading
  55427. */
  55428. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55429. /**
  55430. * Defines the number of remaining tasks to process
  55431. */
  55432. remainingCount: number;
  55433. /**
  55434. * Defines the total number of tasks
  55435. */
  55436. totalCount: number;
  55437. /**
  55438. * Defines the task that was just processed
  55439. */
  55440. task: AbstractAssetTask;
  55441. /**
  55442. * Creates a AssetsProgressEvent
  55443. * @param remainingCount defines the number of remaining tasks to process
  55444. * @param totalCount defines the total number of tasks
  55445. * @param task defines the task that was just processed
  55446. */
  55447. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55448. }
  55449. /**
  55450. * Define a task used by AssetsManager to load meshes
  55451. */
  55452. export class MeshAssetTask extends AbstractAssetTask {
  55453. /**
  55454. * Defines the name of the task
  55455. */
  55456. name: string;
  55457. /**
  55458. * Defines the list of mesh's names you want to load
  55459. */
  55460. meshesNames: any;
  55461. /**
  55462. * Defines the root url to use as a base to load your meshes and associated resources
  55463. */
  55464. rootUrl: string;
  55465. /**
  55466. * Defines the filename of the scene to load from
  55467. */
  55468. sceneFilename: string;
  55469. /**
  55470. * Gets the list of loaded meshes
  55471. */
  55472. loadedMeshes: Array<AbstractMesh>;
  55473. /**
  55474. * Gets the list of loaded particle systems
  55475. */
  55476. loadedParticleSystems: Array<IParticleSystem>;
  55477. /**
  55478. * Gets the list of loaded skeletons
  55479. */
  55480. loadedSkeletons: Array<Skeleton>;
  55481. /**
  55482. * Gets the list of loaded animation groups
  55483. */
  55484. loadedAnimationGroups: Array<AnimationGroup>;
  55485. /**
  55486. * Callback called when the task is successful
  55487. */
  55488. onSuccess: (task: MeshAssetTask) => void;
  55489. /**
  55490. * Callback called when the task is successful
  55491. */
  55492. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55493. /**
  55494. * Creates a new MeshAssetTask
  55495. * @param name defines the name of the task
  55496. * @param meshesNames defines the list of mesh's names you want to load
  55497. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55498. * @param sceneFilename defines the filename of the scene to load from
  55499. */
  55500. constructor(
  55501. /**
  55502. * Defines the name of the task
  55503. */
  55504. name: string,
  55505. /**
  55506. * Defines the list of mesh's names you want to load
  55507. */
  55508. meshesNames: any,
  55509. /**
  55510. * Defines the root url to use as a base to load your meshes and associated resources
  55511. */
  55512. rootUrl: string,
  55513. /**
  55514. * Defines the filename of the scene to load from
  55515. */
  55516. sceneFilename: string);
  55517. /**
  55518. * Execute the current task
  55519. * @param scene defines the scene where you want your assets to be loaded
  55520. * @param onSuccess is a callback called when the task is successfully executed
  55521. * @param onError is a callback called if an error occurs
  55522. */
  55523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55524. }
  55525. /**
  55526. * Define a task used by AssetsManager to load text content
  55527. */
  55528. export class TextFileAssetTask extends AbstractAssetTask {
  55529. /**
  55530. * Defines the name of the task
  55531. */
  55532. name: string;
  55533. /**
  55534. * Defines the location of the file to load
  55535. */
  55536. url: string;
  55537. /**
  55538. * Gets the loaded text string
  55539. */
  55540. text: string;
  55541. /**
  55542. * Callback called when the task is successful
  55543. */
  55544. onSuccess: (task: TextFileAssetTask) => void;
  55545. /**
  55546. * Callback called when the task is successful
  55547. */
  55548. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55549. /**
  55550. * Creates a new TextFileAssetTask object
  55551. * @param name defines the name of the task
  55552. * @param url defines the location of the file to load
  55553. */
  55554. constructor(
  55555. /**
  55556. * Defines the name of the task
  55557. */
  55558. name: string,
  55559. /**
  55560. * Defines the location of the file to load
  55561. */
  55562. url: string);
  55563. /**
  55564. * Execute the current task
  55565. * @param scene defines the scene where you want your assets to be loaded
  55566. * @param onSuccess is a callback called when the task is successfully executed
  55567. * @param onError is a callback called if an error occurs
  55568. */
  55569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55570. }
  55571. /**
  55572. * Define a task used by AssetsManager to load binary data
  55573. */
  55574. export class BinaryFileAssetTask extends AbstractAssetTask {
  55575. /**
  55576. * Defines the name of the task
  55577. */
  55578. name: string;
  55579. /**
  55580. * Defines the location of the file to load
  55581. */
  55582. url: string;
  55583. /**
  55584. * Gets the lodaded data (as an array buffer)
  55585. */
  55586. data: ArrayBuffer;
  55587. /**
  55588. * Callback called when the task is successful
  55589. */
  55590. onSuccess: (task: BinaryFileAssetTask) => void;
  55591. /**
  55592. * Callback called when the task is successful
  55593. */
  55594. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55595. /**
  55596. * Creates a new BinaryFileAssetTask object
  55597. * @param name defines the name of the new task
  55598. * @param url defines the location of the file to load
  55599. */
  55600. constructor(
  55601. /**
  55602. * Defines the name of the task
  55603. */
  55604. name: string,
  55605. /**
  55606. * Defines the location of the file to load
  55607. */
  55608. url: string);
  55609. /**
  55610. * Execute the current task
  55611. * @param scene defines the scene where you want your assets to be loaded
  55612. * @param onSuccess is a callback called when the task is successfully executed
  55613. * @param onError is a callback called if an error occurs
  55614. */
  55615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55616. }
  55617. /**
  55618. * Define a task used by AssetsManager to load images
  55619. */
  55620. export class ImageAssetTask extends AbstractAssetTask {
  55621. /**
  55622. * Defines the name of the task
  55623. */
  55624. name: string;
  55625. /**
  55626. * Defines the location of the image to load
  55627. */
  55628. url: string;
  55629. /**
  55630. * Gets the loaded images
  55631. */
  55632. image: HTMLImageElement;
  55633. /**
  55634. * Callback called when the task is successful
  55635. */
  55636. onSuccess: (task: ImageAssetTask) => void;
  55637. /**
  55638. * Callback called when the task is successful
  55639. */
  55640. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55641. /**
  55642. * Creates a new ImageAssetTask
  55643. * @param name defines the name of the task
  55644. * @param url defines the location of the image to load
  55645. */
  55646. constructor(
  55647. /**
  55648. * Defines the name of the task
  55649. */
  55650. name: string,
  55651. /**
  55652. * Defines the location of the image to load
  55653. */
  55654. url: string);
  55655. /**
  55656. * Execute the current task
  55657. * @param scene defines the scene where you want your assets to be loaded
  55658. * @param onSuccess is a callback called when the task is successfully executed
  55659. * @param onError is a callback called if an error occurs
  55660. */
  55661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55662. }
  55663. /**
  55664. * Defines the interface used by texture loading tasks
  55665. */
  55666. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55667. /**
  55668. * Gets the loaded texture
  55669. */
  55670. texture: TEX;
  55671. }
  55672. /**
  55673. * Define a task used by AssetsManager to load 2D textures
  55674. */
  55675. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55676. /**
  55677. * Defines the name of the task
  55678. */
  55679. name: string;
  55680. /**
  55681. * Defines the location of the file to load
  55682. */
  55683. url: string;
  55684. /**
  55685. * Defines if mipmap should not be generated (default is false)
  55686. */
  55687. noMipmap?: boolean | undefined;
  55688. /**
  55689. * Defines if texture must be inverted on Y axis (default is false)
  55690. */
  55691. invertY?: boolean | undefined;
  55692. /**
  55693. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55694. */
  55695. samplingMode: number;
  55696. /**
  55697. * Gets the loaded texture
  55698. */
  55699. texture: Texture;
  55700. /**
  55701. * Callback called when the task is successful
  55702. */
  55703. onSuccess: (task: TextureAssetTask) => void;
  55704. /**
  55705. * Callback called when the task is successful
  55706. */
  55707. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55708. /**
  55709. * Creates a new TextureAssetTask object
  55710. * @param name defines the name of the task
  55711. * @param url defines the location of the file to load
  55712. * @param noMipmap defines if mipmap should not be generated (default is false)
  55713. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55714. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55715. */
  55716. constructor(
  55717. /**
  55718. * Defines the name of the task
  55719. */
  55720. name: string,
  55721. /**
  55722. * Defines the location of the file to load
  55723. */
  55724. url: string,
  55725. /**
  55726. * Defines if mipmap should not be generated (default is false)
  55727. */
  55728. noMipmap?: boolean | undefined,
  55729. /**
  55730. * Defines if texture must be inverted on Y axis (default is false)
  55731. */
  55732. invertY?: boolean | undefined,
  55733. /**
  55734. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55735. */
  55736. samplingMode?: number);
  55737. /**
  55738. * Execute the current task
  55739. * @param scene defines the scene where you want your assets to be loaded
  55740. * @param onSuccess is a callback called when the task is successfully executed
  55741. * @param onError is a callback called if an error occurs
  55742. */
  55743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55744. }
  55745. /**
  55746. * Define a task used by AssetsManager to load cube textures
  55747. */
  55748. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55749. /**
  55750. * Defines the name of the task
  55751. */
  55752. name: string;
  55753. /**
  55754. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55755. */
  55756. url: string;
  55757. /**
  55758. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55759. */
  55760. extensions?: string[] | undefined;
  55761. /**
  55762. * Defines if mipmaps should not be generated (default is false)
  55763. */
  55764. noMipmap?: boolean | undefined;
  55765. /**
  55766. * Defines the explicit list of files (undefined by default)
  55767. */
  55768. files?: string[] | undefined;
  55769. /**
  55770. * Gets the loaded texture
  55771. */
  55772. texture: CubeTexture;
  55773. /**
  55774. * Callback called when the task is successful
  55775. */
  55776. onSuccess: (task: CubeTextureAssetTask) => void;
  55777. /**
  55778. * Callback called when the task is successful
  55779. */
  55780. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55781. /**
  55782. * Creates a new CubeTextureAssetTask
  55783. * @param name defines the name of the task
  55784. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55785. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55787. * @param files defines the explicit list of files (undefined by default)
  55788. */
  55789. constructor(
  55790. /**
  55791. * Defines the name of the task
  55792. */
  55793. name: string,
  55794. /**
  55795. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55796. */
  55797. url: string,
  55798. /**
  55799. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55800. */
  55801. extensions?: string[] | undefined,
  55802. /**
  55803. * Defines if mipmaps should not be generated (default is false)
  55804. */
  55805. noMipmap?: boolean | undefined,
  55806. /**
  55807. * Defines the explicit list of files (undefined by default)
  55808. */
  55809. files?: string[] | undefined);
  55810. /**
  55811. * Execute the current task
  55812. * @param scene defines the scene where you want your assets to be loaded
  55813. * @param onSuccess is a callback called when the task is successfully executed
  55814. * @param onError is a callback called if an error occurs
  55815. */
  55816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55817. }
  55818. /**
  55819. * Define a task used by AssetsManager to load HDR cube textures
  55820. */
  55821. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55822. /**
  55823. * Defines the name of the task
  55824. */
  55825. name: string;
  55826. /**
  55827. * Defines the location of the file to load
  55828. */
  55829. url: string;
  55830. /**
  55831. * Defines the desired size (the more it increases the longer the generation will be)
  55832. */
  55833. size: number;
  55834. /**
  55835. * Defines if mipmaps should not be generated (default is false)
  55836. */
  55837. noMipmap: boolean;
  55838. /**
  55839. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55840. */
  55841. generateHarmonics: boolean;
  55842. /**
  55843. * 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)
  55844. */
  55845. gammaSpace: boolean;
  55846. /**
  55847. * Internal Use Only
  55848. */
  55849. reserved: boolean;
  55850. /**
  55851. * Gets the loaded texture
  55852. */
  55853. texture: HDRCubeTexture;
  55854. /**
  55855. * Callback called when the task is successful
  55856. */
  55857. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55858. /**
  55859. * Callback called when the task is successful
  55860. */
  55861. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55862. /**
  55863. * Creates a new HDRCubeTextureAssetTask object
  55864. * @param name defines the name of the task
  55865. * @param url defines the location of the file to load
  55866. * @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.
  55867. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55868. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55869. * @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)
  55870. * @param reserved Internal use only
  55871. */
  55872. constructor(
  55873. /**
  55874. * Defines the name of the task
  55875. */
  55876. name: string,
  55877. /**
  55878. * Defines the location of the file to load
  55879. */
  55880. url: string,
  55881. /**
  55882. * Defines the desired size (the more it increases the longer the generation will be)
  55883. */
  55884. size: number,
  55885. /**
  55886. * Defines if mipmaps should not be generated (default is false)
  55887. */
  55888. noMipmap?: boolean,
  55889. /**
  55890. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55891. */
  55892. generateHarmonics?: boolean,
  55893. /**
  55894. * 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)
  55895. */
  55896. gammaSpace?: boolean,
  55897. /**
  55898. * Internal Use Only
  55899. */
  55900. reserved?: boolean);
  55901. /**
  55902. * Execute the current task
  55903. * @param scene defines the scene where you want your assets to be loaded
  55904. * @param onSuccess is a callback called when the task is successfully executed
  55905. * @param onError is a callback called if an error occurs
  55906. */
  55907. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55908. }
  55909. /**
  55910. * This class can be used to easily import assets into a scene
  55911. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55912. */
  55913. export class AssetsManager {
  55914. private _scene;
  55915. private _isLoading;
  55916. protected _tasks: AbstractAssetTask[];
  55917. protected _waitingTasksCount: number;
  55918. protected _totalTasksCount: number;
  55919. /**
  55920. * Callback called when all tasks are processed
  55921. */
  55922. onFinish: (tasks: AbstractAssetTask[]) => void;
  55923. /**
  55924. * Callback called when a task is successful
  55925. */
  55926. onTaskSuccess: (task: AbstractAssetTask) => void;
  55927. /**
  55928. * Callback called when a task had an error
  55929. */
  55930. onTaskError: (task: AbstractAssetTask) => void;
  55931. /**
  55932. * Callback called when a task is done (whatever the result is)
  55933. */
  55934. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55935. /**
  55936. * Observable called when all tasks are processed
  55937. */
  55938. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55939. /**
  55940. * Observable called when a task had an error
  55941. */
  55942. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55943. /**
  55944. * Observable called when a task is successful
  55945. */
  55946. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55947. /**
  55948. * Observable called when a task is done (whatever the result is)
  55949. */
  55950. onProgressObservable: Observable<IAssetsProgressEvent>;
  55951. /**
  55952. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55953. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55954. */
  55955. useDefaultLoadingScreen: boolean;
  55956. /**
  55957. * Creates a new AssetsManager
  55958. * @param scene defines the scene to work on
  55959. */
  55960. constructor(scene: Scene);
  55961. /**
  55962. * Add a MeshAssetTask to the list of active tasks
  55963. * @param taskName defines the name of the new task
  55964. * @param meshesNames defines the name of meshes to load
  55965. * @param rootUrl defines the root url to use to locate files
  55966. * @param sceneFilename defines the filename of the scene file
  55967. * @returns a new MeshAssetTask object
  55968. */
  55969. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55970. /**
  55971. * Add a TextFileAssetTask to the list of active tasks
  55972. * @param taskName defines the name of the new task
  55973. * @param url defines the url of the file to load
  55974. * @returns a new TextFileAssetTask object
  55975. */
  55976. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55977. /**
  55978. * Add a BinaryFileAssetTask to the list of active tasks
  55979. * @param taskName defines the name of the new task
  55980. * @param url defines the url of the file to load
  55981. * @returns a new BinaryFileAssetTask object
  55982. */
  55983. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55984. /**
  55985. * Add a ImageAssetTask to the list of active tasks
  55986. * @param taskName defines the name of the new task
  55987. * @param url defines the url of the file to load
  55988. * @returns a new ImageAssetTask object
  55989. */
  55990. addImageTask(taskName: string, url: string): ImageAssetTask;
  55991. /**
  55992. * Add a TextureAssetTask to the list of active tasks
  55993. * @param taskName defines the name of the new task
  55994. * @param url defines the url of the file to load
  55995. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55996. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55997. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55998. * @returns a new TextureAssetTask object
  55999. */
  56000. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56001. /**
  56002. * Add a CubeTextureAssetTask to the list of active tasks
  56003. * @param taskName defines the name of the new task
  56004. * @param url defines the url of the file to load
  56005. * @param extensions defines the extension to use to load the cube map (can be null)
  56006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56007. * @param files defines the list of files to load (can be null)
  56008. * @returns a new CubeTextureAssetTask object
  56009. */
  56010. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56011. /**
  56012. *
  56013. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56014. * @param taskName defines the name of the new task
  56015. * @param url defines the url of the file to load
  56016. * @param size defines the size you want for the cubemap (can be null)
  56017. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56018. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56019. * @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)
  56020. * @param reserved Internal use only
  56021. * @returns a new HDRCubeTextureAssetTask object
  56022. */
  56023. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56024. /**
  56025. * Remove a task from the assets manager.
  56026. * @param task the task to remove
  56027. */
  56028. removeTask(task: AbstractAssetTask): void;
  56029. private _decreaseWaitingTasksCount;
  56030. private _runTask;
  56031. /**
  56032. * Reset the AssetsManager and remove all tasks
  56033. * @return the current instance of the AssetsManager
  56034. */
  56035. reset(): AssetsManager;
  56036. /**
  56037. * Start the loading process
  56038. * @return the current instance of the AssetsManager
  56039. */
  56040. load(): AssetsManager;
  56041. }
  56042. }
  56043. declare module "babylonjs/Misc/deferred" {
  56044. /**
  56045. * Wrapper class for promise with external resolve and reject.
  56046. */
  56047. export class Deferred<T> {
  56048. /**
  56049. * The promise associated with this deferred object.
  56050. */
  56051. readonly promise: Promise<T>;
  56052. private _resolve;
  56053. private _reject;
  56054. /**
  56055. * The resolve method of the promise associated with this deferred object.
  56056. */
  56057. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56058. /**
  56059. * The reject method of the promise associated with this deferred object.
  56060. */
  56061. readonly reject: (reason?: any) => void;
  56062. /**
  56063. * Constructor for this deferred object.
  56064. */
  56065. constructor();
  56066. }
  56067. }
  56068. declare module "babylonjs/Misc/filesInput" {
  56069. import { Engine } from "babylonjs/Engines/engine";
  56070. import { Scene } from "babylonjs/scene";
  56071. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56072. /**
  56073. * Class used to help managing file picking and drag'n'drop
  56074. */
  56075. export class FilesInput {
  56076. /**
  56077. * List of files ready to be loaded
  56078. */
  56079. static readonly FilesToLoad: {
  56080. [key: string]: File;
  56081. };
  56082. /**
  56083. * Callback called when a file is processed
  56084. */
  56085. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56086. private _engine;
  56087. private _currentScene;
  56088. private _sceneLoadedCallback;
  56089. private _progressCallback;
  56090. private _additionalRenderLoopLogicCallback;
  56091. private _textureLoadingCallback;
  56092. private _startingProcessingFilesCallback;
  56093. private _onReloadCallback;
  56094. private _errorCallback;
  56095. private _elementToMonitor;
  56096. private _sceneFileToLoad;
  56097. private _filesToLoad;
  56098. /**
  56099. * Creates a new FilesInput
  56100. * @param engine defines the rendering engine
  56101. * @param scene defines the hosting scene
  56102. * @param sceneLoadedCallback callback called when scene is loaded
  56103. * @param progressCallback callback called to track progress
  56104. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56105. * @param textureLoadingCallback callback called when a texture is loading
  56106. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56107. * @param onReloadCallback callback called when a reload is requested
  56108. * @param errorCallback callback call if an error occurs
  56109. */
  56110. 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);
  56111. private _dragEnterHandler;
  56112. private _dragOverHandler;
  56113. private _dropHandler;
  56114. /**
  56115. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56116. * @param elementToMonitor defines the DOM element to track
  56117. */
  56118. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56119. /**
  56120. * Release all associated resources
  56121. */
  56122. dispose(): void;
  56123. private renderFunction;
  56124. private drag;
  56125. private drop;
  56126. private _traverseFolder;
  56127. private _processFiles;
  56128. /**
  56129. * Load files from a drop event
  56130. * @param event defines the drop event to use as source
  56131. */
  56132. loadFiles(event: any): void;
  56133. private _processReload;
  56134. /**
  56135. * Reload the current scene from the loaded files
  56136. */
  56137. reload(): void;
  56138. }
  56139. }
  56140. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56141. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56142. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56143. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56144. }
  56145. declare module "babylonjs/Misc/sceneOptimizer" {
  56146. import { Scene, IDisposable } from "babylonjs/scene";
  56147. import { Observable } from "babylonjs/Misc/observable";
  56148. /**
  56149. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56151. */
  56152. export class SceneOptimization {
  56153. /**
  56154. * Defines the priority of this optimization (0 by default which means first in the list)
  56155. */
  56156. priority: number;
  56157. /**
  56158. * Gets a string describing the action executed by the current optimization
  56159. * @returns description string
  56160. */
  56161. getDescription(): string;
  56162. /**
  56163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56164. * @param scene defines the current scene where to apply this optimization
  56165. * @param optimizer defines the current optimizer
  56166. * @returns true if everything that can be done was applied
  56167. */
  56168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56169. /**
  56170. * Creates the SceneOptimization object
  56171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56172. * @param desc defines the description associated with the optimization
  56173. */
  56174. constructor(
  56175. /**
  56176. * Defines the priority of this optimization (0 by default which means first in the list)
  56177. */
  56178. priority?: number);
  56179. }
  56180. /**
  56181. * Defines an optimization used to reduce the size of render target textures
  56182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56183. */
  56184. export class TextureOptimization extends SceneOptimization {
  56185. /**
  56186. * Defines the priority of this optimization (0 by default which means first in the list)
  56187. */
  56188. priority: number;
  56189. /**
  56190. * 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
  56191. */
  56192. maximumSize: number;
  56193. /**
  56194. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56195. */
  56196. step: number;
  56197. /**
  56198. * Gets a string describing the action executed by the current optimization
  56199. * @returns description string
  56200. */
  56201. getDescription(): string;
  56202. /**
  56203. * Creates the TextureOptimization object
  56204. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56205. * @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
  56206. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56207. */
  56208. constructor(
  56209. /**
  56210. * Defines the priority of this optimization (0 by default which means first in the list)
  56211. */
  56212. priority?: number,
  56213. /**
  56214. * 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
  56215. */
  56216. maximumSize?: number,
  56217. /**
  56218. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56219. */
  56220. step?: number);
  56221. /**
  56222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56223. * @param scene defines the current scene where to apply this optimization
  56224. * @param optimizer defines the current optimizer
  56225. * @returns true if everything that can be done was applied
  56226. */
  56227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56228. }
  56229. /**
  56230. * Defines an optimization used to increase or decrease the rendering resolution
  56231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56232. */
  56233. export class HardwareScalingOptimization extends SceneOptimization {
  56234. /**
  56235. * Defines the priority of this optimization (0 by default which means first in the list)
  56236. */
  56237. priority: number;
  56238. /**
  56239. * Defines the maximum scale to use (2 by default)
  56240. */
  56241. maximumScale: number;
  56242. /**
  56243. * Defines the step to use between two passes (0.5 by default)
  56244. */
  56245. step: number;
  56246. private _currentScale;
  56247. private _directionOffset;
  56248. /**
  56249. * Gets a string describing the action executed by the current optimization
  56250. * @return description string
  56251. */
  56252. getDescription(): string;
  56253. /**
  56254. * Creates the HardwareScalingOptimization object
  56255. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56256. * @param maximumScale defines the maximum scale to use (2 by default)
  56257. * @param step defines the step to use between two passes (0.5 by default)
  56258. */
  56259. constructor(
  56260. /**
  56261. * Defines the priority of this optimization (0 by default which means first in the list)
  56262. */
  56263. priority?: number,
  56264. /**
  56265. * Defines the maximum scale to use (2 by default)
  56266. */
  56267. maximumScale?: number,
  56268. /**
  56269. * Defines the step to use between two passes (0.5 by default)
  56270. */
  56271. step?: number);
  56272. /**
  56273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56274. * @param scene defines the current scene where to apply this optimization
  56275. * @param optimizer defines the current optimizer
  56276. * @returns true if everything that can be done was applied
  56277. */
  56278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56279. }
  56280. /**
  56281. * Defines an optimization used to remove shadows
  56282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56283. */
  56284. export class ShadowsOptimization extends SceneOptimization {
  56285. /**
  56286. * Gets a string describing the action executed by the current optimization
  56287. * @return description string
  56288. */
  56289. getDescription(): string;
  56290. /**
  56291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56292. * @param scene defines the current scene where to apply this optimization
  56293. * @param optimizer defines the current optimizer
  56294. * @returns true if everything that can be done was applied
  56295. */
  56296. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56297. }
  56298. /**
  56299. * Defines an optimization used to turn post-processes off
  56300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56301. */
  56302. export class PostProcessesOptimization extends SceneOptimization {
  56303. /**
  56304. * Gets a string describing the action executed by the current optimization
  56305. * @return description string
  56306. */
  56307. getDescription(): string;
  56308. /**
  56309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56310. * @param scene defines the current scene where to apply this optimization
  56311. * @param optimizer defines the current optimizer
  56312. * @returns true if everything that can be done was applied
  56313. */
  56314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56315. }
  56316. /**
  56317. * Defines an optimization used to turn lens flares off
  56318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56319. */
  56320. export class LensFlaresOptimization extends SceneOptimization {
  56321. /**
  56322. * Gets a string describing the action executed by the current optimization
  56323. * @return description string
  56324. */
  56325. getDescription(): string;
  56326. /**
  56327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56328. * @param scene defines the current scene where to apply this optimization
  56329. * @param optimizer defines the current optimizer
  56330. * @returns true if everything that can be done was applied
  56331. */
  56332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56333. }
  56334. /**
  56335. * Defines an optimization based on user defined callback.
  56336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56337. */
  56338. export class CustomOptimization extends SceneOptimization {
  56339. /**
  56340. * Callback called to apply the custom optimization.
  56341. */
  56342. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56343. /**
  56344. * Callback called to get custom description
  56345. */
  56346. onGetDescription: () => string;
  56347. /**
  56348. * Gets a string describing the action executed by the current optimization
  56349. * @returns description string
  56350. */
  56351. getDescription(): string;
  56352. /**
  56353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56354. * @param scene defines the current scene where to apply this optimization
  56355. * @param optimizer defines the current optimizer
  56356. * @returns true if everything that can be done was applied
  56357. */
  56358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56359. }
  56360. /**
  56361. * Defines an optimization used to turn particles off
  56362. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56363. */
  56364. export class ParticlesOptimization extends SceneOptimization {
  56365. /**
  56366. * Gets a string describing the action executed by the current optimization
  56367. * @return description string
  56368. */
  56369. getDescription(): string;
  56370. /**
  56371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56372. * @param scene defines the current scene where to apply this optimization
  56373. * @param optimizer defines the current optimizer
  56374. * @returns true if everything that can be done was applied
  56375. */
  56376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56377. }
  56378. /**
  56379. * Defines an optimization used to turn render targets off
  56380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56381. */
  56382. export class RenderTargetsOptimization extends SceneOptimization {
  56383. /**
  56384. * Gets a string describing the action executed by the current optimization
  56385. * @return description string
  56386. */
  56387. getDescription(): string;
  56388. /**
  56389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56390. * @param scene defines the current scene where to apply this optimization
  56391. * @param optimizer defines the current optimizer
  56392. * @returns true if everything that can be done was applied
  56393. */
  56394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56395. }
  56396. /**
  56397. * Defines an optimization used to merge meshes with compatible materials
  56398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56399. */
  56400. export class MergeMeshesOptimization extends SceneOptimization {
  56401. private static _UpdateSelectionTree;
  56402. /**
  56403. * Gets or sets a boolean which defines if optimization octree has to be updated
  56404. */
  56405. /**
  56406. * Gets or sets a boolean which defines if optimization octree has to be updated
  56407. */
  56408. static UpdateSelectionTree: boolean;
  56409. /**
  56410. * Gets a string describing the action executed by the current optimization
  56411. * @return description string
  56412. */
  56413. getDescription(): string;
  56414. private _canBeMerged;
  56415. /**
  56416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56417. * @param scene defines the current scene where to apply this optimization
  56418. * @param optimizer defines the current optimizer
  56419. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56420. * @returns true if everything that can be done was applied
  56421. */
  56422. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56423. }
  56424. /**
  56425. * Defines a list of options used by SceneOptimizer
  56426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56427. */
  56428. export class SceneOptimizerOptions {
  56429. /**
  56430. * Defines the target frame rate to reach (60 by default)
  56431. */
  56432. targetFrameRate: number;
  56433. /**
  56434. * Defines the interval between two checkes (2000ms by default)
  56435. */
  56436. trackerDuration: number;
  56437. /**
  56438. * Gets the list of optimizations to apply
  56439. */
  56440. optimizations: SceneOptimization[];
  56441. /**
  56442. * Creates a new list of options used by SceneOptimizer
  56443. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56444. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56445. */
  56446. constructor(
  56447. /**
  56448. * Defines the target frame rate to reach (60 by default)
  56449. */
  56450. targetFrameRate?: number,
  56451. /**
  56452. * Defines the interval between two checkes (2000ms by default)
  56453. */
  56454. trackerDuration?: number);
  56455. /**
  56456. * Add a new optimization
  56457. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56458. * @returns the current SceneOptimizerOptions
  56459. */
  56460. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56461. /**
  56462. * Add a new custom optimization
  56463. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56464. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56466. * @returns the current SceneOptimizerOptions
  56467. */
  56468. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56469. /**
  56470. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56471. * @param targetFrameRate defines the target frame rate (60 by default)
  56472. * @returns a SceneOptimizerOptions object
  56473. */
  56474. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56475. /**
  56476. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56477. * @param targetFrameRate defines the target frame rate (60 by default)
  56478. * @returns a SceneOptimizerOptions object
  56479. */
  56480. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56481. /**
  56482. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56483. * @param targetFrameRate defines the target frame rate (60 by default)
  56484. * @returns a SceneOptimizerOptions object
  56485. */
  56486. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56487. }
  56488. /**
  56489. * Class used to run optimizations in order to reach a target frame rate
  56490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56491. */
  56492. export class SceneOptimizer implements IDisposable {
  56493. private _isRunning;
  56494. private _options;
  56495. private _scene;
  56496. private _currentPriorityLevel;
  56497. private _targetFrameRate;
  56498. private _trackerDuration;
  56499. private _currentFrameRate;
  56500. private _sceneDisposeObserver;
  56501. private _improvementMode;
  56502. /**
  56503. * Defines an observable called when the optimizer reaches the target frame rate
  56504. */
  56505. onSuccessObservable: Observable<SceneOptimizer>;
  56506. /**
  56507. * Defines an observable called when the optimizer enables an optimization
  56508. */
  56509. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56510. /**
  56511. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56512. */
  56513. onFailureObservable: Observable<SceneOptimizer>;
  56514. /**
  56515. * Gets a boolean indicating if the optimizer is in improvement mode
  56516. */
  56517. readonly isInImprovementMode: boolean;
  56518. /**
  56519. * Gets the current priority level (0 at start)
  56520. */
  56521. readonly currentPriorityLevel: number;
  56522. /**
  56523. * Gets the current frame rate checked by the SceneOptimizer
  56524. */
  56525. readonly currentFrameRate: number;
  56526. /**
  56527. * Gets or sets the current target frame rate (60 by default)
  56528. */
  56529. /**
  56530. * Gets or sets the current target frame rate (60 by default)
  56531. */
  56532. targetFrameRate: number;
  56533. /**
  56534. * Gets or sets the current interval between two checks (every 2000ms by default)
  56535. */
  56536. /**
  56537. * Gets or sets the current interval between two checks (every 2000ms by default)
  56538. */
  56539. trackerDuration: number;
  56540. /**
  56541. * Gets the list of active optimizations
  56542. */
  56543. readonly optimizations: SceneOptimization[];
  56544. /**
  56545. * Creates a new SceneOptimizer
  56546. * @param scene defines the scene to work on
  56547. * @param options defines the options to use with the SceneOptimizer
  56548. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56549. * @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)
  56550. */
  56551. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56552. /**
  56553. * Stops the current optimizer
  56554. */
  56555. stop(): void;
  56556. /**
  56557. * Reset the optimizer to initial step (current priority level = 0)
  56558. */
  56559. reset(): void;
  56560. /**
  56561. * Start the optimizer. By default it will try to reach a specific framerate
  56562. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56563. */
  56564. start(): void;
  56565. private _checkCurrentState;
  56566. /**
  56567. * Release all resources
  56568. */
  56569. dispose(): void;
  56570. /**
  56571. * Helper function to create a SceneOptimizer with one single line of code
  56572. * @param scene defines the scene to work on
  56573. * @param options defines the options to use with the SceneOptimizer
  56574. * @param onSuccess defines a callback to call on success
  56575. * @param onFailure defines a callback to call on failure
  56576. * @returns the new SceneOptimizer object
  56577. */
  56578. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56579. }
  56580. }
  56581. declare module "babylonjs/Misc/sceneSerializer" {
  56582. import { Scene } from "babylonjs/scene";
  56583. /**
  56584. * Class used to serialize a scene into a string
  56585. */
  56586. export class SceneSerializer {
  56587. /**
  56588. * Clear cache used by a previous serialization
  56589. */
  56590. static ClearCache(): void;
  56591. /**
  56592. * Serialize a scene into a JSON compatible object
  56593. * @param scene defines the scene to serialize
  56594. * @returns a JSON compatible object
  56595. */
  56596. static Serialize(scene: Scene): any;
  56597. /**
  56598. * Serialize a mesh into a JSON compatible object
  56599. * @param toSerialize defines the mesh to serialize
  56600. * @param withParents defines if parents must be serialized as well
  56601. * @param withChildren defines if children must be serialized as well
  56602. * @returns a JSON compatible object
  56603. */
  56604. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56605. }
  56606. }
  56607. declare module "babylonjs/Misc/videoRecorder" {
  56608. import { Nullable } from "babylonjs/types";
  56609. import { Engine } from "babylonjs/Engines/engine";
  56610. /**
  56611. * This represents the different options avilable for the video capture.
  56612. */
  56613. export interface VideoRecorderOptions {
  56614. /** Defines the mime type of the video */
  56615. mimeType: string;
  56616. /** Defines the video the video should be recorded at */
  56617. fps: number;
  56618. /** Defines the chunk size for the recording data */
  56619. recordChunckSize: number;
  56620. /** The audio tracks to attach to the record */
  56621. audioTracks?: MediaStreamTrack[];
  56622. }
  56623. /**
  56624. * This can helps recording videos from BabylonJS.
  56625. * This is based on the available WebRTC functionalities of the browser.
  56626. *
  56627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56628. */
  56629. export class VideoRecorder {
  56630. private static readonly _defaultOptions;
  56631. /**
  56632. * Returns wehther or not the VideoRecorder is available in your browser.
  56633. * @param engine Defines the Babylon Engine to check the support for
  56634. * @returns true if supported otherwise false
  56635. */
  56636. static IsSupported(engine: Engine): boolean;
  56637. private readonly _options;
  56638. private _canvas;
  56639. private _mediaRecorder;
  56640. private _recordedChunks;
  56641. private _fileName;
  56642. private _resolve;
  56643. private _reject;
  56644. /**
  56645. * True wether a recording is already in progress.
  56646. */
  56647. readonly isRecording: boolean;
  56648. /**
  56649. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56650. * a video file.
  56651. * @param engine Defines the BabylonJS Engine you wish to record
  56652. * @param options Defines options that can be used to customized the capture
  56653. */
  56654. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56655. /**
  56656. * Stops the current recording before the default capture timeout passed in the startRecording
  56657. * functions.
  56658. */
  56659. stopRecording(): void;
  56660. /**
  56661. * Starts recording the canvas for a max duration specified in parameters.
  56662. * @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.
  56663. * @param maxDuration Defines the maximum recording time in seconds.
  56664. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56665. * @return a promise callback at the end of the recording with the video data in Blob.
  56666. */
  56667. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56668. /**
  56669. * Releases internal resources used during the recording.
  56670. */
  56671. dispose(): void;
  56672. private _handleDataAvailable;
  56673. private _handleError;
  56674. private _handleStop;
  56675. }
  56676. }
  56677. declare module "babylonjs/Misc/workerPool" {
  56678. import { IDisposable } from "babylonjs/scene";
  56679. /**
  56680. * Helper class to push actions to a pool of workers.
  56681. */
  56682. export class WorkerPool implements IDisposable {
  56683. private _workerInfos;
  56684. private _pendingActions;
  56685. /**
  56686. * Constructor
  56687. * @param workers Array of workers to use for actions
  56688. */
  56689. constructor(workers: Array<Worker>);
  56690. /**
  56691. * Terminates all workers and clears any pending actions.
  56692. */
  56693. dispose(): void;
  56694. /**
  56695. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56696. * pended until a worker has completed its action.
  56697. * @param action The action to perform. Call onComplete when the action is complete.
  56698. */
  56699. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56700. private _execute;
  56701. }
  56702. }
  56703. declare module "babylonjs/Misc/screenshotTools" {
  56704. import { Camera } from "babylonjs/Cameras/camera";
  56705. import { Engine } from "babylonjs/Engines/engine";
  56706. /**
  56707. * Class containing a set of static utilities functions for screenshots
  56708. */
  56709. export class ScreenshotTools {
  56710. /**
  56711. * Captures a screenshot of the current rendering
  56712. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56713. * @param engine defines the rendering engine
  56714. * @param camera defines the source camera
  56715. * @param size This parameter can be set to a single number or to an object with the
  56716. * following (optional) properties: precision, width, height. If a single number is passed,
  56717. * it will be used for both width and height. If an object is passed, the screenshot size
  56718. * will be derived from the parameters. The precision property is a multiplier allowing
  56719. * rendering at a higher or lower resolution
  56720. * @param successCallback defines the callback receives a single parameter which contains the
  56721. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56722. * src parameter of an <img> to display it
  56723. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56724. * Check your browser for supported MIME types
  56725. */
  56726. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56727. /**
  56728. * Generates an image screenshot from the specified camera.
  56729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56730. * @param engine The engine to use for rendering
  56731. * @param camera The camera to use for rendering
  56732. * @param size This parameter can be set to a single number or to an object with the
  56733. * following (optional) properties: precision, width, height. If a single number is passed,
  56734. * it will be used for both width and height. If an object is passed, the screenshot size
  56735. * will be derived from the parameters. The precision property is a multiplier allowing
  56736. * rendering at a higher or lower resolution
  56737. * @param successCallback The callback receives a single parameter which contains the
  56738. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56739. * src parameter of an <img> to display it
  56740. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56741. * Check your browser for supported MIME types
  56742. * @param samples Texture samples (default: 1)
  56743. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56744. * @param fileName A name for for the downloaded file.
  56745. */
  56746. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56747. }
  56748. }
  56749. declare module "babylonjs/Misc/index" {
  56750. export * from "babylonjs/Misc/andOrNotEvaluator";
  56751. export * from "babylonjs/Misc/assetsManager";
  56752. export * from "babylonjs/Misc/dds";
  56753. export * from "babylonjs/Misc/decorators";
  56754. export * from "babylonjs/Misc/deferred";
  56755. export * from "babylonjs/Misc/environmentTextureTools";
  56756. export * from "babylonjs/Misc/filesInput";
  56757. export * from "babylonjs/Misc/HighDynamicRange/index";
  56758. export * from "babylonjs/Misc/khronosTextureContainer";
  56759. export * from "babylonjs/Misc/observable";
  56760. export * from "babylonjs/Misc/performanceMonitor";
  56761. export * from "babylonjs/Misc/promise";
  56762. export * from "babylonjs/Misc/sceneOptimizer";
  56763. export * from "babylonjs/Misc/sceneSerializer";
  56764. export * from "babylonjs/Misc/smartArray";
  56765. export * from "babylonjs/Misc/stringDictionary";
  56766. export * from "babylonjs/Misc/tags";
  56767. export * from "babylonjs/Misc/textureTools";
  56768. export * from "babylonjs/Misc/tga";
  56769. export * from "babylonjs/Misc/tools";
  56770. export * from "babylonjs/Misc/videoRecorder";
  56771. export * from "babylonjs/Misc/virtualJoystick";
  56772. export * from "babylonjs/Misc/workerPool";
  56773. export * from "babylonjs/Misc/logger";
  56774. export * from "babylonjs/Misc/typeStore";
  56775. export * from "babylonjs/Misc/filesInputStore";
  56776. export * from "babylonjs/Misc/deepCopier";
  56777. export * from "babylonjs/Misc/pivotTools";
  56778. export * from "babylonjs/Misc/precisionDate";
  56779. export * from "babylonjs/Misc/screenshotTools";
  56780. export * from "babylonjs/Misc/typeStore";
  56781. }
  56782. declare module "babylonjs/index" {
  56783. export * from "babylonjs/abstractScene";
  56784. export * from "babylonjs/Actions/index";
  56785. export * from "babylonjs/Animations/index";
  56786. export * from "babylonjs/assetContainer";
  56787. export * from "babylonjs/Audio/index";
  56788. export * from "babylonjs/Behaviors/index";
  56789. export * from "babylonjs/Bones/index";
  56790. export * from "babylonjs/Cameras/index";
  56791. export * from "babylonjs/Collisions/index";
  56792. export * from "babylonjs/Culling/index";
  56793. export * from "babylonjs/Debug/index";
  56794. export * from "babylonjs/Engines/index";
  56795. export * from "babylonjs/Events/index";
  56796. export * from "babylonjs/Gamepads/index";
  56797. export * from "babylonjs/Gizmos/index";
  56798. export * from "babylonjs/Helpers/index";
  56799. export * from "babylonjs/Instrumentation/index";
  56800. export * from "babylonjs/Layers/index";
  56801. export * from "babylonjs/LensFlares/index";
  56802. export * from "babylonjs/Lights/index";
  56803. export * from "babylonjs/Loading/index";
  56804. export * from "babylonjs/Materials/index";
  56805. export * from "babylonjs/Maths/index";
  56806. export * from "babylonjs/Meshes/index";
  56807. export * from "babylonjs/Morph/index";
  56808. export * from "babylonjs/node";
  56809. export * from "babylonjs/Offline/index";
  56810. export * from "babylonjs/Particles/index";
  56811. export * from "babylonjs/Physics/index";
  56812. export * from "babylonjs/PostProcesses/index";
  56813. export * from "babylonjs/Probes/index";
  56814. export * from "babylonjs/Rendering/index";
  56815. export * from "babylonjs/scene";
  56816. export * from "babylonjs/sceneComponent";
  56817. export * from "babylonjs/Sprites/index";
  56818. export * from "babylonjs/States/index";
  56819. export * from "babylonjs/Misc/index";
  56820. export * from "babylonjs/types";
  56821. }
  56822. declare module "babylonjs/Animations/pathCursor" {
  56823. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56824. /**
  56825. * A cursor which tracks a point on a path
  56826. */
  56827. export class PathCursor {
  56828. private path;
  56829. /**
  56830. * Stores path cursor callbacks for when an onchange event is triggered
  56831. */
  56832. private _onchange;
  56833. /**
  56834. * The value of the path cursor
  56835. */
  56836. value: number;
  56837. /**
  56838. * The animation array of the path cursor
  56839. */
  56840. animations: Animation[];
  56841. /**
  56842. * Initializes the path cursor
  56843. * @param path The path to track
  56844. */
  56845. constructor(path: Path2);
  56846. /**
  56847. * Gets the cursor point on the path
  56848. * @returns A point on the path cursor at the cursor location
  56849. */
  56850. getPoint(): Vector3;
  56851. /**
  56852. * Moves the cursor ahead by the step amount
  56853. * @param step The amount to move the cursor forward
  56854. * @returns This path cursor
  56855. */
  56856. moveAhead(step?: number): PathCursor;
  56857. /**
  56858. * Moves the cursor behind by the step amount
  56859. * @param step The amount to move the cursor back
  56860. * @returns This path cursor
  56861. */
  56862. moveBack(step?: number): PathCursor;
  56863. /**
  56864. * Moves the cursor by the step amount
  56865. * If the step amount is greater than one, an exception is thrown
  56866. * @param step The amount to move the cursor
  56867. * @returns This path cursor
  56868. */
  56869. move(step: number): PathCursor;
  56870. /**
  56871. * Ensures that the value is limited between zero and one
  56872. * @returns This path cursor
  56873. */
  56874. private ensureLimits;
  56875. /**
  56876. * Runs onchange callbacks on change (used by the animation engine)
  56877. * @returns This path cursor
  56878. */
  56879. private raiseOnChange;
  56880. /**
  56881. * Executes a function on change
  56882. * @param f A path cursor onchange callback
  56883. * @returns This path cursor
  56884. */
  56885. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56886. }
  56887. }
  56888. declare module "babylonjs/Legacy/legacy" {
  56889. import * as Babylon from "babylonjs/index";
  56890. export * from "babylonjs/index";
  56891. }
  56892. declare module "babylonjs/Shaders/blur.fragment" {
  56893. /** @hidden */
  56894. export var blurPixelShader: {
  56895. name: string;
  56896. shader: string;
  56897. };
  56898. }
  56899. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56900. /** @hidden */
  56901. export var bones300Declaration: {
  56902. name: string;
  56903. shader: string;
  56904. };
  56905. }
  56906. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56907. /** @hidden */
  56908. export var instances300Declaration: {
  56909. name: string;
  56910. shader: string;
  56911. };
  56912. }
  56913. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56914. /** @hidden */
  56915. export var pointCloudVertexDeclaration: {
  56916. name: string;
  56917. shader: string;
  56918. };
  56919. }
  56920. // Mixins
  56921. interface Window {
  56922. mozIndexedDB: IDBFactory;
  56923. webkitIndexedDB: IDBFactory;
  56924. msIndexedDB: IDBFactory;
  56925. webkitURL: typeof URL;
  56926. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56927. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56928. WebGLRenderingContext: WebGLRenderingContext;
  56929. MSGesture: MSGesture;
  56930. CANNON: any;
  56931. AudioContext: AudioContext;
  56932. webkitAudioContext: AudioContext;
  56933. PointerEvent: any;
  56934. Math: Math;
  56935. Uint8Array: Uint8ArrayConstructor;
  56936. Float32Array: Float32ArrayConstructor;
  56937. mozURL: typeof URL;
  56938. msURL: typeof URL;
  56939. VRFrameData: any; // WebVR, from specs 1.1
  56940. DracoDecoderModule: any;
  56941. setImmediate(handler: (...args: any[]) => void): number;
  56942. }
  56943. interface Document {
  56944. mozCancelFullScreen(): void;
  56945. msCancelFullScreen(): void;
  56946. webkitCancelFullScreen(): void;
  56947. requestPointerLock(): void;
  56948. exitPointerLock(): void;
  56949. mozFullScreen: boolean;
  56950. msIsFullScreen: boolean;
  56951. readonly webkitIsFullScreen: boolean;
  56952. readonly pointerLockElement: Element;
  56953. mozPointerLockElement: HTMLElement;
  56954. msPointerLockElement: HTMLElement;
  56955. webkitPointerLockElement: HTMLElement;
  56956. }
  56957. interface HTMLCanvasElement {
  56958. requestPointerLock(): void;
  56959. msRequestPointerLock?(): void;
  56960. mozRequestPointerLock?(): void;
  56961. webkitRequestPointerLock?(): void;
  56962. /** Track wether a record is in progress */
  56963. isRecording: boolean;
  56964. /** Capture Stream method defined by some browsers */
  56965. captureStream(fps?: number): MediaStream;
  56966. }
  56967. interface CanvasRenderingContext2D {
  56968. msImageSmoothingEnabled: boolean;
  56969. }
  56970. interface MouseEvent {
  56971. mozMovementX: number;
  56972. mozMovementY: number;
  56973. webkitMovementX: number;
  56974. webkitMovementY: number;
  56975. msMovementX: number;
  56976. msMovementY: number;
  56977. }
  56978. interface Navigator {
  56979. mozGetVRDevices: (any: any) => any;
  56980. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56981. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56982. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56983. webkitGetGamepads(): Gamepad[];
  56984. msGetGamepads(): Gamepad[];
  56985. webkitGamepads(): Gamepad[];
  56986. }
  56987. interface HTMLVideoElement {
  56988. mozSrcObject: any;
  56989. }
  56990. interface Math {
  56991. fround(x: number): number;
  56992. imul(a: number, b: number): number;
  56993. }
  56994. interface WebGLProgram {
  56995. context?: WebGLRenderingContext;
  56996. vertexShader?: WebGLShader;
  56997. fragmentShader?: WebGLShader;
  56998. isParallelCompiled: boolean;
  56999. onCompiled?: () => void;
  57000. }
  57001. interface WebGLRenderingContext {
  57002. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57003. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57004. vertexAttribDivisor(index: number, divisor: number): void;
  57005. createVertexArray(): any;
  57006. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57007. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57008. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57009. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57010. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57011. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57012. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57013. // Queries
  57014. createQuery(): WebGLQuery;
  57015. deleteQuery(query: WebGLQuery): void;
  57016. beginQuery(target: number, query: WebGLQuery): void;
  57017. endQuery(target: number): void;
  57018. getQueryParameter(query: WebGLQuery, pname: number): any;
  57019. getQuery(target: number, pname: number): any;
  57020. MAX_SAMPLES: number;
  57021. RGBA8: number;
  57022. READ_FRAMEBUFFER: number;
  57023. DRAW_FRAMEBUFFER: number;
  57024. UNIFORM_BUFFER: number;
  57025. HALF_FLOAT_OES: number;
  57026. RGBA16F: number;
  57027. RGBA32F: number;
  57028. R32F: number;
  57029. RG32F: number;
  57030. RGB32F: number;
  57031. R16F: number;
  57032. RG16F: number;
  57033. RGB16F: number;
  57034. RED: number;
  57035. RG: number;
  57036. R8: number;
  57037. RG8: number;
  57038. UNSIGNED_INT_24_8: number;
  57039. DEPTH24_STENCIL8: number;
  57040. /* Multiple Render Targets */
  57041. drawBuffers(buffers: number[]): void;
  57042. readBuffer(src: number): void;
  57043. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57044. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57045. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57046. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57047. // Occlusion Query
  57048. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57049. ANY_SAMPLES_PASSED: number;
  57050. QUERY_RESULT_AVAILABLE: number;
  57051. QUERY_RESULT: number;
  57052. }
  57053. interface WebGLBuffer {
  57054. references: number;
  57055. capacity: number;
  57056. is32Bits: boolean;
  57057. }
  57058. interface WebGLProgram {
  57059. transformFeedback?: WebGLTransformFeedback | null;
  57060. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57061. }
  57062. interface EXT_disjoint_timer_query {
  57063. QUERY_COUNTER_BITS_EXT: number;
  57064. TIME_ELAPSED_EXT: number;
  57065. TIMESTAMP_EXT: number;
  57066. GPU_DISJOINT_EXT: number;
  57067. QUERY_RESULT_EXT: number;
  57068. QUERY_RESULT_AVAILABLE_EXT: number;
  57069. queryCounterEXT(query: WebGLQuery, target: number): void;
  57070. createQueryEXT(): WebGLQuery;
  57071. beginQueryEXT(target: number, query: WebGLQuery): void;
  57072. endQueryEXT(target: number): void;
  57073. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57074. deleteQueryEXT(query: WebGLQuery): void;
  57075. }
  57076. interface WebGLUniformLocation {
  57077. _currentState: any;
  57078. }
  57079. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57080. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57081. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57082. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57083. interface WebGLRenderingContext {
  57084. readonly RASTERIZER_DISCARD: number;
  57085. readonly DEPTH_COMPONENT24: number;
  57086. readonly TEXTURE_3D: number;
  57087. readonly TEXTURE_2D_ARRAY: number;
  57088. readonly TEXTURE_COMPARE_FUNC: number;
  57089. readonly TEXTURE_COMPARE_MODE: number;
  57090. readonly COMPARE_REF_TO_TEXTURE: number;
  57091. readonly TEXTURE_WRAP_R: number;
  57092. readonly HALF_FLOAT: number;
  57093. readonly RGB8: number;
  57094. readonly RED_INTEGER: number;
  57095. readonly RG_INTEGER: number;
  57096. readonly RGB_INTEGER: number;
  57097. readonly RGBA_INTEGER: number;
  57098. readonly R8_SNORM: number;
  57099. readonly RG8_SNORM: number;
  57100. readonly RGB8_SNORM: number;
  57101. readonly RGBA8_SNORM: number;
  57102. readonly R8I: number;
  57103. readonly RG8I: number;
  57104. readonly RGB8I: number;
  57105. readonly RGBA8I: number;
  57106. readonly R8UI: number;
  57107. readonly RG8UI: number;
  57108. readonly RGB8UI: number;
  57109. readonly RGBA8UI: number;
  57110. readonly R16I: number;
  57111. readonly RG16I: number;
  57112. readonly RGB16I: number;
  57113. readonly RGBA16I: number;
  57114. readonly R16UI: number;
  57115. readonly RG16UI: number;
  57116. readonly RGB16UI: number;
  57117. readonly RGBA16UI: number;
  57118. readonly R32I: number;
  57119. readonly RG32I: number;
  57120. readonly RGB32I: number;
  57121. readonly RGBA32I: number;
  57122. readonly R32UI: number;
  57123. readonly RG32UI: number;
  57124. readonly RGB32UI: number;
  57125. readonly RGBA32UI: number;
  57126. readonly RGB10_A2UI: number;
  57127. readonly R11F_G11F_B10F: number;
  57128. readonly RGB9_E5: number;
  57129. readonly RGB10_A2: number;
  57130. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57131. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57132. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57133. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57134. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57135. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57136. 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;
  57137. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57138. readonly TRANSFORM_FEEDBACK: number;
  57139. readonly INTERLEAVED_ATTRIBS: number;
  57140. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57141. createTransformFeedback(): WebGLTransformFeedback;
  57142. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57143. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57144. beginTransformFeedback(primitiveMode: number): void;
  57145. endTransformFeedback(): void;
  57146. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57147. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57148. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57149. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57150. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57151. }
  57152. interface ImageBitmap {
  57153. readonly width: number;
  57154. readonly height: number;
  57155. close(): void;
  57156. }
  57157. interface WebGLQuery extends WebGLObject {
  57158. }
  57159. declare var WebGLQuery: {
  57160. prototype: WebGLQuery;
  57161. new(): WebGLQuery;
  57162. };
  57163. interface WebGLSampler extends WebGLObject {
  57164. }
  57165. declare var WebGLSampler: {
  57166. prototype: WebGLSampler;
  57167. new(): WebGLSampler;
  57168. };
  57169. interface WebGLSync extends WebGLObject {
  57170. }
  57171. declare var WebGLSync: {
  57172. prototype: WebGLSync;
  57173. new(): WebGLSync;
  57174. };
  57175. interface WebGLTransformFeedback extends WebGLObject {
  57176. }
  57177. declare var WebGLTransformFeedback: {
  57178. prototype: WebGLTransformFeedback;
  57179. new(): WebGLTransformFeedback;
  57180. };
  57181. interface WebGLVertexArrayObject extends WebGLObject {
  57182. }
  57183. declare var WebGLVertexArrayObject: {
  57184. prototype: WebGLVertexArrayObject;
  57185. new(): WebGLVertexArrayObject;
  57186. };
  57187. // Type definitions for WebVR API
  57188. // Project: https://w3c.github.io/webvr/
  57189. // Definitions by: six a <https://github.com/lostfictions>
  57190. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57191. interface VRDisplay extends EventTarget {
  57192. /**
  57193. * Dictionary of capabilities describing the VRDisplay.
  57194. */
  57195. readonly capabilities: VRDisplayCapabilities;
  57196. /**
  57197. * z-depth defining the far plane of the eye view frustum
  57198. * enables mapping of values in the render target depth
  57199. * attachment to scene coordinates. Initially set to 10000.0.
  57200. */
  57201. depthFar: number;
  57202. /**
  57203. * z-depth defining the near plane of the eye view frustum
  57204. * enables mapping of values in the render target depth
  57205. * attachment to scene coordinates. Initially set to 0.01.
  57206. */
  57207. depthNear: number;
  57208. /**
  57209. * An identifier for this distinct VRDisplay. Used as an
  57210. * association point in the Gamepad API.
  57211. */
  57212. readonly displayId: number;
  57213. /**
  57214. * A display name, a user-readable name identifying it.
  57215. */
  57216. readonly displayName: string;
  57217. readonly isConnected: boolean;
  57218. readonly isPresenting: boolean;
  57219. /**
  57220. * If this VRDisplay supports room-scale experiences, the optional
  57221. * stage attribute contains details on the room-scale parameters.
  57222. */
  57223. readonly stageParameters: VRStageParameters | null;
  57224. /**
  57225. * Passing the value returned by `requestAnimationFrame` to
  57226. * `cancelAnimationFrame` will unregister the callback.
  57227. * @param handle Define the hanle of the request to cancel
  57228. */
  57229. cancelAnimationFrame(handle: number): void;
  57230. /**
  57231. * Stops presenting to the VRDisplay.
  57232. * @returns a promise to know when it stopped
  57233. */
  57234. exitPresent(): Promise<void>;
  57235. /**
  57236. * Return the current VREyeParameters for the given eye.
  57237. * @param whichEye Define the eye we want the parameter for
  57238. * @returns the eye parameters
  57239. */
  57240. getEyeParameters(whichEye: string): VREyeParameters;
  57241. /**
  57242. * Populates the passed VRFrameData with the information required to render
  57243. * the current frame.
  57244. * @param frameData Define the data structure to populate
  57245. * @returns true if ok otherwise false
  57246. */
  57247. getFrameData(frameData: VRFrameData): boolean;
  57248. /**
  57249. * Get the layers currently being presented.
  57250. * @returns the list of VR layers
  57251. */
  57252. getLayers(): VRLayer[];
  57253. /**
  57254. * Return a VRPose containing the future predicted pose of the VRDisplay
  57255. * when the current frame will be presented. The value returned will not
  57256. * change until JavaScript has returned control to the browser.
  57257. *
  57258. * The VRPose will contain the position, orientation, velocity,
  57259. * and acceleration of each of these properties.
  57260. * @returns the pose object
  57261. */
  57262. getPose(): VRPose;
  57263. /**
  57264. * Return the current instantaneous pose of the VRDisplay, with no
  57265. * prediction applied.
  57266. * @returns the current instantaneous pose
  57267. */
  57268. getImmediatePose(): VRPose;
  57269. /**
  57270. * The callback passed to `requestAnimationFrame` will be called
  57271. * any time a new frame should be rendered. When the VRDisplay is
  57272. * presenting the callback will be called at the native refresh
  57273. * rate of the HMD. When not presenting this function acts
  57274. * identically to how window.requestAnimationFrame acts. Content should
  57275. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57276. * asynchronously from other displays and at differing refresh rates.
  57277. * @param callback Define the eaction to run next frame
  57278. * @returns the request handle it
  57279. */
  57280. requestAnimationFrame(callback: FrameRequestCallback): number;
  57281. /**
  57282. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57283. * Repeat calls while already presenting will update the VRLayers being displayed.
  57284. * @param layers Define the list of layer to present
  57285. * @returns a promise to know when the request has been fulfilled
  57286. */
  57287. requestPresent(layers: VRLayer[]): Promise<void>;
  57288. /**
  57289. * Reset the pose for this display, treating its current position and
  57290. * orientation as the "origin/zero" values. VRPose.position,
  57291. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57292. * updated when calling resetPose(). This should be called in only
  57293. * sitting-space experiences.
  57294. */
  57295. resetPose(): void;
  57296. /**
  57297. * The VRLayer provided to the VRDisplay will be captured and presented
  57298. * in the HMD. Calling this function has the same effect on the source
  57299. * canvas as any other operation that uses its source image, and canvases
  57300. * created without preserveDrawingBuffer set to true will be cleared.
  57301. * @param pose Define the pose to submit
  57302. */
  57303. submitFrame(pose?: VRPose): void;
  57304. }
  57305. declare var VRDisplay: {
  57306. prototype: VRDisplay;
  57307. new(): VRDisplay;
  57308. };
  57309. interface VRLayer {
  57310. leftBounds?: number[] | Float32Array | null;
  57311. rightBounds?: number[] | Float32Array | null;
  57312. source?: HTMLCanvasElement | null;
  57313. }
  57314. interface VRDisplayCapabilities {
  57315. readonly canPresent: boolean;
  57316. readonly hasExternalDisplay: boolean;
  57317. readonly hasOrientation: boolean;
  57318. readonly hasPosition: boolean;
  57319. readonly maxLayers: number;
  57320. }
  57321. interface VREyeParameters {
  57322. /** @deprecated */
  57323. readonly fieldOfView: VRFieldOfView;
  57324. readonly offset: Float32Array;
  57325. readonly renderHeight: number;
  57326. readonly renderWidth: number;
  57327. }
  57328. interface VRFieldOfView {
  57329. readonly downDegrees: number;
  57330. readonly leftDegrees: number;
  57331. readonly rightDegrees: number;
  57332. readonly upDegrees: number;
  57333. }
  57334. interface VRFrameData {
  57335. readonly leftProjectionMatrix: Float32Array;
  57336. readonly leftViewMatrix: Float32Array;
  57337. readonly pose: VRPose;
  57338. readonly rightProjectionMatrix: Float32Array;
  57339. readonly rightViewMatrix: Float32Array;
  57340. readonly timestamp: number;
  57341. }
  57342. interface VRPose {
  57343. readonly angularAcceleration: Float32Array | null;
  57344. readonly angularVelocity: Float32Array | null;
  57345. readonly linearAcceleration: Float32Array | null;
  57346. readonly linearVelocity: Float32Array | null;
  57347. readonly orientation: Float32Array | null;
  57348. readonly position: Float32Array | null;
  57349. readonly timestamp: number;
  57350. }
  57351. interface VRStageParameters {
  57352. sittingToStandingTransform?: Float32Array;
  57353. sizeX?: number;
  57354. sizeY?: number;
  57355. }
  57356. interface Navigator {
  57357. getVRDisplays(): Promise<VRDisplay[]>;
  57358. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57359. }
  57360. interface Window {
  57361. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57362. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57363. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57364. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57365. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57366. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57367. }
  57368. interface Gamepad {
  57369. readonly displayId: number;
  57370. }
  57371. interface XRDevice {
  57372. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57373. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57374. }
  57375. interface XRSession {
  57376. getInputSources(): Array<any>;
  57377. baseLayer: XRWebGLLayer;
  57378. requestFrameOfReference(type: string): Promise<void>;
  57379. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57380. end(): Promise<void>;
  57381. requestAnimationFrame: Function;
  57382. addEventListener: Function;
  57383. }
  57384. interface XRSessionCreationOptions {
  57385. outputContext?: WebGLRenderingContext | null;
  57386. immersive?: boolean;
  57387. environmentIntegration?: boolean;
  57388. }
  57389. interface XRLayer {
  57390. getViewport: Function;
  57391. framebufferWidth: number;
  57392. framebufferHeight: number;
  57393. }
  57394. interface XRView {
  57395. projectionMatrix: Float32Array;
  57396. }
  57397. interface XRFrame {
  57398. getDevicePose: Function;
  57399. getInputPose: Function;
  57400. views: Array<XRView>;
  57401. baseLayer: XRLayer;
  57402. }
  57403. interface XRFrameOfReference {
  57404. }
  57405. interface XRWebGLLayer extends XRLayer {
  57406. framebuffer: WebGLFramebuffer;
  57407. }
  57408. declare var XRWebGLLayer: {
  57409. prototype: XRWebGLLayer;
  57410. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57411. };
  57412. declare module "babylonjs" {
  57413. export * from "babylonjs/Legacy/legacy";
  57414. }
  57415. declare module BABYLON {
  57416. /** Alias type for value that can be null */
  57417. export type Nullable<T> = T | null;
  57418. /**
  57419. * Alias type for number that are floats
  57420. * @ignorenaming
  57421. */
  57422. export type float = number;
  57423. /**
  57424. * Alias type for number that are doubles.
  57425. * @ignorenaming
  57426. */
  57427. export type double = number;
  57428. /**
  57429. * Alias type for number that are integer
  57430. * @ignorenaming
  57431. */
  57432. export type int = number;
  57433. /** Alias type for number array or Float32Array */
  57434. export type FloatArray = number[] | Float32Array;
  57435. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57436. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57437. /**
  57438. * Alias for types that can be used by a Buffer or VertexBuffer.
  57439. */
  57440. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57441. /**
  57442. * Alias type for primitive types
  57443. * @ignorenaming
  57444. */
  57445. type Primitive = undefined | null | boolean | string | number | Function;
  57446. /**
  57447. * Type modifier to make all the properties of an object Readonly
  57448. */
  57449. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57450. /**
  57451. * Type modifier to make all the properties of an object Readonly recursively
  57452. */
  57453. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57454. /** @hidden */
  57455. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57456. }
  57457. /** @hidden */
  57458. /** @hidden */
  57459. type DeepImmutableObject<T> = {
  57460. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57461. };
  57462. }
  57463. declare module BABYLON {
  57464. /**
  57465. * Class containing a set of static utilities functions for arrays.
  57466. */
  57467. export class ArrayTools {
  57468. /**
  57469. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57470. * @param size the number of element to construct and put in the array
  57471. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57472. * @returns a new array filled with new objects
  57473. */
  57474. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57475. }
  57476. }
  57477. declare module BABYLON {
  57478. /**
  57479. * Scalar computation library
  57480. */
  57481. export class Scalar {
  57482. /**
  57483. * Two pi constants convenient for computation.
  57484. */
  57485. static TwoPi: number;
  57486. /**
  57487. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57488. * @param a number
  57489. * @param b number
  57490. * @param epsilon (default = 1.401298E-45)
  57491. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57492. */
  57493. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57494. /**
  57495. * Returns a string : the upper case translation of the number i to hexadecimal.
  57496. * @param i number
  57497. * @returns the upper case translation of the number i to hexadecimal.
  57498. */
  57499. static ToHex(i: number): string;
  57500. /**
  57501. * Returns -1 if value is negative and +1 is value is positive.
  57502. * @param value the value
  57503. * @returns the value itself if it's equal to zero.
  57504. */
  57505. static Sign(value: number): number;
  57506. /**
  57507. * Returns the value itself if it's between min and max.
  57508. * Returns min if the value is lower than min.
  57509. * Returns max if the value is greater than max.
  57510. * @param value the value to clmap
  57511. * @param min the min value to clamp to (default: 0)
  57512. * @param max the max value to clamp to (default: 1)
  57513. * @returns the clamped value
  57514. */
  57515. static Clamp(value: number, min?: number, max?: number): number;
  57516. /**
  57517. * the log2 of value.
  57518. * @param value the value to compute log2 of
  57519. * @returns the log2 of value.
  57520. */
  57521. static Log2(value: number): number;
  57522. /**
  57523. * Loops the value, so that it is never larger than length and never smaller than 0.
  57524. *
  57525. * This is similar to the modulo operator but it works with floating point numbers.
  57526. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57527. * With t = 5 and length = 2.5, the result would be 0.0.
  57528. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57529. * @param value the value
  57530. * @param length the length
  57531. * @returns the looped value
  57532. */
  57533. static Repeat(value: number, length: number): number;
  57534. /**
  57535. * Normalize the value between 0.0 and 1.0 using min and max values
  57536. * @param value value to normalize
  57537. * @param min max to normalize between
  57538. * @param max min to normalize between
  57539. * @returns the normalized value
  57540. */
  57541. static Normalize(value: number, min: number, max: number): number;
  57542. /**
  57543. * Denormalize the value from 0.0 and 1.0 using min and max values
  57544. * @param normalized value to denormalize
  57545. * @param min max to denormalize between
  57546. * @param max min to denormalize between
  57547. * @returns the denormalized value
  57548. */
  57549. static Denormalize(normalized: number, min: number, max: number): number;
  57550. /**
  57551. * Calculates the shortest difference between two given angles given in degrees.
  57552. * @param current current angle in degrees
  57553. * @param target target angle in degrees
  57554. * @returns the delta
  57555. */
  57556. static DeltaAngle(current: number, target: number): number;
  57557. /**
  57558. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57559. * @param tx value
  57560. * @param length length
  57561. * @returns The returned value will move back and forth between 0 and length
  57562. */
  57563. static PingPong(tx: number, length: number): number;
  57564. /**
  57565. * Interpolates between min and max with smoothing at the limits.
  57566. *
  57567. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57568. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57569. * @param from from
  57570. * @param to to
  57571. * @param tx value
  57572. * @returns the smooth stepped value
  57573. */
  57574. static SmoothStep(from: number, to: number, tx: number): number;
  57575. /**
  57576. * Moves a value current towards target.
  57577. *
  57578. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57579. * Negative values of maxDelta pushes the value away from target.
  57580. * @param current current value
  57581. * @param target target value
  57582. * @param maxDelta max distance to move
  57583. * @returns resulting value
  57584. */
  57585. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57586. /**
  57587. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57588. *
  57589. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57590. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57591. * @param current current value
  57592. * @param target target value
  57593. * @param maxDelta max distance to move
  57594. * @returns resulting angle
  57595. */
  57596. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57597. /**
  57598. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57599. * @param start start value
  57600. * @param end target value
  57601. * @param amount amount to lerp between
  57602. * @returns the lerped value
  57603. */
  57604. static Lerp(start: number, end: number, amount: number): number;
  57605. /**
  57606. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57607. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57608. * @param start start value
  57609. * @param end target value
  57610. * @param amount amount to lerp between
  57611. * @returns the lerped value
  57612. */
  57613. static LerpAngle(start: number, end: number, amount: number): number;
  57614. /**
  57615. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57616. * @param a start value
  57617. * @param b target value
  57618. * @param value value between a and b
  57619. * @returns the inverseLerp value
  57620. */
  57621. static InverseLerp(a: number, b: number, value: number): number;
  57622. /**
  57623. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57624. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57625. * @param value1 spline value
  57626. * @param tangent1 spline value
  57627. * @param value2 spline value
  57628. * @param tangent2 spline value
  57629. * @param amount input value
  57630. * @returns hermite result
  57631. */
  57632. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57633. /**
  57634. * Returns a random float number between and min and max values
  57635. * @param min min value of random
  57636. * @param max max value of random
  57637. * @returns random value
  57638. */
  57639. static RandomRange(min: number, max: number): number;
  57640. /**
  57641. * This function returns percentage of a number in a given range.
  57642. *
  57643. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57644. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57645. * @param number to convert to percentage
  57646. * @param min min range
  57647. * @param max max range
  57648. * @returns the percentage
  57649. */
  57650. static RangeToPercent(number: number, min: number, max: number): number;
  57651. /**
  57652. * This function returns number that corresponds to the percentage in a given range.
  57653. *
  57654. * PercentToRange(0.34,0,100) will return 34.
  57655. * @param percent to convert to number
  57656. * @param min min range
  57657. * @param max max range
  57658. * @returns the number
  57659. */
  57660. static PercentToRange(percent: number, min: number, max: number): number;
  57661. /**
  57662. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57663. * @param angle The angle to normalize in radian.
  57664. * @return The converted angle.
  57665. */
  57666. static NormalizeRadians(angle: number): number;
  57667. }
  57668. }
  57669. declare module BABYLON {
  57670. /**
  57671. * Constant used to convert a value to gamma space
  57672. * @ignorenaming
  57673. */
  57674. export const ToGammaSpace: number;
  57675. /**
  57676. * Constant used to convert a value to linear space
  57677. * @ignorenaming
  57678. */
  57679. export const ToLinearSpace = 2.2;
  57680. /**
  57681. * Constant used to define the minimal number value in Babylon.js
  57682. * @ignorenaming
  57683. */
  57684. export const Epsilon = 0.001;
  57685. /**
  57686. * Class used to hold a RBG color
  57687. */
  57688. export class Color3 {
  57689. /**
  57690. * Defines the red component (between 0 and 1, default is 0)
  57691. */
  57692. r: number;
  57693. /**
  57694. * Defines the green component (between 0 and 1, default is 0)
  57695. */
  57696. g: number;
  57697. /**
  57698. * Defines the blue component (between 0 and 1, default is 0)
  57699. */
  57700. b: number;
  57701. /**
  57702. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57703. * @param r defines the red component (between 0 and 1, default is 0)
  57704. * @param g defines the green component (between 0 and 1, default is 0)
  57705. * @param b defines the blue component (between 0 and 1, default is 0)
  57706. */
  57707. constructor(
  57708. /**
  57709. * Defines the red component (between 0 and 1, default is 0)
  57710. */
  57711. r?: number,
  57712. /**
  57713. * Defines the green component (between 0 and 1, default is 0)
  57714. */
  57715. g?: number,
  57716. /**
  57717. * Defines the blue component (between 0 and 1, default is 0)
  57718. */
  57719. b?: number);
  57720. /**
  57721. * Creates a string with the Color3 current values
  57722. * @returns the string representation of the Color3 object
  57723. */
  57724. toString(): string;
  57725. /**
  57726. * Returns the string "Color3"
  57727. * @returns "Color3"
  57728. */
  57729. getClassName(): string;
  57730. /**
  57731. * Compute the Color3 hash code
  57732. * @returns an unique number that can be used to hash Color3 objects
  57733. */
  57734. getHashCode(): number;
  57735. /**
  57736. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57737. * @param array defines the array where to store the r,g,b components
  57738. * @param index defines an optional index in the target array to define where to start storing values
  57739. * @returns the current Color3 object
  57740. */
  57741. toArray(array: FloatArray, index?: number): Color3;
  57742. /**
  57743. * Returns a new Color4 object from the current Color3 and the given alpha
  57744. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57745. * @returns a new Color4 object
  57746. */
  57747. toColor4(alpha?: number): Color4;
  57748. /**
  57749. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57750. * @returns the new array
  57751. */
  57752. asArray(): number[];
  57753. /**
  57754. * Returns the luminance value
  57755. * @returns a float value
  57756. */
  57757. toLuminance(): number;
  57758. /**
  57759. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57760. * @param otherColor defines the second operand
  57761. * @returns the new Color3 object
  57762. */
  57763. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57764. /**
  57765. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57766. * @param otherColor defines the second operand
  57767. * @param result defines the Color3 object where to store the result
  57768. * @returns the current Color3
  57769. */
  57770. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57771. /**
  57772. * Determines equality between Color3 objects
  57773. * @param otherColor defines the second operand
  57774. * @returns true if the rgb values are equal to the given ones
  57775. */
  57776. equals(otherColor: DeepImmutable<Color3>): boolean;
  57777. /**
  57778. * Determines equality between the current Color3 object and a set of r,b,g values
  57779. * @param r defines the red component to check
  57780. * @param g defines the green component to check
  57781. * @param b defines the blue component to check
  57782. * @returns true if the rgb values are equal to the given ones
  57783. */
  57784. equalsFloats(r: number, g: number, b: number): boolean;
  57785. /**
  57786. * Multiplies in place each rgb value by scale
  57787. * @param scale defines the scaling factor
  57788. * @returns the updated Color3
  57789. */
  57790. scale(scale: number): Color3;
  57791. /**
  57792. * Multiplies the rgb values by scale and stores the result into "result"
  57793. * @param scale defines the scaling factor
  57794. * @param result defines the Color3 object where to store the result
  57795. * @returns the unmodified current Color3
  57796. */
  57797. scaleToRef(scale: number, result: Color3): Color3;
  57798. /**
  57799. * Scale the current Color3 values by a factor and add the result to a given Color3
  57800. * @param scale defines the scale factor
  57801. * @param result defines color to store the result into
  57802. * @returns the unmodified current Color3
  57803. */
  57804. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57805. /**
  57806. * Clamps the rgb values by the min and max values and stores the result into "result"
  57807. * @param min defines minimum clamping value (default is 0)
  57808. * @param max defines maximum clamping value (default is 1)
  57809. * @param result defines color to store the result into
  57810. * @returns the original Color3
  57811. */
  57812. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57813. /**
  57814. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57815. * @param otherColor defines the second operand
  57816. * @returns the new Color3
  57817. */
  57818. add(otherColor: DeepImmutable<Color3>): Color3;
  57819. /**
  57820. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57821. * @param otherColor defines the second operand
  57822. * @param result defines Color3 object to store the result into
  57823. * @returns the unmodified current Color3
  57824. */
  57825. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57826. /**
  57827. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57828. * @param otherColor defines the second operand
  57829. * @returns the new Color3
  57830. */
  57831. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57832. /**
  57833. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57834. * @param otherColor defines the second operand
  57835. * @param result defines Color3 object to store the result into
  57836. * @returns the unmodified current Color3
  57837. */
  57838. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57839. /**
  57840. * Copy the current object
  57841. * @returns a new Color3 copied the current one
  57842. */
  57843. clone(): Color3;
  57844. /**
  57845. * Copies the rgb values from the source in the current Color3
  57846. * @param source defines the source Color3 object
  57847. * @returns the updated Color3 object
  57848. */
  57849. copyFrom(source: DeepImmutable<Color3>): Color3;
  57850. /**
  57851. * Updates the Color3 rgb values from the given floats
  57852. * @param r defines the red component to read from
  57853. * @param g defines the green component to read from
  57854. * @param b defines the blue component to read from
  57855. * @returns the current Color3 object
  57856. */
  57857. copyFromFloats(r: number, g: number, b: number): Color3;
  57858. /**
  57859. * Updates the Color3 rgb values from the given floats
  57860. * @param r defines the red component to read from
  57861. * @param g defines the green component to read from
  57862. * @param b defines the blue component to read from
  57863. * @returns the current Color3 object
  57864. */
  57865. set(r: number, g: number, b: number): Color3;
  57866. /**
  57867. * Compute the Color3 hexadecimal code as a string
  57868. * @returns a string containing the hexadecimal representation of the Color3 object
  57869. */
  57870. toHexString(): string;
  57871. /**
  57872. * Computes a new Color3 converted from the current one to linear space
  57873. * @returns a new Color3 object
  57874. */
  57875. toLinearSpace(): Color3;
  57876. /**
  57877. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57878. * @param convertedColor defines the Color3 object where to store the linear space version
  57879. * @returns the unmodified Color3
  57880. */
  57881. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57882. /**
  57883. * Computes a new Color3 converted from the current one to gamma space
  57884. * @returns a new Color3 object
  57885. */
  57886. toGammaSpace(): Color3;
  57887. /**
  57888. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57889. * @param convertedColor defines the Color3 object where to store the gamma space version
  57890. * @returns the unmodified Color3
  57891. */
  57892. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57893. private static _BlackReadOnly;
  57894. /**
  57895. * Creates a new Color3 from the string containing valid hexadecimal values
  57896. * @param hex defines a string containing valid hexadecimal values
  57897. * @returns a new Color3 object
  57898. */
  57899. static FromHexString(hex: string): Color3;
  57900. /**
  57901. * Creates a new Vector3 from the starting index of the given array
  57902. * @param array defines the source array
  57903. * @param offset defines an offset in the source array
  57904. * @returns a new Color3 object
  57905. */
  57906. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57907. /**
  57908. * Creates a new Color3 from integer values (< 256)
  57909. * @param r defines the red component to read from (value between 0 and 255)
  57910. * @param g defines the green component to read from (value between 0 and 255)
  57911. * @param b defines the blue component to read from (value between 0 and 255)
  57912. * @returns a new Color3 object
  57913. */
  57914. static FromInts(r: number, g: number, b: number): Color3;
  57915. /**
  57916. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57917. * @param start defines the start Color3 value
  57918. * @param end defines the end Color3 value
  57919. * @param amount defines the gradient value between start and end
  57920. * @returns a new Color3 object
  57921. */
  57922. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57923. /**
  57924. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57925. * @param left defines the start value
  57926. * @param right defines the end value
  57927. * @param amount defines the gradient factor
  57928. * @param result defines the Color3 object where to store the result
  57929. */
  57930. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57931. /**
  57932. * Returns a Color3 value containing a red color
  57933. * @returns a new Color3 object
  57934. */
  57935. static Red(): Color3;
  57936. /**
  57937. * Returns a Color3 value containing a green color
  57938. * @returns a new Color3 object
  57939. */
  57940. static Green(): Color3;
  57941. /**
  57942. * Returns a Color3 value containing a blue color
  57943. * @returns a new Color3 object
  57944. */
  57945. static Blue(): Color3;
  57946. /**
  57947. * Returns a Color3 value containing a black color
  57948. * @returns a new Color3 object
  57949. */
  57950. static Black(): Color3;
  57951. /**
  57952. * Gets a Color3 value containing a black color that must not be updated
  57953. */
  57954. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57955. /**
  57956. * Returns a Color3 value containing a white color
  57957. * @returns a new Color3 object
  57958. */
  57959. static White(): Color3;
  57960. /**
  57961. * Returns a Color3 value containing a purple color
  57962. * @returns a new Color3 object
  57963. */
  57964. static Purple(): Color3;
  57965. /**
  57966. * Returns a Color3 value containing a magenta color
  57967. * @returns a new Color3 object
  57968. */
  57969. static Magenta(): Color3;
  57970. /**
  57971. * Returns a Color3 value containing a yellow color
  57972. * @returns a new Color3 object
  57973. */
  57974. static Yellow(): Color3;
  57975. /**
  57976. * Returns a Color3 value containing a gray color
  57977. * @returns a new Color3 object
  57978. */
  57979. static Gray(): Color3;
  57980. /**
  57981. * Returns a Color3 value containing a teal color
  57982. * @returns a new Color3 object
  57983. */
  57984. static Teal(): Color3;
  57985. /**
  57986. * Returns a Color3 value containing a random color
  57987. * @returns a new Color3 object
  57988. */
  57989. static Random(): Color3;
  57990. }
  57991. /**
  57992. * Class used to hold a RBGA color
  57993. */
  57994. export class Color4 {
  57995. /**
  57996. * Defines the red component (between 0 and 1, default is 0)
  57997. */
  57998. r: number;
  57999. /**
  58000. * Defines the green component (between 0 and 1, default is 0)
  58001. */
  58002. g: number;
  58003. /**
  58004. * Defines the blue component (between 0 and 1, default is 0)
  58005. */
  58006. b: number;
  58007. /**
  58008. * Defines the alpha component (between 0 and 1, default is 1)
  58009. */
  58010. a: number;
  58011. /**
  58012. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58013. * @param r defines the red component (between 0 and 1, default is 0)
  58014. * @param g defines the green component (between 0 and 1, default is 0)
  58015. * @param b defines the blue component (between 0 and 1, default is 0)
  58016. * @param a defines the alpha component (between 0 and 1, default is 1)
  58017. */
  58018. constructor(
  58019. /**
  58020. * Defines the red component (between 0 and 1, default is 0)
  58021. */
  58022. r?: number,
  58023. /**
  58024. * Defines the green component (between 0 and 1, default is 0)
  58025. */
  58026. g?: number,
  58027. /**
  58028. * Defines the blue component (between 0 and 1, default is 0)
  58029. */
  58030. b?: number,
  58031. /**
  58032. * Defines the alpha component (between 0 and 1, default is 1)
  58033. */
  58034. a?: number);
  58035. /**
  58036. * Adds in place the given Color4 values to the current Color4 object
  58037. * @param right defines the second operand
  58038. * @returns the current updated Color4 object
  58039. */
  58040. addInPlace(right: DeepImmutable<Color4>): Color4;
  58041. /**
  58042. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58043. * @returns the new array
  58044. */
  58045. asArray(): number[];
  58046. /**
  58047. * Stores from the starting index in the given array the Color4 successive values
  58048. * @param array defines the array where to store the r,g,b components
  58049. * @param index defines an optional index in the target array to define where to start storing values
  58050. * @returns the current Color4 object
  58051. */
  58052. toArray(array: number[], index?: number): Color4;
  58053. /**
  58054. * Determines equality between Color4 objects
  58055. * @param otherColor defines the second operand
  58056. * @returns true if the rgba values are equal to the given ones
  58057. */
  58058. equals(otherColor: DeepImmutable<Color4>): boolean;
  58059. /**
  58060. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58061. * @param right defines the second operand
  58062. * @returns a new Color4 object
  58063. */
  58064. add(right: DeepImmutable<Color4>): Color4;
  58065. /**
  58066. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58067. * @param right defines the second operand
  58068. * @returns a new Color4 object
  58069. */
  58070. subtract(right: DeepImmutable<Color4>): Color4;
  58071. /**
  58072. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58073. * @param right defines the second operand
  58074. * @param result defines the Color4 object where to store the result
  58075. * @returns the current Color4 object
  58076. */
  58077. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58078. /**
  58079. * Creates a new Color4 with the current Color4 values multiplied by scale
  58080. * @param scale defines the scaling factor to apply
  58081. * @returns a new Color4 object
  58082. */
  58083. scale(scale: number): Color4;
  58084. /**
  58085. * Multiplies the current Color4 values by scale and stores the result in "result"
  58086. * @param scale defines the scaling factor to apply
  58087. * @param result defines the Color4 object where to store the result
  58088. * @returns the current unmodified Color4
  58089. */
  58090. scaleToRef(scale: number, result: Color4): Color4;
  58091. /**
  58092. * Scale the current Color4 values by a factor and add the result to a given Color4
  58093. * @param scale defines the scale factor
  58094. * @param result defines the Color4 object where to store the result
  58095. * @returns the unmodified current Color4
  58096. */
  58097. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58098. /**
  58099. * Clamps the rgb values by the min and max values and stores the result into "result"
  58100. * @param min defines minimum clamping value (default is 0)
  58101. * @param max defines maximum clamping value (default is 1)
  58102. * @param result defines color to store the result into.
  58103. * @returns the cuurent Color4
  58104. */
  58105. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58106. /**
  58107. * Multipy an Color4 value by another and return a new Color4 object
  58108. * @param color defines the Color4 value to multiply by
  58109. * @returns a new Color4 object
  58110. */
  58111. multiply(color: Color4): Color4;
  58112. /**
  58113. * Multipy a Color4 value by another and push the result in a reference value
  58114. * @param color defines the Color4 value to multiply by
  58115. * @param result defines the Color4 to fill the result in
  58116. * @returns the result Color4
  58117. */
  58118. multiplyToRef(color: Color4, result: Color4): Color4;
  58119. /**
  58120. * Creates a string with the Color4 current values
  58121. * @returns the string representation of the Color4 object
  58122. */
  58123. toString(): string;
  58124. /**
  58125. * Returns the string "Color4"
  58126. * @returns "Color4"
  58127. */
  58128. getClassName(): string;
  58129. /**
  58130. * Compute the Color4 hash code
  58131. * @returns an unique number that can be used to hash Color4 objects
  58132. */
  58133. getHashCode(): number;
  58134. /**
  58135. * Creates a new Color4 copied from the current one
  58136. * @returns a new Color4 object
  58137. */
  58138. clone(): Color4;
  58139. /**
  58140. * Copies the given Color4 values into the current one
  58141. * @param source defines the source Color4 object
  58142. * @returns the current updated Color4 object
  58143. */
  58144. copyFrom(source: Color4): Color4;
  58145. /**
  58146. * Copies the given float values into the current one
  58147. * @param r defines the red component to read from
  58148. * @param g defines the green component to read from
  58149. * @param b defines the blue component to read from
  58150. * @param a defines the alpha component to read from
  58151. * @returns the current updated Color4 object
  58152. */
  58153. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58154. /**
  58155. * Copies the given float values into the current one
  58156. * @param r defines the red component to read from
  58157. * @param g defines the green component to read from
  58158. * @param b defines the blue component to read from
  58159. * @param a defines the alpha component to read from
  58160. * @returns the current updated Color4 object
  58161. */
  58162. set(r: number, g: number, b: number, a: number): Color4;
  58163. /**
  58164. * Compute the Color4 hexadecimal code as a string
  58165. * @returns a string containing the hexadecimal representation of the Color4 object
  58166. */
  58167. toHexString(): string;
  58168. /**
  58169. * Computes a new Color4 converted from the current one to linear space
  58170. * @returns a new Color4 object
  58171. */
  58172. toLinearSpace(): Color4;
  58173. /**
  58174. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58175. * @param convertedColor defines the Color4 object where to store the linear space version
  58176. * @returns the unmodified Color4
  58177. */
  58178. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58179. /**
  58180. * Computes a new Color4 converted from the current one to gamma space
  58181. * @returns a new Color4 object
  58182. */
  58183. toGammaSpace(): Color4;
  58184. /**
  58185. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58186. * @param convertedColor defines the Color4 object where to store the gamma space version
  58187. * @returns the unmodified Color4
  58188. */
  58189. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58190. /**
  58191. * Creates a new Color4 from the string containing valid hexadecimal values
  58192. * @param hex defines a string containing valid hexadecimal values
  58193. * @returns a new Color4 object
  58194. */
  58195. static FromHexString(hex: string): Color4;
  58196. /**
  58197. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58198. * @param left defines the start value
  58199. * @param right defines the end value
  58200. * @param amount defines the gradient factor
  58201. * @returns a new Color4 object
  58202. */
  58203. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58204. /**
  58205. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58206. * @param left defines the start value
  58207. * @param right defines the end value
  58208. * @param amount defines the gradient factor
  58209. * @param result defines the Color4 object where to store data
  58210. */
  58211. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58212. /**
  58213. * Creates a new Color4 from a Color3 and an alpha value
  58214. * @param color3 defines the source Color3 to read from
  58215. * @param alpha defines the alpha component (1.0 by default)
  58216. * @returns a new Color4 object
  58217. */
  58218. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58219. /**
  58220. * Creates a new Color4 from the starting index element of the given array
  58221. * @param array defines the source array to read from
  58222. * @param offset defines the offset in the source array
  58223. * @returns a new Color4 object
  58224. */
  58225. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58226. /**
  58227. * Creates a new Color3 from integer values (< 256)
  58228. * @param r defines the red component to read from (value between 0 and 255)
  58229. * @param g defines the green component to read from (value between 0 and 255)
  58230. * @param b defines the blue component to read from (value between 0 and 255)
  58231. * @param a defines the alpha component to read from (value between 0 and 255)
  58232. * @returns a new Color3 object
  58233. */
  58234. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58235. /**
  58236. * Check the content of a given array and convert it to an array containing RGBA data
  58237. * If the original array was already containing count * 4 values then it is returned directly
  58238. * @param colors defines the array to check
  58239. * @param count defines the number of RGBA data to expect
  58240. * @returns an array containing count * 4 values (RGBA)
  58241. */
  58242. static CheckColors4(colors: number[], count: number): number[];
  58243. }
  58244. /**
  58245. * Class representing a vector containing 2 coordinates
  58246. */
  58247. export class Vector2 {
  58248. /** defines the first coordinate */
  58249. x: number;
  58250. /** defines the second coordinate */
  58251. y: number;
  58252. /**
  58253. * Creates a new Vector2 from the given x and y coordinates
  58254. * @param x defines the first coordinate
  58255. * @param y defines the second coordinate
  58256. */
  58257. constructor(
  58258. /** defines the first coordinate */
  58259. x?: number,
  58260. /** defines the second coordinate */
  58261. y?: number);
  58262. /**
  58263. * Gets a string with the Vector2 coordinates
  58264. * @returns a string with the Vector2 coordinates
  58265. */
  58266. toString(): string;
  58267. /**
  58268. * Gets class name
  58269. * @returns the string "Vector2"
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Gets current vector hash code
  58274. * @returns the Vector2 hash code as a number
  58275. */
  58276. getHashCode(): number;
  58277. /**
  58278. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58279. * @param array defines the source array
  58280. * @param index defines the offset in source array
  58281. * @returns the current Vector2
  58282. */
  58283. toArray(array: FloatArray, index?: number): Vector2;
  58284. /**
  58285. * Copy the current vector to an array
  58286. * @returns a new array with 2 elements: the Vector2 coordinates.
  58287. */
  58288. asArray(): number[];
  58289. /**
  58290. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58291. * @param source defines the source Vector2
  58292. * @returns the current updated Vector2
  58293. */
  58294. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58295. /**
  58296. * Sets the Vector2 coordinates with the given floats
  58297. * @param x defines the first coordinate
  58298. * @param y defines the second coordinate
  58299. * @returns the current updated Vector2
  58300. */
  58301. copyFromFloats(x: number, y: number): Vector2;
  58302. /**
  58303. * Sets the Vector2 coordinates with the given floats
  58304. * @param x defines the first coordinate
  58305. * @param y defines the second coordinate
  58306. * @returns the current updated Vector2
  58307. */
  58308. set(x: number, y: number): Vector2;
  58309. /**
  58310. * Add another vector with the current one
  58311. * @param otherVector defines the other vector
  58312. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58313. */
  58314. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58315. /**
  58316. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58317. * @param otherVector defines the other vector
  58318. * @param result defines the target vector
  58319. * @returns the unmodified current Vector2
  58320. */
  58321. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58322. /**
  58323. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58324. * @param otherVector defines the other vector
  58325. * @returns the current updated Vector2
  58326. */
  58327. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58328. /**
  58329. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58330. * @param otherVector defines the other vector
  58331. * @returns a new Vector2
  58332. */
  58333. addVector3(otherVector: Vector3): Vector2;
  58334. /**
  58335. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58336. * @param otherVector defines the other vector
  58337. * @returns a new Vector2
  58338. */
  58339. subtract(otherVector: Vector2): Vector2;
  58340. /**
  58341. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58342. * @param otherVector defines the other vector
  58343. * @param result defines the target vector
  58344. * @returns the unmodified current Vector2
  58345. */
  58346. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58347. /**
  58348. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58349. * @param otherVector defines the other vector
  58350. * @returns the current updated Vector2
  58351. */
  58352. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58353. /**
  58354. * Multiplies in place the current Vector2 coordinates by the given ones
  58355. * @param otherVector defines the other vector
  58356. * @returns the current updated Vector2
  58357. */
  58358. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58359. /**
  58360. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58361. * @param otherVector defines the other vector
  58362. * @returns a new Vector2
  58363. */
  58364. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58365. /**
  58366. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58367. * @param otherVector defines the other vector
  58368. * @param result defines the target vector
  58369. * @returns the unmodified current Vector2
  58370. */
  58371. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58372. /**
  58373. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58374. * @param x defines the first coordinate
  58375. * @param y defines the second coordinate
  58376. * @returns a new Vector2
  58377. */
  58378. multiplyByFloats(x: number, y: number): Vector2;
  58379. /**
  58380. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58381. * @param otherVector defines the other vector
  58382. * @returns a new Vector2
  58383. */
  58384. divide(otherVector: Vector2): Vector2;
  58385. /**
  58386. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58387. * @param otherVector defines the other vector
  58388. * @param result defines the target vector
  58389. * @returns the unmodified current Vector2
  58390. */
  58391. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58392. /**
  58393. * Divides the current Vector2 coordinates by the given ones
  58394. * @param otherVector defines the other vector
  58395. * @returns the current updated Vector2
  58396. */
  58397. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58398. /**
  58399. * Gets a new Vector2 with current Vector2 negated coordinates
  58400. * @returns a new Vector2
  58401. */
  58402. negate(): Vector2;
  58403. /**
  58404. * Multiply the Vector2 coordinates by scale
  58405. * @param scale defines the scaling factor
  58406. * @returns the current updated Vector2
  58407. */
  58408. scaleInPlace(scale: number): Vector2;
  58409. /**
  58410. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58411. * @param scale defines the scaling factor
  58412. * @returns a new Vector2
  58413. */
  58414. scale(scale: number): Vector2;
  58415. /**
  58416. * Scale the current Vector2 values by a factor to a given Vector2
  58417. * @param scale defines the scale factor
  58418. * @param result defines the Vector2 object where to store the result
  58419. * @returns the unmodified current Vector2
  58420. */
  58421. scaleToRef(scale: number, result: Vector2): Vector2;
  58422. /**
  58423. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58424. * @param scale defines the scale factor
  58425. * @param result defines the Vector2 object where to store the result
  58426. * @returns the unmodified current Vector2
  58427. */
  58428. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58429. /**
  58430. * Gets a boolean if two vectors are equals
  58431. * @param otherVector defines the other vector
  58432. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58433. */
  58434. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58435. /**
  58436. * Gets a boolean if two vectors are equals (using an epsilon value)
  58437. * @param otherVector defines the other vector
  58438. * @param epsilon defines the minimal distance to consider equality
  58439. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58440. */
  58441. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58442. /**
  58443. * Gets a new Vector2 from current Vector2 floored values
  58444. * @returns a new Vector2
  58445. */
  58446. floor(): Vector2;
  58447. /**
  58448. * Gets a new Vector2 from current Vector2 floored values
  58449. * @returns a new Vector2
  58450. */
  58451. fract(): Vector2;
  58452. /**
  58453. * Gets the length of the vector
  58454. * @returns the vector length (float)
  58455. */
  58456. length(): number;
  58457. /**
  58458. * Gets the vector squared length
  58459. * @returns the vector squared length (float)
  58460. */
  58461. lengthSquared(): number;
  58462. /**
  58463. * Normalize the vector
  58464. * @returns the current updated Vector2
  58465. */
  58466. normalize(): Vector2;
  58467. /**
  58468. * Gets a new Vector2 copied from the Vector2
  58469. * @returns a new Vector2
  58470. */
  58471. clone(): Vector2;
  58472. /**
  58473. * Gets a new Vector2(0, 0)
  58474. * @returns a new Vector2
  58475. */
  58476. static Zero(): Vector2;
  58477. /**
  58478. * Gets a new Vector2(1, 1)
  58479. * @returns a new Vector2
  58480. */
  58481. static One(): Vector2;
  58482. /**
  58483. * Gets a new Vector2 set from the given index element of the given array
  58484. * @param array defines the data source
  58485. * @param offset defines the offset in the data source
  58486. * @returns a new Vector2
  58487. */
  58488. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58489. /**
  58490. * Sets "result" from the given index element of the given array
  58491. * @param array defines the data source
  58492. * @param offset defines the offset in the data source
  58493. * @param result defines the target vector
  58494. */
  58495. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58496. /**
  58497. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58498. * @param value1 defines 1st point of control
  58499. * @param value2 defines 2nd point of control
  58500. * @param value3 defines 3rd point of control
  58501. * @param value4 defines 4th point of control
  58502. * @param amount defines the interpolation factor
  58503. * @returns a new Vector2
  58504. */
  58505. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58506. /**
  58507. * 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".
  58508. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58509. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58510. * @param value defines the value to clamp
  58511. * @param min defines the lower limit
  58512. * @param max defines the upper limit
  58513. * @returns a new Vector2
  58514. */
  58515. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58516. /**
  58517. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58518. * @param value1 defines the 1st control point
  58519. * @param tangent1 defines the outgoing tangent
  58520. * @param value2 defines the 2nd control point
  58521. * @param tangent2 defines the incoming tangent
  58522. * @param amount defines the interpolation factor
  58523. * @returns a new Vector2
  58524. */
  58525. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58526. /**
  58527. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58528. * @param start defines the start vector
  58529. * @param end defines the end vector
  58530. * @param amount defines the interpolation factor
  58531. * @returns a new Vector2
  58532. */
  58533. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58534. /**
  58535. * Gets the dot product of the vector "left" and the vector "right"
  58536. * @param left defines first vector
  58537. * @param right defines second vector
  58538. * @returns the dot product (float)
  58539. */
  58540. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58541. /**
  58542. * Returns a new Vector2 equal to the normalized given vector
  58543. * @param vector defines the vector to normalize
  58544. * @returns a new Vector2
  58545. */
  58546. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58547. /**
  58548. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58549. * @param left defines 1st vector
  58550. * @param right defines 2nd vector
  58551. * @returns a new Vector2
  58552. */
  58553. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58554. /**
  58555. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58556. * @param left defines 1st vector
  58557. * @param right defines 2nd vector
  58558. * @returns a new Vector2
  58559. */
  58560. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58561. /**
  58562. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58563. * @param vector defines the vector to transform
  58564. * @param transformation defines the matrix to apply
  58565. * @returns a new Vector2
  58566. */
  58567. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58568. /**
  58569. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58570. * @param vector defines the vector to transform
  58571. * @param transformation defines the matrix to apply
  58572. * @param result defines the target vector
  58573. */
  58574. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58575. /**
  58576. * Determines if a given vector is included in a triangle
  58577. * @param p defines the vector to test
  58578. * @param p0 defines 1st triangle point
  58579. * @param p1 defines 2nd triangle point
  58580. * @param p2 defines 3rd triangle point
  58581. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58582. */
  58583. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58584. /**
  58585. * Gets the distance between the vectors "value1" and "value2"
  58586. * @param value1 defines first vector
  58587. * @param value2 defines second vector
  58588. * @returns the distance between vectors
  58589. */
  58590. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58591. /**
  58592. * Returns the squared distance between the vectors "value1" and "value2"
  58593. * @param value1 defines first vector
  58594. * @param value2 defines second vector
  58595. * @returns the squared distance between vectors
  58596. */
  58597. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58598. /**
  58599. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58600. * @param value1 defines first vector
  58601. * @param value2 defines second vector
  58602. * @returns a new Vector2
  58603. */
  58604. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58605. /**
  58606. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58607. * @param p defines the middle point
  58608. * @param segA defines one point of the segment
  58609. * @param segB defines the other point of the segment
  58610. * @returns the shortest distance
  58611. */
  58612. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58613. }
  58614. /**
  58615. * Classed used to store (x,y,z) vector representation
  58616. * A Vector3 is the main object used in 3D geometry
  58617. * It can represent etiher the coordinates of a point the space, either a direction
  58618. * Reminder: js uses a left handed forward facing system
  58619. */
  58620. export class Vector3 {
  58621. /**
  58622. * Defines the first coordinates (on X axis)
  58623. */
  58624. x: number;
  58625. /**
  58626. * Defines the second coordinates (on Y axis)
  58627. */
  58628. y: number;
  58629. /**
  58630. * Defines the third coordinates (on Z axis)
  58631. */
  58632. z: number;
  58633. private static _UpReadOnly;
  58634. /**
  58635. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58636. * @param x defines the first coordinates (on X axis)
  58637. * @param y defines the second coordinates (on Y axis)
  58638. * @param z defines the third coordinates (on Z axis)
  58639. */
  58640. constructor(
  58641. /**
  58642. * Defines the first coordinates (on X axis)
  58643. */
  58644. x?: number,
  58645. /**
  58646. * Defines the second coordinates (on Y axis)
  58647. */
  58648. y?: number,
  58649. /**
  58650. * Defines the third coordinates (on Z axis)
  58651. */
  58652. z?: number);
  58653. /**
  58654. * Creates a string representation of the Vector3
  58655. * @returns a string with the Vector3 coordinates.
  58656. */
  58657. toString(): string;
  58658. /**
  58659. * Gets the class name
  58660. * @returns the string "Vector3"
  58661. */
  58662. getClassName(): string;
  58663. /**
  58664. * Creates the Vector3 hash code
  58665. * @returns a number which tends to be unique between Vector3 instances
  58666. */
  58667. getHashCode(): number;
  58668. /**
  58669. * Creates an array containing three elements : the coordinates of the Vector3
  58670. * @returns a new array of numbers
  58671. */
  58672. asArray(): number[];
  58673. /**
  58674. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58675. * @param array defines the destination array
  58676. * @param index defines the offset in the destination array
  58677. * @returns the current Vector3
  58678. */
  58679. toArray(array: FloatArray, index?: number): Vector3;
  58680. /**
  58681. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58682. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58683. */
  58684. toQuaternion(): Quaternion;
  58685. /**
  58686. * Adds the given vector to the current Vector3
  58687. * @param otherVector defines the second operand
  58688. * @returns the current updated Vector3
  58689. */
  58690. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58691. /**
  58692. * Adds the given coordinates to the current Vector3
  58693. * @param x defines the x coordinate of the operand
  58694. * @param y defines the y coordinate of the operand
  58695. * @param z defines the z coordinate of the operand
  58696. * @returns the current updated Vector3
  58697. */
  58698. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58699. /**
  58700. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58701. * @param otherVector defines the second operand
  58702. * @returns the resulting Vector3
  58703. */
  58704. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58705. /**
  58706. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58707. * @param otherVector defines the second operand
  58708. * @param result defines the Vector3 object where to store the result
  58709. * @returns the current Vector3
  58710. */
  58711. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58712. /**
  58713. * Subtract the given vector from the current Vector3
  58714. * @param otherVector defines the second operand
  58715. * @returns the current updated Vector3
  58716. */
  58717. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58718. /**
  58719. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58720. * @param otherVector defines the second operand
  58721. * @returns the resulting Vector3
  58722. */
  58723. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58724. /**
  58725. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58726. * @param otherVector defines the second operand
  58727. * @param result defines the Vector3 object where to store the result
  58728. * @returns the current Vector3
  58729. */
  58730. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58731. /**
  58732. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58733. * @param x defines the x coordinate of the operand
  58734. * @param y defines the y coordinate of the operand
  58735. * @param z defines the z coordinate of the operand
  58736. * @returns the resulting Vector3
  58737. */
  58738. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58739. /**
  58740. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58741. * @param x defines the x coordinate of the operand
  58742. * @param y defines the y coordinate of the operand
  58743. * @param z defines the z coordinate of the operand
  58744. * @param result defines the Vector3 object where to store the result
  58745. * @returns the current Vector3
  58746. */
  58747. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58748. /**
  58749. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58750. * @returns a new Vector3
  58751. */
  58752. negate(): Vector3;
  58753. /**
  58754. * Multiplies the Vector3 coordinates by the float "scale"
  58755. * @param scale defines the multiplier factor
  58756. * @returns the current updated Vector3
  58757. */
  58758. scaleInPlace(scale: number): Vector3;
  58759. /**
  58760. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58761. * @param scale defines the multiplier factor
  58762. * @returns a new Vector3
  58763. */
  58764. scale(scale: number): Vector3;
  58765. /**
  58766. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58767. * @param scale defines the multiplier factor
  58768. * @param result defines the Vector3 object where to store the result
  58769. * @returns the current Vector3
  58770. */
  58771. scaleToRef(scale: number, result: Vector3): Vector3;
  58772. /**
  58773. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58774. * @param scale defines the scale factor
  58775. * @param result defines the Vector3 object where to store the result
  58776. * @returns the unmodified current Vector3
  58777. */
  58778. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58779. /**
  58780. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58781. * @param otherVector defines the second operand
  58782. * @returns true if both vectors are equals
  58783. */
  58784. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58785. /**
  58786. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58787. * @param otherVector defines the second operand
  58788. * @param epsilon defines the minimal distance to define values as equals
  58789. * @returns true if both vectors are distant less than epsilon
  58790. */
  58791. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58792. /**
  58793. * Returns true if the current Vector3 coordinates equals the given floats
  58794. * @param x defines the x coordinate of the operand
  58795. * @param y defines the y coordinate of the operand
  58796. * @param z defines the z coordinate of the operand
  58797. * @returns true if both vectors are equals
  58798. */
  58799. equalsToFloats(x: number, y: number, z: number): boolean;
  58800. /**
  58801. * Multiplies the current Vector3 coordinates by the given ones
  58802. * @param otherVector defines the second operand
  58803. * @returns the current updated Vector3
  58804. */
  58805. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58806. /**
  58807. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58808. * @param otherVector defines the second operand
  58809. * @returns the new Vector3
  58810. */
  58811. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58812. /**
  58813. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58814. * @param otherVector defines the second operand
  58815. * @param result defines the Vector3 object where to store the result
  58816. * @returns the current Vector3
  58817. */
  58818. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58819. /**
  58820. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58821. * @param x defines the x coordinate of the operand
  58822. * @param y defines the y coordinate of the operand
  58823. * @param z defines the z coordinate of the operand
  58824. * @returns the new Vector3
  58825. */
  58826. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58827. /**
  58828. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58829. * @param otherVector defines the second operand
  58830. * @returns the new Vector3
  58831. */
  58832. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58833. /**
  58834. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58835. * @param otherVector defines the second operand
  58836. * @param result defines the Vector3 object where to store the result
  58837. * @returns the current Vector3
  58838. */
  58839. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58840. /**
  58841. * Divides the current Vector3 coordinates by the given ones.
  58842. * @param otherVector defines the second operand
  58843. * @returns the current updated Vector3
  58844. */
  58845. divideInPlace(otherVector: Vector3): Vector3;
  58846. /**
  58847. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58848. * @param other defines the second operand
  58849. * @returns the current updated Vector3
  58850. */
  58851. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58852. /**
  58853. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58854. * @param other defines the second operand
  58855. * @returns the current updated Vector3
  58856. */
  58857. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58858. /**
  58859. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58860. * @param x defines the x coordinate of the operand
  58861. * @param y defines the y coordinate of the operand
  58862. * @param z defines the z coordinate of the operand
  58863. * @returns the current updated Vector3
  58864. */
  58865. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58866. /**
  58867. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58868. * @param x defines the x coordinate of the operand
  58869. * @param y defines the y coordinate of the operand
  58870. * @param z defines the z coordinate of the operand
  58871. * @returns the current updated Vector3
  58872. */
  58873. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58874. /**
  58875. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58876. * Check if is non uniform within a certain amount of decimal places to account for this
  58877. * @param epsilon the amount the values can differ
  58878. * @returns if the the vector is non uniform to a certain number of decimal places
  58879. */
  58880. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58881. /**
  58882. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58883. */
  58884. readonly isNonUniform: boolean;
  58885. /**
  58886. * Gets a new Vector3 from current Vector3 floored values
  58887. * @returns a new Vector3
  58888. */
  58889. floor(): Vector3;
  58890. /**
  58891. * Gets a new Vector3 from current Vector3 floored values
  58892. * @returns a new Vector3
  58893. */
  58894. fract(): Vector3;
  58895. /**
  58896. * Gets the length of the Vector3
  58897. * @returns the length of the Vecto3
  58898. */
  58899. length(): number;
  58900. /**
  58901. * Gets the squared length of the Vector3
  58902. * @returns squared length of the Vector3
  58903. */
  58904. lengthSquared(): number;
  58905. /**
  58906. * Normalize the current Vector3.
  58907. * Please note that this is an in place operation.
  58908. * @returns the current updated Vector3
  58909. */
  58910. normalize(): Vector3;
  58911. /**
  58912. * Reorders the x y z properties of the vector in place
  58913. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58914. * @returns the current updated vector
  58915. */
  58916. reorderInPlace(order: string): this;
  58917. /**
  58918. * Rotates the vector around 0,0,0 by a quaternion
  58919. * @param quaternion the rotation quaternion
  58920. * @param result vector to store the result
  58921. * @returns the resulting vector
  58922. */
  58923. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58924. /**
  58925. * Rotates a vector around a given point
  58926. * @param quaternion the rotation quaternion
  58927. * @param point the point to rotate around
  58928. * @param result vector to store the result
  58929. * @returns the resulting vector
  58930. */
  58931. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58932. /**
  58933. * Normalize the current Vector3 with the given input length.
  58934. * Please note that this is an in place operation.
  58935. * @param len the length of the vector
  58936. * @returns the current updated Vector3
  58937. */
  58938. normalizeFromLength(len: number): Vector3;
  58939. /**
  58940. * Normalize the current Vector3 to a new vector
  58941. * @returns the new Vector3
  58942. */
  58943. normalizeToNew(): Vector3;
  58944. /**
  58945. * Normalize the current Vector3 to the reference
  58946. * @param reference define the Vector3 to update
  58947. * @returns the updated Vector3
  58948. */
  58949. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58950. /**
  58951. * Creates a new Vector3 copied from the current Vector3
  58952. * @returns the new Vector3
  58953. */
  58954. clone(): Vector3;
  58955. /**
  58956. * Copies the given vector coordinates to the current Vector3 ones
  58957. * @param source defines the source Vector3
  58958. * @returns the current updated Vector3
  58959. */
  58960. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58961. /**
  58962. * Copies the given floats to the current Vector3 coordinates
  58963. * @param x defines the x coordinate of the operand
  58964. * @param y defines the y coordinate of the operand
  58965. * @param z defines the z coordinate of the operand
  58966. * @returns the current updated Vector3
  58967. */
  58968. copyFromFloats(x: number, y: number, z: number): Vector3;
  58969. /**
  58970. * Copies the given floats to the current Vector3 coordinates
  58971. * @param x defines the x coordinate of the operand
  58972. * @param y defines the y coordinate of the operand
  58973. * @param z defines the z coordinate of the operand
  58974. * @returns the current updated Vector3
  58975. */
  58976. set(x: number, y: number, z: number): Vector3;
  58977. /**
  58978. * Copies the given float to the current Vector3 coordinates
  58979. * @param v defines the x, y and z coordinates of the operand
  58980. * @returns the current updated Vector3
  58981. */
  58982. setAll(v: number): Vector3;
  58983. /**
  58984. * Get the clip factor between two vectors
  58985. * @param vector0 defines the first operand
  58986. * @param vector1 defines the second operand
  58987. * @param axis defines the axis to use
  58988. * @param size defines the size along the axis
  58989. * @returns the clip factor
  58990. */
  58991. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58992. /**
  58993. * Get angle between two vectors
  58994. * @param vector0 angle between vector0 and vector1
  58995. * @param vector1 angle between vector0 and vector1
  58996. * @param normal direction of the normal
  58997. * @return the angle between vector0 and vector1
  58998. */
  58999. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59000. /**
  59001. * Returns a new Vector3 set from the index "offset" of the given array
  59002. * @param array defines the source array
  59003. * @param offset defines the offset in the source array
  59004. * @returns the new Vector3
  59005. */
  59006. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59007. /**
  59008. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59009. * This function is deprecated. Use FromArray instead
  59010. * @param array defines the source array
  59011. * @param offset defines the offset in the source array
  59012. * @returns the new Vector3
  59013. */
  59014. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59015. /**
  59016. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59017. * @param array defines the source array
  59018. * @param offset defines the offset in the source array
  59019. * @param result defines the Vector3 where to store the result
  59020. */
  59021. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59022. /**
  59023. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59024. * This function is deprecated. Use FromArrayToRef instead.
  59025. * @param array defines the source array
  59026. * @param offset defines the offset in the source array
  59027. * @param result defines the Vector3 where to store the result
  59028. */
  59029. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59030. /**
  59031. * Sets the given vector "result" with the given floats.
  59032. * @param x defines the x coordinate of the source
  59033. * @param y defines the y coordinate of the source
  59034. * @param z defines the z coordinate of the source
  59035. * @param result defines the Vector3 where to store the result
  59036. */
  59037. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59038. /**
  59039. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59040. * @returns a new empty Vector3
  59041. */
  59042. static Zero(): Vector3;
  59043. /**
  59044. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59045. * @returns a new unit Vector3
  59046. */
  59047. static One(): Vector3;
  59048. /**
  59049. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59050. * @returns a new up Vector3
  59051. */
  59052. static Up(): Vector3;
  59053. /**
  59054. * Gets a up Vector3 that must not be updated
  59055. */
  59056. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59057. /**
  59058. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59059. * @returns a new down Vector3
  59060. */
  59061. static Down(): Vector3;
  59062. /**
  59063. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59064. * @returns a new forward Vector3
  59065. */
  59066. static Forward(): Vector3;
  59067. /**
  59068. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59069. * @returns a new forward Vector3
  59070. */
  59071. static Backward(): Vector3;
  59072. /**
  59073. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59074. * @returns a new right Vector3
  59075. */
  59076. static Right(): Vector3;
  59077. /**
  59078. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59079. * @returns a new left Vector3
  59080. */
  59081. static Left(): Vector3;
  59082. /**
  59083. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59084. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59085. * @param vector defines the Vector3 to transform
  59086. * @param transformation defines the transformation matrix
  59087. * @returns the transformed Vector3
  59088. */
  59089. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59090. /**
  59091. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59092. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59093. * @param vector defines the Vector3 to transform
  59094. * @param transformation defines the transformation matrix
  59095. * @param result defines the Vector3 where to store the result
  59096. */
  59097. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59098. /**
  59099. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59100. * This method computes tranformed coordinates only, not transformed direction vectors
  59101. * @param x define the x coordinate of the source vector
  59102. * @param y define the y coordinate of the source vector
  59103. * @param z define the z coordinate of the source vector
  59104. * @param transformation defines the transformation matrix
  59105. * @param result defines the Vector3 where to store the result
  59106. */
  59107. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59108. /**
  59109. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59110. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59111. * @param vector defines the Vector3 to transform
  59112. * @param transformation defines the transformation matrix
  59113. * @returns the new Vector3
  59114. */
  59115. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59116. /**
  59117. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59118. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59119. * @param vector defines the Vector3 to transform
  59120. * @param transformation defines the transformation matrix
  59121. * @param result defines the Vector3 where to store the result
  59122. */
  59123. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59124. /**
  59125. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59126. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59127. * @param x define the x coordinate of the source vector
  59128. * @param y define the y coordinate of the source vector
  59129. * @param z define the z coordinate of the source vector
  59130. * @param transformation defines the transformation matrix
  59131. * @param result defines the Vector3 where to store the result
  59132. */
  59133. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59134. /**
  59135. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59136. * @param value1 defines the first control point
  59137. * @param value2 defines the second control point
  59138. * @param value3 defines the third control point
  59139. * @param value4 defines the fourth control point
  59140. * @param amount defines the amount on the spline to use
  59141. * @returns the new Vector3
  59142. */
  59143. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59144. /**
  59145. * 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"
  59146. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59147. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59148. * @param value defines the current value
  59149. * @param min defines the lower range value
  59150. * @param max defines the upper range value
  59151. * @returns the new Vector3
  59152. */
  59153. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59154. /**
  59155. * 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"
  59156. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59157. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59158. * @param value defines the current value
  59159. * @param min defines the lower range value
  59160. * @param max defines the upper range value
  59161. * @param result defines the Vector3 where to store the result
  59162. */
  59163. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59164. /**
  59165. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59166. * @param value1 defines the first control point
  59167. * @param tangent1 defines the first tangent vector
  59168. * @param value2 defines the second control point
  59169. * @param tangent2 defines the second tangent vector
  59170. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59171. * @returns the new Vector3
  59172. */
  59173. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59174. /**
  59175. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59176. * @param start defines the start value
  59177. * @param end defines the end value
  59178. * @param amount max defines amount between both (between 0 and 1)
  59179. * @returns the new Vector3
  59180. */
  59181. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59182. /**
  59183. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59184. * @param start defines the start value
  59185. * @param end defines the end value
  59186. * @param amount max defines amount between both (between 0 and 1)
  59187. * @param result defines the Vector3 where to store the result
  59188. */
  59189. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59190. /**
  59191. * Returns the dot product (float) between the vectors "left" and "right"
  59192. * @param left defines the left operand
  59193. * @param right defines the right operand
  59194. * @returns the dot product
  59195. */
  59196. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59197. /**
  59198. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59199. * The cross product is then orthogonal to both "left" and "right"
  59200. * @param left defines the left operand
  59201. * @param right defines the right operand
  59202. * @returns the cross product
  59203. */
  59204. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59205. /**
  59206. * Sets the given vector "result" with the cross product of "left" and "right"
  59207. * The cross product is then orthogonal to both "left" and "right"
  59208. * @param left defines the left operand
  59209. * @param right defines the right operand
  59210. * @param result defines the Vector3 where to store the result
  59211. */
  59212. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59213. /**
  59214. * Returns a new Vector3 as the normalization of the given vector
  59215. * @param vector defines the Vector3 to normalize
  59216. * @returns the new Vector3
  59217. */
  59218. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59219. /**
  59220. * Sets the given vector "result" with the normalization of the given first vector
  59221. * @param vector defines the Vector3 to normalize
  59222. * @param result defines the Vector3 where to store the result
  59223. */
  59224. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59225. /**
  59226. * Project a Vector3 onto screen space
  59227. * @param vector defines the Vector3 to project
  59228. * @param world defines the world matrix to use
  59229. * @param transform defines the transform (view x projection) matrix to use
  59230. * @param viewport defines the screen viewport to use
  59231. * @returns the new Vector3
  59232. */
  59233. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59234. /** @hidden */
  59235. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59236. /**
  59237. * Unproject from screen space to object space
  59238. * @param source defines the screen space Vector3 to use
  59239. * @param viewportWidth defines the current width of the viewport
  59240. * @param viewportHeight defines the current height of the viewport
  59241. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59242. * @param transform defines the transform (view x projection) matrix to use
  59243. * @returns the new Vector3
  59244. */
  59245. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59246. /**
  59247. * Unproject from screen space to object space
  59248. * @param source defines the screen space Vector3 to use
  59249. * @param viewportWidth defines the current width of the viewport
  59250. * @param viewportHeight defines the current height of the viewport
  59251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59252. * @param view defines the view matrix to use
  59253. * @param projection defines the projection matrix to use
  59254. * @returns the new Vector3
  59255. */
  59256. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59257. /**
  59258. * Unproject from screen space to object space
  59259. * @param source defines the screen space Vector3 to use
  59260. * @param viewportWidth defines the current width of the viewport
  59261. * @param viewportHeight defines the current height of the viewport
  59262. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59263. * @param view defines the view matrix to use
  59264. * @param projection defines the projection matrix to use
  59265. * @param result defines the Vector3 where to store the result
  59266. */
  59267. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59268. /**
  59269. * Unproject from screen space to object space
  59270. * @param sourceX defines the screen space x coordinate to use
  59271. * @param sourceY defines the screen space y coordinate to use
  59272. * @param sourceZ defines the screen space z coordinate to use
  59273. * @param viewportWidth defines the current width of the viewport
  59274. * @param viewportHeight defines the current height of the viewport
  59275. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59276. * @param view defines the view matrix to use
  59277. * @param projection defines the projection matrix to use
  59278. * @param result defines the Vector3 where to store the result
  59279. */
  59280. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59281. /**
  59282. * Gets the minimal coordinate values between two Vector3
  59283. * @param left defines the first operand
  59284. * @param right defines the second operand
  59285. * @returns the new Vector3
  59286. */
  59287. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59288. /**
  59289. * Gets the maximal coordinate values between two Vector3
  59290. * @param left defines the first operand
  59291. * @param right defines the second operand
  59292. * @returns the new Vector3
  59293. */
  59294. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59295. /**
  59296. * Returns the distance between the vectors "value1" and "value2"
  59297. * @param value1 defines the first operand
  59298. * @param value2 defines the second operand
  59299. * @returns the distance
  59300. */
  59301. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59302. /**
  59303. * Returns the squared distance between the vectors "value1" and "value2"
  59304. * @param value1 defines the first operand
  59305. * @param value2 defines the second operand
  59306. * @returns the squared distance
  59307. */
  59308. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59309. /**
  59310. * Returns a new Vector3 located at the center between "value1" and "value2"
  59311. * @param value1 defines the first operand
  59312. * @param value2 defines the second operand
  59313. * @returns the new Vector3
  59314. */
  59315. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59316. /**
  59317. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59318. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59319. * to something in order to rotate it from its local system to the given target system
  59320. * Note: axis1, axis2 and axis3 are normalized during this operation
  59321. * @param axis1 defines the first axis
  59322. * @param axis2 defines the second axis
  59323. * @param axis3 defines the third axis
  59324. * @returns a new Vector3
  59325. */
  59326. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59327. /**
  59328. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59329. * @param axis1 defines the first axis
  59330. * @param axis2 defines the second axis
  59331. * @param axis3 defines the third axis
  59332. * @param ref defines the Vector3 where to store the result
  59333. */
  59334. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59335. }
  59336. /**
  59337. * Vector4 class created for EulerAngle class conversion to Quaternion
  59338. */
  59339. export class Vector4 {
  59340. /** x value of the vector */
  59341. x: number;
  59342. /** y value of the vector */
  59343. y: number;
  59344. /** z value of the vector */
  59345. z: number;
  59346. /** w value of the vector */
  59347. w: number;
  59348. /**
  59349. * Creates a Vector4 object from the given floats.
  59350. * @param x x value of the vector
  59351. * @param y y value of the vector
  59352. * @param z z value of the vector
  59353. * @param w w value of the vector
  59354. */
  59355. constructor(
  59356. /** x value of the vector */
  59357. x: number,
  59358. /** y value of the vector */
  59359. y: number,
  59360. /** z value of the vector */
  59361. z: number,
  59362. /** w value of the vector */
  59363. w: number);
  59364. /**
  59365. * Returns the string with the Vector4 coordinates.
  59366. * @returns a string containing all the vector values
  59367. */
  59368. toString(): string;
  59369. /**
  59370. * Returns the string "Vector4".
  59371. * @returns "Vector4"
  59372. */
  59373. getClassName(): string;
  59374. /**
  59375. * Returns the Vector4 hash code.
  59376. * @returns a unique hash code
  59377. */
  59378. getHashCode(): number;
  59379. /**
  59380. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59381. * @returns the resulting array
  59382. */
  59383. asArray(): number[];
  59384. /**
  59385. * Populates the given array from the given index with the Vector4 coordinates.
  59386. * @param array array to populate
  59387. * @param index index of the array to start at (default: 0)
  59388. * @returns the Vector4.
  59389. */
  59390. toArray(array: FloatArray, index?: number): Vector4;
  59391. /**
  59392. * Adds the given vector to the current Vector4.
  59393. * @param otherVector the vector to add
  59394. * @returns the updated Vector4.
  59395. */
  59396. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59397. /**
  59398. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59399. * @param otherVector the vector to add
  59400. * @returns the resulting vector
  59401. */
  59402. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59403. /**
  59404. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59405. * @param otherVector the vector to add
  59406. * @param result the vector to store the result
  59407. * @returns the current Vector4.
  59408. */
  59409. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59410. /**
  59411. * Subtract in place the given vector from the current Vector4.
  59412. * @param otherVector the vector to subtract
  59413. * @returns the updated Vector4.
  59414. */
  59415. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59416. /**
  59417. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59418. * @param otherVector the vector to add
  59419. * @returns the new vector with the result
  59420. */
  59421. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59422. /**
  59423. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59424. * @param otherVector the vector to subtract
  59425. * @param result the vector to store the result
  59426. * @returns the current Vector4.
  59427. */
  59428. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59429. /**
  59430. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59431. */
  59432. /**
  59433. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59434. * @param x value to subtract
  59435. * @param y value to subtract
  59436. * @param z value to subtract
  59437. * @param w value to subtract
  59438. * @returns new vector containing the result
  59439. */
  59440. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59441. /**
  59442. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59443. * @param x value to subtract
  59444. * @param y value to subtract
  59445. * @param z value to subtract
  59446. * @param w value to subtract
  59447. * @param result the vector to store the result in
  59448. * @returns the current Vector4.
  59449. */
  59450. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59451. /**
  59452. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59453. * @returns a new vector with the negated values
  59454. */
  59455. negate(): Vector4;
  59456. /**
  59457. * Multiplies the current Vector4 coordinates by scale (float).
  59458. * @param scale the number to scale with
  59459. * @returns the updated Vector4.
  59460. */
  59461. scaleInPlace(scale: number): Vector4;
  59462. /**
  59463. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59464. * @param scale the number to scale with
  59465. * @returns a new vector with the result
  59466. */
  59467. scale(scale: number): Vector4;
  59468. /**
  59469. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59470. * @param scale the number to scale with
  59471. * @param result a vector to store the result in
  59472. * @returns the current Vector4.
  59473. */
  59474. scaleToRef(scale: number, result: Vector4): Vector4;
  59475. /**
  59476. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59477. * @param scale defines the scale factor
  59478. * @param result defines the Vector4 object where to store the result
  59479. * @returns the unmodified current Vector4
  59480. */
  59481. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59482. /**
  59483. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59484. * @param otherVector the vector to compare against
  59485. * @returns true if they are equal
  59486. */
  59487. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59488. /**
  59489. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59490. * @param otherVector vector to compare against
  59491. * @param epsilon (Default: very small number)
  59492. * @returns true if they are equal
  59493. */
  59494. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59495. /**
  59496. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59497. * @param x x value to compare against
  59498. * @param y y value to compare against
  59499. * @param z z value to compare against
  59500. * @param w w value to compare against
  59501. * @returns true if equal
  59502. */
  59503. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59504. /**
  59505. * Multiplies in place the current Vector4 by the given one.
  59506. * @param otherVector vector to multiple with
  59507. * @returns the updated Vector4.
  59508. */
  59509. multiplyInPlace(otherVector: Vector4): Vector4;
  59510. /**
  59511. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59512. * @param otherVector vector to multiple with
  59513. * @returns resulting new vector
  59514. */
  59515. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59516. /**
  59517. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59518. * @param otherVector vector to multiple with
  59519. * @param result vector to store the result
  59520. * @returns the current Vector4.
  59521. */
  59522. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59523. /**
  59524. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59525. * @param x x value multiply with
  59526. * @param y y value multiply with
  59527. * @param z z value multiply with
  59528. * @param w w value multiply with
  59529. * @returns resulting new vector
  59530. */
  59531. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59532. /**
  59533. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59534. * @param otherVector vector to devide with
  59535. * @returns resulting new vector
  59536. */
  59537. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59538. /**
  59539. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59540. * @param otherVector vector to devide with
  59541. * @param result vector to store the result
  59542. * @returns the current Vector4.
  59543. */
  59544. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59545. /**
  59546. * Divides the current Vector3 coordinates by the given ones.
  59547. * @param otherVector vector to devide with
  59548. * @returns the updated Vector3.
  59549. */
  59550. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59551. /**
  59552. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59553. * @param other defines the second operand
  59554. * @returns the current updated Vector4
  59555. */
  59556. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59557. /**
  59558. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59559. * @param other defines the second operand
  59560. * @returns the current updated Vector4
  59561. */
  59562. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59563. /**
  59564. * Gets a new Vector4 from current Vector4 floored values
  59565. * @returns a new Vector4
  59566. */
  59567. floor(): Vector4;
  59568. /**
  59569. * Gets a new Vector4 from current Vector3 floored values
  59570. * @returns a new Vector4
  59571. */
  59572. fract(): Vector4;
  59573. /**
  59574. * Returns the Vector4 length (float).
  59575. * @returns the length
  59576. */
  59577. length(): number;
  59578. /**
  59579. * Returns the Vector4 squared length (float).
  59580. * @returns the length squared
  59581. */
  59582. lengthSquared(): number;
  59583. /**
  59584. * Normalizes in place the Vector4.
  59585. * @returns the updated Vector4.
  59586. */
  59587. normalize(): Vector4;
  59588. /**
  59589. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59590. * @returns this converted to a new vector3
  59591. */
  59592. toVector3(): Vector3;
  59593. /**
  59594. * Returns a new Vector4 copied from the current one.
  59595. * @returns the new cloned vector
  59596. */
  59597. clone(): Vector4;
  59598. /**
  59599. * Updates the current Vector4 with the given one coordinates.
  59600. * @param source the source vector to copy from
  59601. * @returns the updated Vector4.
  59602. */
  59603. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59604. /**
  59605. * Updates the current Vector4 coordinates with the given floats.
  59606. * @param x float to copy from
  59607. * @param y float to copy from
  59608. * @param z float to copy from
  59609. * @param w float to copy from
  59610. * @returns the updated Vector4.
  59611. */
  59612. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59613. /**
  59614. * Updates the current Vector4 coordinates with the given floats.
  59615. * @param x float to set from
  59616. * @param y float to set from
  59617. * @param z float to set from
  59618. * @param w float to set from
  59619. * @returns the updated Vector4.
  59620. */
  59621. set(x: number, y: number, z: number, w: number): Vector4;
  59622. /**
  59623. * Copies the given float to the current Vector3 coordinates
  59624. * @param v defines the x, y, z and w coordinates of the operand
  59625. * @returns the current updated Vector3
  59626. */
  59627. setAll(v: number): Vector4;
  59628. /**
  59629. * Returns a new Vector4 set from the starting index of the given array.
  59630. * @param array the array to pull values from
  59631. * @param offset the offset into the array to start at
  59632. * @returns the new vector
  59633. */
  59634. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59635. /**
  59636. * Updates the given vector "result" from the starting index of the given array.
  59637. * @param array the array to pull values from
  59638. * @param offset the offset into the array to start at
  59639. * @param result the vector to store the result in
  59640. */
  59641. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59642. /**
  59643. * Updates the given vector "result" from the starting index of the given Float32Array.
  59644. * @param array the array to pull values from
  59645. * @param offset the offset into the array to start at
  59646. * @param result the vector to store the result in
  59647. */
  59648. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59649. /**
  59650. * Updates the given vector "result" coordinates from the given floats.
  59651. * @param x float to set from
  59652. * @param y float to set from
  59653. * @param z float to set from
  59654. * @param w float to set from
  59655. * @param result the vector to the floats in
  59656. */
  59657. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59658. /**
  59659. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59660. * @returns the new vector
  59661. */
  59662. static Zero(): Vector4;
  59663. /**
  59664. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59665. * @returns the new vector
  59666. */
  59667. static One(): Vector4;
  59668. /**
  59669. * Returns a new normalized Vector4 from the given one.
  59670. * @param vector the vector to normalize
  59671. * @returns the vector
  59672. */
  59673. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59674. /**
  59675. * Updates the given vector "result" from the normalization of the given one.
  59676. * @param vector the vector to normalize
  59677. * @param result the vector to store the result in
  59678. */
  59679. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59680. /**
  59681. * Returns a vector with the minimum values from the left and right vectors
  59682. * @param left left vector to minimize
  59683. * @param right right vector to minimize
  59684. * @returns a new vector with the minimum of the left and right vector values
  59685. */
  59686. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59687. /**
  59688. * Returns a vector with the maximum values from the left and right vectors
  59689. * @param left left vector to maximize
  59690. * @param right right vector to maximize
  59691. * @returns a new vector with the maximum of the left and right vector values
  59692. */
  59693. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59694. /**
  59695. * Returns the distance (float) between the vectors "value1" and "value2".
  59696. * @param value1 value to calulate the distance between
  59697. * @param value2 value to calulate the distance between
  59698. * @return the distance between the two vectors
  59699. */
  59700. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59701. /**
  59702. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59703. * @param value1 value to calulate the distance between
  59704. * @param value2 value to calulate the distance between
  59705. * @return the distance between the two vectors squared
  59706. */
  59707. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59708. /**
  59709. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59710. * @param value1 value to calulate the center between
  59711. * @param value2 value to calulate the center between
  59712. * @return the center between the two vectors
  59713. */
  59714. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59715. /**
  59716. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59717. * This methods computes transformed normalized direction vectors only.
  59718. * @param vector the vector to transform
  59719. * @param transformation the transformation matrix to apply
  59720. * @returns the new vector
  59721. */
  59722. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59723. /**
  59724. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59725. * This methods computes transformed normalized direction vectors only.
  59726. * @param vector the vector to transform
  59727. * @param transformation the transformation matrix to apply
  59728. * @param result the vector to store the result in
  59729. */
  59730. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59731. /**
  59732. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59733. * This methods computes transformed normalized direction vectors only.
  59734. * @param x value to transform
  59735. * @param y value to transform
  59736. * @param z value to transform
  59737. * @param w value to transform
  59738. * @param transformation the transformation matrix to apply
  59739. * @param result the vector to store the results in
  59740. */
  59741. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59742. /**
  59743. * Creates a new Vector4 from a Vector3
  59744. * @param source defines the source data
  59745. * @param w defines the 4th component (default is 0)
  59746. * @returns a new Vector4
  59747. */
  59748. static FromVector3(source: Vector3, w?: number): Vector4;
  59749. }
  59750. /**
  59751. * Interface for the size containing width and height
  59752. */
  59753. export interface ISize {
  59754. /**
  59755. * Width
  59756. */
  59757. width: number;
  59758. /**
  59759. * Heighht
  59760. */
  59761. height: number;
  59762. }
  59763. /**
  59764. * Size containing widht and height
  59765. */
  59766. export class Size implements ISize {
  59767. /**
  59768. * Width
  59769. */
  59770. width: number;
  59771. /**
  59772. * Height
  59773. */
  59774. height: number;
  59775. /**
  59776. * Creates a Size object from the given width and height (floats).
  59777. * @param width width of the new size
  59778. * @param height height of the new size
  59779. */
  59780. constructor(width: number, height: number);
  59781. /**
  59782. * Returns a string with the Size width and height
  59783. * @returns a string with the Size width and height
  59784. */
  59785. toString(): string;
  59786. /**
  59787. * "Size"
  59788. * @returns the string "Size"
  59789. */
  59790. getClassName(): string;
  59791. /**
  59792. * Returns the Size hash code.
  59793. * @returns a hash code for a unique width and height
  59794. */
  59795. getHashCode(): number;
  59796. /**
  59797. * Updates the current size from the given one.
  59798. * @param src the given size
  59799. */
  59800. copyFrom(src: Size): void;
  59801. /**
  59802. * Updates in place the current Size from the given floats.
  59803. * @param width width of the new size
  59804. * @param height height of the new size
  59805. * @returns the updated Size.
  59806. */
  59807. copyFromFloats(width: number, height: number): Size;
  59808. /**
  59809. * Updates in place the current Size from the given floats.
  59810. * @param width width to set
  59811. * @param height height to set
  59812. * @returns the updated Size.
  59813. */
  59814. set(width: number, height: number): Size;
  59815. /**
  59816. * Multiplies the width and height by numbers
  59817. * @param w factor to multiple the width by
  59818. * @param h factor to multiple the height by
  59819. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59820. */
  59821. multiplyByFloats(w: number, h: number): Size;
  59822. /**
  59823. * Clones the size
  59824. * @returns a new Size copied from the given one.
  59825. */
  59826. clone(): Size;
  59827. /**
  59828. * True if the current Size and the given one width and height are strictly equal.
  59829. * @param other the other size to compare against
  59830. * @returns True if the current Size and the given one width and height are strictly equal.
  59831. */
  59832. equals(other: Size): boolean;
  59833. /**
  59834. * The surface of the Size : width * height (float).
  59835. */
  59836. readonly surface: number;
  59837. /**
  59838. * Create a new size of zero
  59839. * @returns a new Size set to (0.0, 0.0)
  59840. */
  59841. static Zero(): Size;
  59842. /**
  59843. * Sums the width and height of two sizes
  59844. * @param otherSize size to add to this size
  59845. * @returns a new Size set as the addition result of the current Size and the given one.
  59846. */
  59847. add(otherSize: Size): Size;
  59848. /**
  59849. * Subtracts the width and height of two
  59850. * @param otherSize size to subtract to this size
  59851. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59852. */
  59853. subtract(otherSize: Size): Size;
  59854. /**
  59855. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59856. * @param start starting size to lerp between
  59857. * @param end end size to lerp between
  59858. * @param amount amount to lerp between the start and end values
  59859. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59860. */
  59861. static Lerp(start: Size, end: Size, amount: number): Size;
  59862. }
  59863. /**
  59864. * Class used to store quaternion data
  59865. * @see https://en.wikipedia.org/wiki/Quaternion
  59866. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59867. */
  59868. export class Quaternion {
  59869. /** defines the first component (0 by default) */
  59870. x: number;
  59871. /** defines the second component (0 by default) */
  59872. y: number;
  59873. /** defines the third component (0 by default) */
  59874. z: number;
  59875. /** defines the fourth component (1.0 by default) */
  59876. w: number;
  59877. /**
  59878. * Creates a new Quaternion from the given floats
  59879. * @param x defines the first component (0 by default)
  59880. * @param y defines the second component (0 by default)
  59881. * @param z defines the third component (0 by default)
  59882. * @param w defines the fourth component (1.0 by default)
  59883. */
  59884. constructor(
  59885. /** defines the first component (0 by default) */
  59886. x?: number,
  59887. /** defines the second component (0 by default) */
  59888. y?: number,
  59889. /** defines the third component (0 by default) */
  59890. z?: number,
  59891. /** defines the fourth component (1.0 by default) */
  59892. w?: number);
  59893. /**
  59894. * Gets a string representation for the current quaternion
  59895. * @returns a string with the Quaternion coordinates
  59896. */
  59897. toString(): string;
  59898. /**
  59899. * Gets the class name of the quaternion
  59900. * @returns the string "Quaternion"
  59901. */
  59902. getClassName(): string;
  59903. /**
  59904. * Gets a hash code for this quaternion
  59905. * @returns the quaternion hash code
  59906. */
  59907. getHashCode(): number;
  59908. /**
  59909. * Copy the quaternion to an array
  59910. * @returns a new array populated with 4 elements from the quaternion coordinates
  59911. */
  59912. asArray(): number[];
  59913. /**
  59914. * Check if two quaternions are equals
  59915. * @param otherQuaternion defines the second operand
  59916. * @return true if the current quaternion and the given one coordinates are strictly equals
  59917. */
  59918. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59919. /**
  59920. * Clone the current quaternion
  59921. * @returns a new quaternion copied from the current one
  59922. */
  59923. clone(): Quaternion;
  59924. /**
  59925. * Copy a quaternion to the current one
  59926. * @param other defines the other quaternion
  59927. * @returns the updated current quaternion
  59928. */
  59929. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59930. /**
  59931. * Updates the current quaternion with the given float coordinates
  59932. * @param x defines the x coordinate
  59933. * @param y defines the y coordinate
  59934. * @param z defines the z coordinate
  59935. * @param w defines the w coordinate
  59936. * @returns the updated current quaternion
  59937. */
  59938. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59939. /**
  59940. * Updates the current quaternion from the given float coordinates
  59941. * @param x defines the x coordinate
  59942. * @param y defines the y coordinate
  59943. * @param z defines the z coordinate
  59944. * @param w defines the w coordinate
  59945. * @returns the updated current quaternion
  59946. */
  59947. set(x: number, y: number, z: number, w: number): Quaternion;
  59948. /**
  59949. * Adds two quaternions
  59950. * @param other defines the second operand
  59951. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59952. */
  59953. add(other: DeepImmutable<Quaternion>): Quaternion;
  59954. /**
  59955. * Add a quaternion to the current one
  59956. * @param other defines the quaternion to add
  59957. * @returns the current quaternion
  59958. */
  59959. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59960. /**
  59961. * Subtract two quaternions
  59962. * @param other defines the second operand
  59963. * @returns a new quaternion as the subtraction result of the given one from the current one
  59964. */
  59965. subtract(other: Quaternion): Quaternion;
  59966. /**
  59967. * Multiplies the current quaternion by a scale factor
  59968. * @param value defines the scale factor
  59969. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59970. */
  59971. scale(value: number): Quaternion;
  59972. /**
  59973. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59974. * @param scale defines the scale factor
  59975. * @param result defines the Quaternion object where to store the result
  59976. * @returns the unmodified current quaternion
  59977. */
  59978. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59979. /**
  59980. * Multiplies in place the current quaternion by a scale factor
  59981. * @param value defines the scale factor
  59982. * @returns the current modified quaternion
  59983. */
  59984. scaleInPlace(value: number): Quaternion;
  59985. /**
  59986. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59987. * @param scale defines the scale factor
  59988. * @param result defines the Quaternion object where to store the result
  59989. * @returns the unmodified current quaternion
  59990. */
  59991. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59992. /**
  59993. * Multiplies two quaternions
  59994. * @param q1 defines the second operand
  59995. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59996. */
  59997. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59998. /**
  59999. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60000. * @param q1 defines the second operand
  60001. * @param result defines the target quaternion
  60002. * @returns the current quaternion
  60003. */
  60004. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60005. /**
  60006. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60007. * @param q1 defines the second operand
  60008. * @returns the currentupdated quaternion
  60009. */
  60010. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60011. /**
  60012. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60013. * @param ref defines the target quaternion
  60014. * @returns the current quaternion
  60015. */
  60016. conjugateToRef(ref: Quaternion): Quaternion;
  60017. /**
  60018. * Conjugates in place (1-q) the current quaternion
  60019. * @returns the current updated quaternion
  60020. */
  60021. conjugateInPlace(): Quaternion;
  60022. /**
  60023. * Conjugates in place (1-q) the current quaternion
  60024. * @returns a new quaternion
  60025. */
  60026. conjugate(): Quaternion;
  60027. /**
  60028. * Gets length of current quaternion
  60029. * @returns the quaternion length (float)
  60030. */
  60031. length(): number;
  60032. /**
  60033. * Normalize in place the current quaternion
  60034. * @returns the current updated quaternion
  60035. */
  60036. normalize(): Quaternion;
  60037. /**
  60038. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60039. * @param order is a reserved parameter and is ignore for now
  60040. * @returns a new Vector3 containing the Euler angles
  60041. */
  60042. toEulerAngles(order?: string): Vector3;
  60043. /**
  60044. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60045. * @param result defines the vector which will be filled with the Euler angles
  60046. * @param order is a reserved parameter and is ignore for now
  60047. * @returns the current unchanged quaternion
  60048. */
  60049. toEulerAnglesToRef(result: Vector3): Quaternion;
  60050. /**
  60051. * Updates the given rotation matrix with the current quaternion values
  60052. * @param result defines the target matrix
  60053. * @returns the current unchanged quaternion
  60054. */
  60055. toRotationMatrix(result: Matrix): Quaternion;
  60056. /**
  60057. * Updates the current quaternion from the given rotation matrix values
  60058. * @param matrix defines the source matrix
  60059. * @returns the current updated quaternion
  60060. */
  60061. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60062. /**
  60063. * Creates a new quaternion from a rotation matrix
  60064. * @param matrix defines the source matrix
  60065. * @returns a new quaternion created from the given rotation matrix values
  60066. */
  60067. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60068. /**
  60069. * Updates the given quaternion with the given rotation matrix values
  60070. * @param matrix defines the source matrix
  60071. * @param result defines the target quaternion
  60072. */
  60073. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60074. /**
  60075. * Returns the dot product (float) between the quaternions "left" and "right"
  60076. * @param left defines the left operand
  60077. * @param right defines the right operand
  60078. * @returns the dot product
  60079. */
  60080. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60081. /**
  60082. * Checks if the two quaternions are close to each other
  60083. * @param quat0 defines the first quaternion to check
  60084. * @param quat1 defines the second quaternion to check
  60085. * @returns true if the two quaternions are close to each other
  60086. */
  60087. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60088. /**
  60089. * Creates an empty quaternion
  60090. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60091. */
  60092. static Zero(): Quaternion;
  60093. /**
  60094. * Inverse a given quaternion
  60095. * @param q defines the source quaternion
  60096. * @returns a new quaternion as the inverted current quaternion
  60097. */
  60098. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60099. /**
  60100. * Inverse a given quaternion
  60101. * @param q defines the source quaternion
  60102. * @param result the quaternion the result will be stored in
  60103. * @returns the result quaternion
  60104. */
  60105. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60106. /**
  60107. * Creates an identity quaternion
  60108. * @returns the identity quaternion
  60109. */
  60110. static Identity(): Quaternion;
  60111. /**
  60112. * Gets a boolean indicating if the given quaternion is identity
  60113. * @param quaternion defines the quaternion to check
  60114. * @returns true if the quaternion is identity
  60115. */
  60116. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60117. /**
  60118. * Creates a quaternion from a rotation around an axis
  60119. * @param axis defines the axis to use
  60120. * @param angle defines the angle to use
  60121. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60122. */
  60123. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60124. /**
  60125. * Creates a rotation around an axis and stores it into the given quaternion
  60126. * @param axis defines the axis to use
  60127. * @param angle defines the angle to use
  60128. * @param result defines the target quaternion
  60129. * @returns the target quaternion
  60130. */
  60131. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60132. /**
  60133. * Creates a new quaternion from data stored into an array
  60134. * @param array defines the data source
  60135. * @param offset defines the offset in the source array where the data starts
  60136. * @returns a new quaternion
  60137. */
  60138. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60139. /**
  60140. * Create a quaternion from Euler rotation angles
  60141. * @param x Pitch
  60142. * @param y Yaw
  60143. * @param z Roll
  60144. * @returns the new Quaternion
  60145. */
  60146. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60147. /**
  60148. * Updates a quaternion from Euler rotation angles
  60149. * @param x Pitch
  60150. * @param y Yaw
  60151. * @param z Roll
  60152. * @param result the quaternion to store the result
  60153. * @returns the updated quaternion
  60154. */
  60155. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60156. /**
  60157. * Create a quaternion from Euler rotation vector
  60158. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60159. * @returns the new Quaternion
  60160. */
  60161. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60162. /**
  60163. * Updates a quaternion from Euler rotation vector
  60164. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60165. * @param result the quaternion to store the result
  60166. * @returns the updated quaternion
  60167. */
  60168. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60169. /**
  60170. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60171. * @param yaw defines the rotation around Y axis
  60172. * @param pitch defines the rotation around X axis
  60173. * @param roll defines the rotation around Z axis
  60174. * @returns the new quaternion
  60175. */
  60176. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60177. /**
  60178. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60179. * @param yaw defines the rotation around Y axis
  60180. * @param pitch defines the rotation around X axis
  60181. * @param roll defines the rotation around Z axis
  60182. * @param result defines the target quaternion
  60183. */
  60184. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60185. /**
  60186. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60187. * @param alpha defines the rotation around first axis
  60188. * @param beta defines the rotation around second axis
  60189. * @param gamma defines the rotation around third axis
  60190. * @returns the new quaternion
  60191. */
  60192. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60193. /**
  60194. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60195. * @param alpha defines the rotation around first axis
  60196. * @param beta defines the rotation around second axis
  60197. * @param gamma defines the rotation around third axis
  60198. * @param result defines the target quaternion
  60199. */
  60200. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60201. /**
  60202. * 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)
  60203. * @param axis1 defines the first axis
  60204. * @param axis2 defines the second axis
  60205. * @param axis3 defines the third axis
  60206. * @returns the new quaternion
  60207. */
  60208. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60209. /**
  60210. * 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
  60211. * @param axis1 defines the first axis
  60212. * @param axis2 defines the second axis
  60213. * @param axis3 defines the third axis
  60214. * @param ref defines the target quaternion
  60215. */
  60216. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60217. /**
  60218. * Interpolates between two quaternions
  60219. * @param left defines first quaternion
  60220. * @param right defines second quaternion
  60221. * @param amount defines the gradient to use
  60222. * @returns the new interpolated quaternion
  60223. */
  60224. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60225. /**
  60226. * Interpolates between two quaternions and stores it into a target quaternion
  60227. * @param left defines first quaternion
  60228. * @param right defines second quaternion
  60229. * @param amount defines the gradient to use
  60230. * @param result defines the target quaternion
  60231. */
  60232. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60233. /**
  60234. * Interpolate between two quaternions using Hermite interpolation
  60235. * @param value1 defines first quaternion
  60236. * @param tangent1 defines the incoming tangent
  60237. * @param value2 defines second quaternion
  60238. * @param tangent2 defines the outgoing tangent
  60239. * @param amount defines the target quaternion
  60240. * @returns the new interpolated quaternion
  60241. */
  60242. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60243. }
  60244. /**
  60245. * Class used to store matrix data (4x4)
  60246. */
  60247. export class Matrix {
  60248. private static _updateFlagSeed;
  60249. private static _identityReadOnly;
  60250. private _isIdentity;
  60251. private _isIdentityDirty;
  60252. private _isIdentity3x2;
  60253. private _isIdentity3x2Dirty;
  60254. /**
  60255. * Gets the update flag of the matrix which is an unique number for the matrix.
  60256. * It will be incremented every time the matrix data change.
  60257. * You can use it to speed the comparison between two versions of the same matrix.
  60258. */
  60259. updateFlag: number;
  60260. private readonly _m;
  60261. /**
  60262. * Gets the internal data of the matrix
  60263. */
  60264. readonly m: DeepImmutable<Float32Array>;
  60265. /** @hidden */
  60266. _markAsUpdated(): void;
  60267. /** @hidden */
  60268. private _updateIdentityStatus;
  60269. /**
  60270. * Creates an empty matrix (filled with zeros)
  60271. */
  60272. constructor();
  60273. /**
  60274. * Check if the current matrix is identity
  60275. * @returns true is the matrix is the identity matrix
  60276. */
  60277. isIdentity(): boolean;
  60278. /**
  60279. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60280. * @returns true is the matrix is the identity matrix
  60281. */
  60282. isIdentityAs3x2(): boolean;
  60283. /**
  60284. * Gets the determinant of the matrix
  60285. * @returns the matrix determinant
  60286. */
  60287. determinant(): number;
  60288. /**
  60289. * Returns the matrix as a Float32Array
  60290. * @returns the matrix underlying array
  60291. */
  60292. toArray(): DeepImmutable<Float32Array>;
  60293. /**
  60294. * Returns the matrix as a Float32Array
  60295. * @returns the matrix underlying array.
  60296. */
  60297. asArray(): DeepImmutable<Float32Array>;
  60298. /**
  60299. * Inverts the current matrix in place
  60300. * @returns the current inverted matrix
  60301. */
  60302. invert(): Matrix;
  60303. /**
  60304. * Sets all the matrix elements to zero
  60305. * @returns the current matrix
  60306. */
  60307. reset(): Matrix;
  60308. /**
  60309. * Adds the current matrix with a second one
  60310. * @param other defines the matrix to add
  60311. * @returns a new matrix as the addition of the current matrix and the given one
  60312. */
  60313. add(other: DeepImmutable<Matrix>): Matrix;
  60314. /**
  60315. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60316. * @param other defines the matrix to add
  60317. * @param result defines the target matrix
  60318. * @returns the current matrix
  60319. */
  60320. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60321. /**
  60322. * Adds in place the given matrix to the current matrix
  60323. * @param other defines the second operand
  60324. * @returns the current updated matrix
  60325. */
  60326. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60327. /**
  60328. * Sets the given matrix to the current inverted Matrix
  60329. * @param other defines the target matrix
  60330. * @returns the unmodified current matrix
  60331. */
  60332. invertToRef(other: Matrix): Matrix;
  60333. /**
  60334. * add a value at the specified position in the current Matrix
  60335. * @param index the index of the value within the matrix. between 0 and 15.
  60336. * @param value the value to be added
  60337. * @returns the current updated matrix
  60338. */
  60339. addAtIndex(index: number, value: number): Matrix;
  60340. /**
  60341. * mutiply the specified position in the current Matrix by a value
  60342. * @param index the index of the value within the matrix. between 0 and 15.
  60343. * @param value the value to be added
  60344. * @returns the current updated matrix
  60345. */
  60346. multiplyAtIndex(index: number, value: number): Matrix;
  60347. /**
  60348. * Inserts the translation vector (using 3 floats) in the current matrix
  60349. * @param x defines the 1st component of the translation
  60350. * @param y defines the 2nd component of the translation
  60351. * @param z defines the 3rd component of the translation
  60352. * @returns the current updated matrix
  60353. */
  60354. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60355. /**
  60356. * Inserts the translation vector in the current matrix
  60357. * @param vector3 defines the translation to insert
  60358. * @returns the current updated matrix
  60359. */
  60360. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60361. /**
  60362. * Gets the translation value of the current matrix
  60363. * @returns a new Vector3 as the extracted translation from the matrix
  60364. */
  60365. getTranslation(): Vector3;
  60366. /**
  60367. * Fill a Vector3 with the extracted translation from the matrix
  60368. * @param result defines the Vector3 where to store the translation
  60369. * @returns the current matrix
  60370. */
  60371. getTranslationToRef(result: Vector3): Matrix;
  60372. /**
  60373. * Remove rotation and scaling part from the matrix
  60374. * @returns the updated matrix
  60375. */
  60376. removeRotationAndScaling(): Matrix;
  60377. /**
  60378. * Multiply two matrices
  60379. * @param other defines the second operand
  60380. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60381. */
  60382. multiply(other: DeepImmutable<Matrix>): Matrix;
  60383. /**
  60384. * Copy the current matrix from the given one
  60385. * @param other defines the source matrix
  60386. * @returns the current updated matrix
  60387. */
  60388. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60389. /**
  60390. * Populates the given array from the starting index with the current matrix values
  60391. * @param array defines the target array
  60392. * @param offset defines the offset in the target array where to start storing values
  60393. * @returns the current matrix
  60394. */
  60395. copyToArray(array: Float32Array, offset?: number): Matrix;
  60396. /**
  60397. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60398. * @param other defines the second operand
  60399. * @param result defines the matrix where to store the multiplication
  60400. * @returns the current matrix
  60401. */
  60402. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60403. /**
  60404. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60405. * @param other defines the second operand
  60406. * @param result defines the array where to store the multiplication
  60407. * @param offset defines the offset in the target array where to start storing values
  60408. * @returns the current matrix
  60409. */
  60410. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60411. /**
  60412. * Check equality between this matrix and a second one
  60413. * @param value defines the second matrix to compare
  60414. * @returns true is the current matrix and the given one values are strictly equal
  60415. */
  60416. equals(value: DeepImmutable<Matrix>): boolean;
  60417. /**
  60418. * Clone the current matrix
  60419. * @returns a new matrix from the current matrix
  60420. */
  60421. clone(): Matrix;
  60422. /**
  60423. * Returns the name of the current matrix class
  60424. * @returns the string "Matrix"
  60425. */
  60426. getClassName(): string;
  60427. /**
  60428. * Gets the hash code of the current matrix
  60429. * @returns the hash code
  60430. */
  60431. getHashCode(): number;
  60432. /**
  60433. * Decomposes the current Matrix into a translation, rotation and scaling components
  60434. * @param scale defines the scale vector3 given as a reference to update
  60435. * @param rotation defines the rotation quaternion given as a reference to update
  60436. * @param translation defines the translation vector3 given as a reference to update
  60437. * @returns true if operation was successful
  60438. */
  60439. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60440. /**
  60441. * Gets specific row of the matrix
  60442. * @param index defines the number of the row to get
  60443. * @returns the index-th row of the current matrix as a new Vector4
  60444. */
  60445. getRow(index: number): Nullable<Vector4>;
  60446. /**
  60447. * Sets the index-th row of the current matrix to the vector4 values
  60448. * @param index defines the number of the row to set
  60449. * @param row defines the target vector4
  60450. * @returns the updated current matrix
  60451. */
  60452. setRow(index: number, row: Vector4): Matrix;
  60453. /**
  60454. * Compute the transpose of the matrix
  60455. * @returns the new transposed matrix
  60456. */
  60457. transpose(): Matrix;
  60458. /**
  60459. * Compute the transpose of the matrix and store it in a given matrix
  60460. * @param result defines the target matrix
  60461. * @returns the current matrix
  60462. */
  60463. transposeToRef(result: Matrix): Matrix;
  60464. /**
  60465. * Sets the index-th row of the current matrix with the given 4 x float values
  60466. * @param index defines the row index
  60467. * @param x defines the x component to set
  60468. * @param y defines the y component to set
  60469. * @param z defines the z component to set
  60470. * @param w defines the w component to set
  60471. * @returns the updated current matrix
  60472. */
  60473. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60474. /**
  60475. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60476. * @param scale defines the scale factor
  60477. * @returns a new matrix
  60478. */
  60479. scale(scale: number): Matrix;
  60480. /**
  60481. * Scale the current matrix values by a factor to a given result matrix
  60482. * @param scale defines the scale factor
  60483. * @param result defines the matrix to store the result
  60484. * @returns the current matrix
  60485. */
  60486. scaleToRef(scale: number, result: Matrix): Matrix;
  60487. /**
  60488. * Scale the current matrix values by a factor and add the result to a given matrix
  60489. * @param scale defines the scale factor
  60490. * @param result defines the Matrix to store the result
  60491. * @returns the current matrix
  60492. */
  60493. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60494. /**
  60495. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60496. * @param ref matrix to store the result
  60497. */
  60498. toNormalMatrix(ref: Matrix): void;
  60499. /**
  60500. * Gets only rotation part of the current matrix
  60501. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60502. */
  60503. getRotationMatrix(): Matrix;
  60504. /**
  60505. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60506. * @param result defines the target matrix to store data to
  60507. * @returns the current matrix
  60508. */
  60509. getRotationMatrixToRef(result: Matrix): Matrix;
  60510. /**
  60511. * Toggles model matrix from being right handed to left handed in place and vice versa
  60512. */
  60513. toggleModelMatrixHandInPlace(): void;
  60514. /**
  60515. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60516. */
  60517. toggleProjectionMatrixHandInPlace(): void;
  60518. /**
  60519. * Creates a matrix from an array
  60520. * @param array defines the source array
  60521. * @param offset defines an offset in the source array
  60522. * @returns a new Matrix set from the starting index of the given array
  60523. */
  60524. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60525. /**
  60526. * Copy the content of an array into a given matrix
  60527. * @param array defines the source array
  60528. * @param offset defines an offset in the source array
  60529. * @param result defines the target matrix
  60530. */
  60531. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60532. /**
  60533. * Stores an array into a matrix after having multiplied each component by a given factor
  60534. * @param array defines the source array
  60535. * @param offset defines the offset in the source array
  60536. * @param scale defines the scaling factor
  60537. * @param result defines the target matrix
  60538. */
  60539. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60540. /**
  60541. * Gets an identity matrix that must not be updated
  60542. */
  60543. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60544. /**
  60545. * Stores a list of values (16) inside a given matrix
  60546. * @param initialM11 defines 1st value of 1st row
  60547. * @param initialM12 defines 2nd value of 1st row
  60548. * @param initialM13 defines 3rd value of 1st row
  60549. * @param initialM14 defines 4th value of 1st row
  60550. * @param initialM21 defines 1st value of 2nd row
  60551. * @param initialM22 defines 2nd value of 2nd row
  60552. * @param initialM23 defines 3rd value of 2nd row
  60553. * @param initialM24 defines 4th value of 2nd row
  60554. * @param initialM31 defines 1st value of 3rd row
  60555. * @param initialM32 defines 2nd value of 3rd row
  60556. * @param initialM33 defines 3rd value of 3rd row
  60557. * @param initialM34 defines 4th value of 3rd row
  60558. * @param initialM41 defines 1st value of 4th row
  60559. * @param initialM42 defines 2nd value of 4th row
  60560. * @param initialM43 defines 3rd value of 4th row
  60561. * @param initialM44 defines 4th value of 4th row
  60562. * @param result defines the target matrix
  60563. */
  60564. 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;
  60565. /**
  60566. * Creates new matrix from a list of values (16)
  60567. * @param initialM11 defines 1st value of 1st row
  60568. * @param initialM12 defines 2nd value of 1st row
  60569. * @param initialM13 defines 3rd value of 1st row
  60570. * @param initialM14 defines 4th value of 1st row
  60571. * @param initialM21 defines 1st value of 2nd row
  60572. * @param initialM22 defines 2nd value of 2nd row
  60573. * @param initialM23 defines 3rd value of 2nd row
  60574. * @param initialM24 defines 4th value of 2nd row
  60575. * @param initialM31 defines 1st value of 3rd row
  60576. * @param initialM32 defines 2nd value of 3rd row
  60577. * @param initialM33 defines 3rd value of 3rd row
  60578. * @param initialM34 defines 4th value of 3rd row
  60579. * @param initialM41 defines 1st value of 4th row
  60580. * @param initialM42 defines 2nd value of 4th row
  60581. * @param initialM43 defines 3rd value of 4th row
  60582. * @param initialM44 defines 4th value of 4th row
  60583. * @returns the new matrix
  60584. */
  60585. 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;
  60586. /**
  60587. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60588. * @param scale defines the scale vector3
  60589. * @param rotation defines the rotation quaternion
  60590. * @param translation defines the translation vector3
  60591. * @returns a new matrix
  60592. */
  60593. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60594. /**
  60595. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60596. * @param scale defines the scale vector3
  60597. * @param rotation defines the rotation quaternion
  60598. * @param translation defines the translation vector3
  60599. * @param result defines the target matrix
  60600. */
  60601. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60602. /**
  60603. * Creates a new identity matrix
  60604. * @returns a new identity matrix
  60605. */
  60606. static Identity(): Matrix;
  60607. /**
  60608. * Creates a new identity matrix and stores the result in a given matrix
  60609. * @param result defines the target matrix
  60610. */
  60611. static IdentityToRef(result: Matrix): void;
  60612. /**
  60613. * Creates a new zero matrix
  60614. * @returns a new zero matrix
  60615. */
  60616. static Zero(): Matrix;
  60617. /**
  60618. * Creates a new rotation matrix for "angle" radians around the X axis
  60619. * @param angle defines the angle (in radians) to use
  60620. * @return the new matrix
  60621. */
  60622. static RotationX(angle: number): Matrix;
  60623. /**
  60624. * Creates a new matrix as the invert of a given matrix
  60625. * @param source defines the source matrix
  60626. * @returns the new matrix
  60627. */
  60628. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60629. /**
  60630. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60631. * @param angle defines the angle (in radians) to use
  60632. * @param result defines the target matrix
  60633. */
  60634. static RotationXToRef(angle: number, result: Matrix): void;
  60635. /**
  60636. * Creates a new rotation matrix for "angle" radians around the Y axis
  60637. * @param angle defines the angle (in radians) to use
  60638. * @return the new matrix
  60639. */
  60640. static RotationY(angle: number): Matrix;
  60641. /**
  60642. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60643. * @param angle defines the angle (in radians) to use
  60644. * @param result defines the target matrix
  60645. */
  60646. static RotationYToRef(angle: number, result: Matrix): void;
  60647. /**
  60648. * Creates a new rotation matrix for "angle" radians around the Z axis
  60649. * @param angle defines the angle (in radians) to use
  60650. * @return the new matrix
  60651. */
  60652. static RotationZ(angle: number): Matrix;
  60653. /**
  60654. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60655. * @param angle defines the angle (in radians) to use
  60656. * @param result defines the target matrix
  60657. */
  60658. static RotationZToRef(angle: number, result: Matrix): void;
  60659. /**
  60660. * Creates a new rotation matrix for "angle" radians around the given axis
  60661. * @param axis defines the axis to use
  60662. * @param angle defines the angle (in radians) to use
  60663. * @return the new matrix
  60664. */
  60665. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60666. /**
  60667. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60668. * @param axis defines the axis to use
  60669. * @param angle defines the angle (in radians) to use
  60670. * @param result defines the target matrix
  60671. */
  60672. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60673. /**
  60674. * Creates a rotation matrix
  60675. * @param yaw defines the yaw angle in radians (Y axis)
  60676. * @param pitch defines the pitch angle in radians (X axis)
  60677. * @param roll defines the roll angle in radians (X axis)
  60678. * @returns the new rotation matrix
  60679. */
  60680. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60681. /**
  60682. * Creates a rotation matrix and stores it in a given matrix
  60683. * @param yaw defines the yaw angle in radians (Y axis)
  60684. * @param pitch defines the pitch angle in radians (X axis)
  60685. * @param roll defines the roll angle in radians (X axis)
  60686. * @param result defines the target matrix
  60687. */
  60688. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60689. /**
  60690. * Creates a scaling matrix
  60691. * @param x defines the scale factor on X axis
  60692. * @param y defines the scale factor on Y axis
  60693. * @param z defines the scale factor on Z axis
  60694. * @returns the new matrix
  60695. */
  60696. static Scaling(x: number, y: number, z: number): Matrix;
  60697. /**
  60698. * Creates a scaling matrix and stores it in a given matrix
  60699. * @param x defines the scale factor on X axis
  60700. * @param y defines the scale factor on Y axis
  60701. * @param z defines the scale factor on Z axis
  60702. * @param result defines the target matrix
  60703. */
  60704. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60705. /**
  60706. * Creates a translation matrix
  60707. * @param x defines the translation on X axis
  60708. * @param y defines the translation on Y axis
  60709. * @param z defines the translationon Z axis
  60710. * @returns the new matrix
  60711. */
  60712. static Translation(x: number, y: number, z: number): Matrix;
  60713. /**
  60714. * Creates a translation matrix and stores it in a given matrix
  60715. * @param x defines the translation on X axis
  60716. * @param y defines the translation on Y axis
  60717. * @param z defines the translationon Z axis
  60718. * @param result defines the target matrix
  60719. */
  60720. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60721. /**
  60722. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60723. * @param startValue defines the start value
  60724. * @param endValue defines the end value
  60725. * @param gradient defines the gradient factor
  60726. * @returns the new matrix
  60727. */
  60728. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60729. /**
  60730. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60731. * @param startValue defines the start value
  60732. * @param endValue defines the end value
  60733. * @param gradient defines the gradient factor
  60734. * @param result defines the Matrix object where to store data
  60735. */
  60736. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60737. /**
  60738. * Builds a new matrix whose values are computed by:
  60739. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60740. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60741. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60742. * @param startValue defines the first matrix
  60743. * @param endValue defines the second matrix
  60744. * @param gradient defines the gradient between the two matrices
  60745. * @returns the new matrix
  60746. */
  60747. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60748. /**
  60749. * Update a matrix to values which are computed by:
  60750. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60751. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60752. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60753. * @param startValue defines the first matrix
  60754. * @param endValue defines the second matrix
  60755. * @param gradient defines the gradient between the two matrices
  60756. * @param result defines the target matrix
  60757. */
  60758. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60759. /**
  60760. * 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"
  60761. * This function works in left handed mode
  60762. * @param eye defines the final position of the entity
  60763. * @param target defines where the entity should look at
  60764. * @param up defines the up vector for the entity
  60765. * @returns the new matrix
  60766. */
  60767. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60768. /**
  60769. * 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".
  60770. * This function works in left handed mode
  60771. * @param eye defines the final position of the entity
  60772. * @param target defines where the entity should look at
  60773. * @param up defines the up vector for the entity
  60774. * @param result defines the target matrix
  60775. */
  60776. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60777. /**
  60778. * 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"
  60779. * This function works in right handed mode
  60780. * @param eye defines the final position of the entity
  60781. * @param target defines where the entity should look at
  60782. * @param up defines the up vector for the entity
  60783. * @returns the new matrix
  60784. */
  60785. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60786. /**
  60787. * 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".
  60788. * This function works in right handed mode
  60789. * @param eye defines the final position of the entity
  60790. * @param target defines where the entity should look at
  60791. * @param up defines the up vector for the entity
  60792. * @param result defines the target matrix
  60793. */
  60794. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60795. /**
  60796. * Create a left-handed orthographic projection matrix
  60797. * @param width defines the viewport width
  60798. * @param height defines the viewport height
  60799. * @param znear defines the near clip plane
  60800. * @param zfar defines the far clip plane
  60801. * @returns a new matrix as a left-handed orthographic projection matrix
  60802. */
  60803. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60804. /**
  60805. * Store a left-handed orthographic projection to a given matrix
  60806. * @param width defines the viewport width
  60807. * @param height defines the viewport height
  60808. * @param znear defines the near clip plane
  60809. * @param zfar defines the far clip plane
  60810. * @param result defines the target matrix
  60811. */
  60812. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60813. /**
  60814. * Create a left-handed orthographic projection matrix
  60815. * @param left defines the viewport left coordinate
  60816. * @param right defines the viewport right coordinate
  60817. * @param bottom defines the viewport bottom coordinate
  60818. * @param top defines the viewport top coordinate
  60819. * @param znear defines the near clip plane
  60820. * @param zfar defines the far clip plane
  60821. * @returns a new matrix as a left-handed orthographic projection matrix
  60822. */
  60823. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60824. /**
  60825. * Stores a left-handed orthographic projection into a given matrix
  60826. * @param left defines the viewport left coordinate
  60827. * @param right defines the viewport right coordinate
  60828. * @param bottom defines the viewport bottom coordinate
  60829. * @param top defines the viewport top coordinate
  60830. * @param znear defines the near clip plane
  60831. * @param zfar defines the far clip plane
  60832. * @param result defines the target matrix
  60833. */
  60834. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60835. /**
  60836. * Creates a right-handed orthographic projection matrix
  60837. * @param left defines the viewport left coordinate
  60838. * @param right defines the viewport right coordinate
  60839. * @param bottom defines the viewport bottom coordinate
  60840. * @param top defines the viewport top coordinate
  60841. * @param znear defines the near clip plane
  60842. * @param zfar defines the far clip plane
  60843. * @returns a new matrix as a right-handed orthographic projection matrix
  60844. */
  60845. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60846. /**
  60847. * Stores a right-handed orthographic projection into a given matrix
  60848. * @param left defines the viewport left coordinate
  60849. * @param right defines the viewport right coordinate
  60850. * @param bottom defines the viewport bottom coordinate
  60851. * @param top defines the viewport top coordinate
  60852. * @param znear defines the near clip plane
  60853. * @param zfar defines the far clip plane
  60854. * @param result defines the target matrix
  60855. */
  60856. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60857. /**
  60858. * Creates a left-handed perspective projection matrix
  60859. * @param width defines the viewport width
  60860. * @param height defines the viewport height
  60861. * @param znear defines the near clip plane
  60862. * @param zfar defines the far clip plane
  60863. * @returns a new matrix as a left-handed perspective projection matrix
  60864. */
  60865. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60866. /**
  60867. * Creates a left-handed perspective projection matrix
  60868. * @param fov defines the horizontal field of view
  60869. * @param aspect defines the aspect ratio
  60870. * @param znear defines the near clip plane
  60871. * @param zfar defines the far clip plane
  60872. * @returns a new matrix as a left-handed perspective projection matrix
  60873. */
  60874. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60875. /**
  60876. * Stores a left-handed perspective projection into a given matrix
  60877. * @param fov defines the horizontal field of view
  60878. * @param aspect defines the aspect ratio
  60879. * @param znear defines the near clip plane
  60880. * @param zfar defines the far clip plane
  60881. * @param result defines the target matrix
  60882. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60883. */
  60884. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60885. /**
  60886. * Creates a right-handed perspective projection matrix
  60887. * @param fov defines the horizontal field of view
  60888. * @param aspect defines the aspect ratio
  60889. * @param znear defines the near clip plane
  60890. * @param zfar defines the far clip plane
  60891. * @returns a new matrix as a right-handed perspective projection matrix
  60892. */
  60893. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60894. /**
  60895. * Stores a right-handed perspective projection into a given matrix
  60896. * @param fov defines the horizontal field of view
  60897. * @param aspect defines the aspect ratio
  60898. * @param znear defines the near clip plane
  60899. * @param zfar defines the far clip plane
  60900. * @param result defines the target matrix
  60901. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60902. */
  60903. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60904. /**
  60905. * Stores a perspective projection for WebVR info a given matrix
  60906. * @param fov defines the field of view
  60907. * @param znear defines the near clip plane
  60908. * @param zfar defines the far clip plane
  60909. * @param result defines the target matrix
  60910. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60911. */
  60912. static PerspectiveFovWebVRToRef(fov: {
  60913. upDegrees: number;
  60914. downDegrees: number;
  60915. leftDegrees: number;
  60916. rightDegrees: number;
  60917. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60918. /**
  60919. * Computes a complete transformation matrix
  60920. * @param viewport defines the viewport to use
  60921. * @param world defines the world matrix
  60922. * @param view defines the view matrix
  60923. * @param projection defines the projection matrix
  60924. * @param zmin defines the near clip plane
  60925. * @param zmax defines the far clip plane
  60926. * @returns the transformation matrix
  60927. */
  60928. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60929. /**
  60930. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60931. * @param matrix defines the matrix to use
  60932. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60933. */
  60934. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60935. /**
  60936. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60937. * @param matrix defines the matrix to use
  60938. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60939. */
  60940. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60941. /**
  60942. * Compute the transpose of a given matrix
  60943. * @param matrix defines the matrix to transpose
  60944. * @returns the new matrix
  60945. */
  60946. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60947. /**
  60948. * Compute the transpose of a matrix and store it in a target matrix
  60949. * @param matrix defines the matrix to transpose
  60950. * @param result defines the target matrix
  60951. */
  60952. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60953. /**
  60954. * Computes a reflection matrix from a plane
  60955. * @param plane defines the reflection plane
  60956. * @returns a new matrix
  60957. */
  60958. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60959. /**
  60960. * Computes a reflection matrix from a plane
  60961. * @param plane defines the reflection plane
  60962. * @param result defines the target matrix
  60963. */
  60964. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60965. /**
  60966. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60967. * @param xaxis defines the value of the 1st axis
  60968. * @param yaxis defines the value of the 2nd axis
  60969. * @param zaxis defines the value of the 3rd axis
  60970. * @param result defines the target matrix
  60971. */
  60972. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60973. /**
  60974. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60975. * @param quat defines the quaternion to use
  60976. * @param result defines the target matrix
  60977. */
  60978. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60979. }
  60980. /**
  60981. * Represens a plane by the equation ax + by + cz + d = 0
  60982. */
  60983. export class Plane {
  60984. /**
  60985. * Normal of the plane (a,b,c)
  60986. */
  60987. normal: Vector3;
  60988. /**
  60989. * d component of the plane
  60990. */
  60991. d: number;
  60992. /**
  60993. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60994. * @param a a component of the plane
  60995. * @param b b component of the plane
  60996. * @param c c component of the plane
  60997. * @param d d component of the plane
  60998. */
  60999. constructor(a: number, b: number, c: number, d: number);
  61000. /**
  61001. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61002. */
  61003. asArray(): number[];
  61004. /**
  61005. * @returns a new plane copied from the current Plane.
  61006. */
  61007. clone(): Plane;
  61008. /**
  61009. * @returns the string "Plane".
  61010. */
  61011. getClassName(): string;
  61012. /**
  61013. * @returns the Plane hash code.
  61014. */
  61015. getHashCode(): number;
  61016. /**
  61017. * Normalize the current Plane in place.
  61018. * @returns the updated Plane.
  61019. */
  61020. normalize(): Plane;
  61021. /**
  61022. * Applies a transformation the plane and returns the result
  61023. * @param transformation the transformation matrix to be applied to the plane
  61024. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61025. */
  61026. transform(transformation: DeepImmutable<Matrix>): Plane;
  61027. /**
  61028. * Calcualtte the dot product between the point and the plane normal
  61029. * @param point point to calculate the dot product with
  61030. * @returns the dot product (float) of the point coordinates and the plane normal.
  61031. */
  61032. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61033. /**
  61034. * Updates the current Plane from the plane defined by the three given points.
  61035. * @param point1 one of the points used to contruct the plane
  61036. * @param point2 one of the points used to contruct the plane
  61037. * @param point3 one of the points used to contruct the plane
  61038. * @returns the updated Plane.
  61039. */
  61040. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61041. /**
  61042. * Checks if the plane is facing a given direction
  61043. * @param direction the direction to check if the plane is facing
  61044. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61045. * @returns True is the vector "direction" is the same side than the plane normal.
  61046. */
  61047. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61048. /**
  61049. * Calculates the distance to a point
  61050. * @param point point to calculate distance to
  61051. * @returns the signed distance (float) from the given point to the Plane.
  61052. */
  61053. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61054. /**
  61055. * Creates a plane from an array
  61056. * @param array the array to create a plane from
  61057. * @returns a new Plane from the given array.
  61058. */
  61059. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61060. /**
  61061. * Creates a plane from three points
  61062. * @param point1 point used to create the plane
  61063. * @param point2 point used to create the plane
  61064. * @param point3 point used to create the plane
  61065. * @returns a new Plane defined by the three given points.
  61066. */
  61067. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61068. /**
  61069. * Creates a plane from an origin point and a normal
  61070. * @param origin origin of the plane to be constructed
  61071. * @param normal normal of the plane to be constructed
  61072. * @returns a new Plane the normal vector to this plane at the given origin point.
  61073. * Note : the vector "normal" is updated because normalized.
  61074. */
  61075. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61076. /**
  61077. * Calculates the distance from a plane and a point
  61078. * @param origin origin of the plane to be constructed
  61079. * @param normal normal of the plane to be constructed
  61080. * @param point point to calculate distance to
  61081. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61082. */
  61083. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61084. }
  61085. /**
  61086. * Class used to represent a viewport on screen
  61087. */
  61088. export class Viewport {
  61089. /** viewport left coordinate */
  61090. x: number;
  61091. /** viewport top coordinate */
  61092. y: number;
  61093. /**viewport width */
  61094. width: number;
  61095. /** viewport height */
  61096. height: number;
  61097. /**
  61098. * Creates a Viewport object located at (x, y) and sized (width, height)
  61099. * @param x defines viewport left coordinate
  61100. * @param y defines viewport top coordinate
  61101. * @param width defines the viewport width
  61102. * @param height defines the viewport height
  61103. */
  61104. constructor(
  61105. /** viewport left coordinate */
  61106. x: number,
  61107. /** viewport top coordinate */
  61108. y: number,
  61109. /**viewport width */
  61110. width: number,
  61111. /** viewport height */
  61112. height: number);
  61113. /**
  61114. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61115. * @param renderWidth defines the rendering width
  61116. * @param renderHeight defines the rendering height
  61117. * @returns a new Viewport
  61118. */
  61119. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61120. /**
  61121. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61122. * @param renderWidth defines the rendering width
  61123. * @param renderHeight defines the rendering height
  61124. * @param ref defines the target viewport
  61125. * @returns the current viewport
  61126. */
  61127. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61128. /**
  61129. * Returns a new Viewport copied from the current one
  61130. * @returns a new Viewport
  61131. */
  61132. clone(): Viewport;
  61133. }
  61134. /**
  61135. * Reprasents a camera frustum
  61136. */
  61137. export class Frustum {
  61138. /**
  61139. * Gets the planes representing the frustum
  61140. * @param transform matrix to be applied to the returned planes
  61141. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61142. */
  61143. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61144. /**
  61145. * Gets the near frustum plane transformed by the transform matrix
  61146. * @param transform transformation matrix to be applied to the resulting frustum plane
  61147. * @param frustumPlane the resuling frustum plane
  61148. */
  61149. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61150. /**
  61151. * Gets the far frustum plane transformed by the transform matrix
  61152. * @param transform transformation matrix to be applied to the resulting frustum plane
  61153. * @param frustumPlane the resuling frustum plane
  61154. */
  61155. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61156. /**
  61157. * Gets the left frustum plane transformed by the transform matrix
  61158. * @param transform transformation matrix to be applied to the resulting frustum plane
  61159. * @param frustumPlane the resuling frustum plane
  61160. */
  61161. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61162. /**
  61163. * Gets the right frustum plane transformed by the transform matrix
  61164. * @param transform transformation matrix to be applied to the resulting frustum plane
  61165. * @param frustumPlane the resuling frustum plane
  61166. */
  61167. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61168. /**
  61169. * Gets the top frustum plane transformed by the transform matrix
  61170. * @param transform transformation matrix to be applied to the resulting frustum plane
  61171. * @param frustumPlane the resuling frustum plane
  61172. */
  61173. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61174. /**
  61175. * Gets the bottom frustum plane transformed by the transform matrix
  61176. * @param transform transformation matrix to be applied to the resulting frustum plane
  61177. * @param frustumPlane the resuling frustum plane
  61178. */
  61179. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61180. /**
  61181. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61182. * @param transform transformation matrix to be applied to the resulting frustum planes
  61183. * @param frustumPlanes the resuling frustum planes
  61184. */
  61185. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61186. }
  61187. /** Defines supported spaces */
  61188. export enum Space {
  61189. /** Local (object) space */
  61190. LOCAL = 0,
  61191. /** World space */
  61192. WORLD = 1,
  61193. /** Bone space */
  61194. BONE = 2
  61195. }
  61196. /** Defines the 3 main axes */
  61197. export class Axis {
  61198. /** X axis */
  61199. static X: Vector3;
  61200. /** Y axis */
  61201. static Y: Vector3;
  61202. /** Z axis */
  61203. static Z: Vector3;
  61204. }
  61205. /** Class used to represent a Bezier curve */
  61206. export class BezierCurve {
  61207. /**
  61208. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61209. * @param t defines the time
  61210. * @param x1 defines the left coordinate on X axis
  61211. * @param y1 defines the left coordinate on Y axis
  61212. * @param x2 defines the right coordinate on X axis
  61213. * @param y2 defines the right coordinate on Y axis
  61214. * @returns the interpolated value
  61215. */
  61216. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61217. }
  61218. /**
  61219. * Defines potential orientation for back face culling
  61220. */
  61221. export enum Orientation {
  61222. /**
  61223. * Clockwise
  61224. */
  61225. CW = 0,
  61226. /** Counter clockwise */
  61227. CCW = 1
  61228. }
  61229. /**
  61230. * Defines angle representation
  61231. */
  61232. export class Angle {
  61233. private _radians;
  61234. /**
  61235. * Creates an Angle object of "radians" radians (float).
  61236. * @param radians the angle in radians
  61237. */
  61238. constructor(radians: number);
  61239. /**
  61240. * Get value in degrees
  61241. * @returns the Angle value in degrees (float)
  61242. */
  61243. degrees(): number;
  61244. /**
  61245. * Get value in radians
  61246. * @returns the Angle value in radians (float)
  61247. */
  61248. radians(): number;
  61249. /**
  61250. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61251. * @param a defines first vector
  61252. * @param b defines second vector
  61253. * @returns a new Angle
  61254. */
  61255. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61256. /**
  61257. * Gets a new Angle object from the given float in radians
  61258. * @param radians defines the angle value in radians
  61259. * @returns a new Angle
  61260. */
  61261. static FromRadians(radians: number): Angle;
  61262. /**
  61263. * Gets a new Angle object from the given float in degrees
  61264. * @param degrees defines the angle value in degrees
  61265. * @returns a new Angle
  61266. */
  61267. static FromDegrees(degrees: number): Angle;
  61268. }
  61269. /**
  61270. * This represents an arc in a 2d space.
  61271. */
  61272. export class Arc2 {
  61273. /** Defines the start point of the arc */
  61274. startPoint: Vector2;
  61275. /** Defines the mid point of the arc */
  61276. midPoint: Vector2;
  61277. /** Defines the end point of the arc */
  61278. endPoint: Vector2;
  61279. /**
  61280. * Defines the center point of the arc.
  61281. */
  61282. centerPoint: Vector2;
  61283. /**
  61284. * Defines the radius of the arc.
  61285. */
  61286. radius: number;
  61287. /**
  61288. * Defines the angle of the arc (from mid point to end point).
  61289. */
  61290. angle: Angle;
  61291. /**
  61292. * Defines the start angle of the arc (from start point to middle point).
  61293. */
  61294. startAngle: Angle;
  61295. /**
  61296. * Defines the orientation of the arc (clock wise/counter clock wise).
  61297. */
  61298. orientation: Orientation;
  61299. /**
  61300. * Creates an Arc object from the three given points : start, middle and end.
  61301. * @param startPoint Defines the start point of the arc
  61302. * @param midPoint Defines the midlle point of the arc
  61303. * @param endPoint Defines the end point of the arc
  61304. */
  61305. constructor(
  61306. /** Defines the start point of the arc */
  61307. startPoint: Vector2,
  61308. /** Defines the mid point of the arc */
  61309. midPoint: Vector2,
  61310. /** Defines the end point of the arc */
  61311. endPoint: Vector2);
  61312. }
  61313. /**
  61314. * Represents a 2D path made up of multiple 2D points
  61315. */
  61316. export class Path2 {
  61317. private _points;
  61318. private _length;
  61319. /**
  61320. * If the path start and end point are the same
  61321. */
  61322. closed: boolean;
  61323. /**
  61324. * Creates a Path2 object from the starting 2D coordinates x and y.
  61325. * @param x the starting points x value
  61326. * @param y the starting points y value
  61327. */
  61328. constructor(x: number, y: number);
  61329. /**
  61330. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61331. * @param x the added points x value
  61332. * @param y the added points y value
  61333. * @returns the updated Path2.
  61334. */
  61335. addLineTo(x: number, y: number): Path2;
  61336. /**
  61337. * 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.
  61338. * @param midX middle point x value
  61339. * @param midY middle point y value
  61340. * @param endX end point x value
  61341. * @param endY end point y value
  61342. * @param numberOfSegments (default: 36)
  61343. * @returns the updated Path2.
  61344. */
  61345. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61346. /**
  61347. * Closes the Path2.
  61348. * @returns the Path2.
  61349. */
  61350. close(): Path2;
  61351. /**
  61352. * Gets the sum of the distance between each sequential point in the path
  61353. * @returns the Path2 total length (float).
  61354. */
  61355. length(): number;
  61356. /**
  61357. * Gets the points which construct the path
  61358. * @returns the Path2 internal array of points.
  61359. */
  61360. getPoints(): Vector2[];
  61361. /**
  61362. * Retreives the point at the distance aways from the starting point
  61363. * @param normalizedLengthPosition the length along the path to retreive the point from
  61364. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61365. */
  61366. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61367. /**
  61368. * Creates a new path starting from an x and y position
  61369. * @param x starting x value
  61370. * @param y starting y value
  61371. * @returns a new Path2 starting at the coordinates (x, y).
  61372. */
  61373. static StartingAt(x: number, y: number): Path2;
  61374. }
  61375. /**
  61376. * Represents a 3D path made up of multiple 3D points
  61377. */
  61378. export class Path3D {
  61379. /**
  61380. * an array of Vector3, the curve axis of the Path3D
  61381. */
  61382. path: Vector3[];
  61383. private _curve;
  61384. private _distances;
  61385. private _tangents;
  61386. private _normals;
  61387. private _binormals;
  61388. private _raw;
  61389. /**
  61390. * new Path3D(path, normal, raw)
  61391. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61392. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61393. * @param path an array of Vector3, the curve axis of the Path3D
  61394. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61395. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61396. */
  61397. constructor(
  61398. /**
  61399. * an array of Vector3, the curve axis of the Path3D
  61400. */
  61401. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61402. /**
  61403. * Returns the Path3D array of successive Vector3 designing its curve.
  61404. * @returns the Path3D array of successive Vector3 designing its curve.
  61405. */
  61406. getCurve(): Vector3[];
  61407. /**
  61408. * Returns an array populated with tangent vectors on each Path3D curve point.
  61409. * @returns an array populated with tangent vectors on each Path3D curve point.
  61410. */
  61411. getTangents(): Vector3[];
  61412. /**
  61413. * Returns an array populated with normal vectors on each Path3D curve point.
  61414. * @returns an array populated with normal vectors on each Path3D curve point.
  61415. */
  61416. getNormals(): Vector3[];
  61417. /**
  61418. * Returns an array populated with binormal vectors on each Path3D curve point.
  61419. * @returns an array populated with binormal vectors on each Path3D curve point.
  61420. */
  61421. getBinormals(): Vector3[];
  61422. /**
  61423. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61424. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61425. */
  61426. getDistances(): number[];
  61427. /**
  61428. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61429. * @param path path which all values are copied into the curves points
  61430. * @param firstNormal which should be projected onto the curve
  61431. * @returns the same object updated.
  61432. */
  61433. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61434. private _compute;
  61435. private _getFirstNonNullVector;
  61436. private _getLastNonNullVector;
  61437. private _normalVector;
  61438. }
  61439. /**
  61440. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61441. * A Curve3 is designed from a series of successive Vector3.
  61442. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61443. */
  61444. export class Curve3 {
  61445. private _points;
  61446. private _length;
  61447. /**
  61448. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61449. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61450. * @param v1 (Vector3) the control point
  61451. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61452. * @param nbPoints (integer) the wanted number of points in the curve
  61453. * @returns the created Curve3
  61454. */
  61455. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61456. /**
  61457. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61458. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61459. * @param v1 (Vector3) the first control point
  61460. * @param v2 (Vector3) the second control point
  61461. * @param v3 (Vector3) the end point of the Cubic Bezier
  61462. * @param nbPoints (integer) the wanted number of points in the curve
  61463. * @returns the created Curve3
  61464. */
  61465. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61466. /**
  61467. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61468. * @param p1 (Vector3) the origin point of the Hermite Spline
  61469. * @param t1 (Vector3) the tangent vector at the origin point
  61470. * @param p2 (Vector3) the end point of the Hermite Spline
  61471. * @param t2 (Vector3) the tangent vector at the end point
  61472. * @param nbPoints (integer) the wanted number of points in the curve
  61473. * @returns the created Curve3
  61474. */
  61475. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61476. /**
  61477. * Returns a Curve3 object along a CatmullRom Spline curve :
  61478. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61479. * @param nbPoints (integer) the wanted number of points between each curve control points
  61480. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61481. * @returns the created Curve3
  61482. */
  61483. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61484. /**
  61485. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61486. * A Curve3 is designed from a series of successive Vector3.
  61487. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61488. * @param points points which make up the curve
  61489. */
  61490. constructor(points: Vector3[]);
  61491. /**
  61492. * @returns the Curve3 stored array of successive Vector3
  61493. */
  61494. getPoints(): Vector3[];
  61495. /**
  61496. * @returns the computed length (float) of the curve.
  61497. */
  61498. length(): number;
  61499. /**
  61500. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61501. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61502. * curveA and curveB keep unchanged.
  61503. * @param curve the curve to continue from this curve
  61504. * @returns the newly constructed curve
  61505. */
  61506. continue(curve: DeepImmutable<Curve3>): Curve3;
  61507. private _computeLength;
  61508. }
  61509. /**
  61510. * Contains position and normal vectors for a vertex
  61511. */
  61512. export class PositionNormalVertex {
  61513. /** the position of the vertex (defaut: 0,0,0) */
  61514. position: Vector3;
  61515. /** the normal of the vertex (defaut: 0,1,0) */
  61516. normal: Vector3;
  61517. /**
  61518. * Creates a PositionNormalVertex
  61519. * @param position the position of the vertex (defaut: 0,0,0)
  61520. * @param normal the normal of the vertex (defaut: 0,1,0)
  61521. */
  61522. constructor(
  61523. /** the position of the vertex (defaut: 0,0,0) */
  61524. position?: Vector3,
  61525. /** the normal of the vertex (defaut: 0,1,0) */
  61526. normal?: Vector3);
  61527. /**
  61528. * Clones the PositionNormalVertex
  61529. * @returns the cloned PositionNormalVertex
  61530. */
  61531. clone(): PositionNormalVertex;
  61532. }
  61533. /**
  61534. * Contains position, normal and uv vectors for a vertex
  61535. */
  61536. export class PositionNormalTextureVertex {
  61537. /** the position of the vertex (defaut: 0,0,0) */
  61538. position: Vector3;
  61539. /** the normal of the vertex (defaut: 0,1,0) */
  61540. normal: Vector3;
  61541. /** the uv of the vertex (default: 0,0) */
  61542. uv: Vector2;
  61543. /**
  61544. * Creates a PositionNormalTextureVertex
  61545. * @param position the position of the vertex (defaut: 0,0,0)
  61546. * @param normal the normal of the vertex (defaut: 0,1,0)
  61547. * @param uv the uv of the vertex (default: 0,0)
  61548. */
  61549. constructor(
  61550. /** the position of the vertex (defaut: 0,0,0) */
  61551. position?: Vector3,
  61552. /** the normal of the vertex (defaut: 0,1,0) */
  61553. normal?: Vector3,
  61554. /** the uv of the vertex (default: 0,0) */
  61555. uv?: Vector2);
  61556. /**
  61557. * Clones the PositionNormalTextureVertex
  61558. * @returns the cloned PositionNormalTextureVertex
  61559. */
  61560. clone(): PositionNormalTextureVertex;
  61561. }
  61562. /**
  61563. * @hidden
  61564. */
  61565. export class Tmp {
  61566. static Color3: Color3[];
  61567. static Color4: Color4[];
  61568. static Vector2: Vector2[];
  61569. static Vector3: Vector3[];
  61570. static Vector4: Vector4[];
  61571. static Quaternion: Quaternion[];
  61572. static Matrix: Matrix[];
  61573. }
  61574. }
  61575. declare module BABYLON {
  61576. /**
  61577. * Class used to enable access to offline support
  61578. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61579. */
  61580. export interface IOfflineProvider {
  61581. /**
  61582. * Gets a boolean indicating if scene must be saved in the database
  61583. */
  61584. enableSceneOffline: boolean;
  61585. /**
  61586. * Gets a boolean indicating if textures must be saved in the database
  61587. */
  61588. enableTexturesOffline: boolean;
  61589. /**
  61590. * Open the offline support and make it available
  61591. * @param successCallback defines the callback to call on success
  61592. * @param errorCallback defines the callback to call on error
  61593. */
  61594. open(successCallback: () => void, errorCallback: () => void): void;
  61595. /**
  61596. * Loads an image from the offline support
  61597. * @param url defines the url to load from
  61598. * @param image defines the target DOM image
  61599. */
  61600. loadImage(url: string, image: HTMLImageElement): void;
  61601. /**
  61602. * Loads a file from offline support
  61603. * @param url defines the URL to load from
  61604. * @param sceneLoaded defines a callback to call on success
  61605. * @param progressCallBack defines a callback to call when progress changed
  61606. * @param errorCallback defines a callback to call on error
  61607. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61608. */
  61609. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61610. }
  61611. }
  61612. declare module BABYLON {
  61613. /**
  61614. * A class serves as a medium between the observable and its observers
  61615. */
  61616. export class EventState {
  61617. /**
  61618. * Create a new EventState
  61619. * @param mask defines the mask associated with this state
  61620. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61621. * @param target defines the original target of the state
  61622. * @param currentTarget defines the current target of the state
  61623. */
  61624. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61625. /**
  61626. * Initialize the current event state
  61627. * @param mask defines the mask associated with this state
  61628. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61629. * @param target defines the original target of the state
  61630. * @param currentTarget defines the current target of the state
  61631. * @returns the current event state
  61632. */
  61633. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61634. /**
  61635. * An Observer can set this property to true to prevent subsequent observers of being notified
  61636. */
  61637. skipNextObservers: boolean;
  61638. /**
  61639. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61640. */
  61641. mask: number;
  61642. /**
  61643. * The object that originally notified the event
  61644. */
  61645. target?: any;
  61646. /**
  61647. * The current object in the bubbling phase
  61648. */
  61649. currentTarget?: any;
  61650. /**
  61651. * This will be populated with the return value of the last function that was executed.
  61652. * If it is the first function in the callback chain it will be the event data.
  61653. */
  61654. lastReturnValue?: any;
  61655. }
  61656. /**
  61657. * Represent an Observer registered to a given Observable object.
  61658. */
  61659. export class Observer<T> {
  61660. /**
  61661. * Defines the callback to call when the observer is notified
  61662. */
  61663. callback: (eventData: T, eventState: EventState) => void;
  61664. /**
  61665. * Defines the mask of the observer (used to filter notifications)
  61666. */
  61667. mask: number;
  61668. /**
  61669. * Defines the current scope used to restore the JS context
  61670. */
  61671. scope: any;
  61672. /** @hidden */
  61673. _willBeUnregistered: boolean;
  61674. /**
  61675. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61676. */
  61677. unregisterOnNextCall: boolean;
  61678. /**
  61679. * Creates a new observer
  61680. * @param callback defines the callback to call when the observer is notified
  61681. * @param mask defines the mask of the observer (used to filter notifications)
  61682. * @param scope defines the current scope used to restore the JS context
  61683. */
  61684. constructor(
  61685. /**
  61686. * Defines the callback to call when the observer is notified
  61687. */
  61688. callback: (eventData: T, eventState: EventState) => void,
  61689. /**
  61690. * Defines the mask of the observer (used to filter notifications)
  61691. */
  61692. mask: number,
  61693. /**
  61694. * Defines the current scope used to restore the JS context
  61695. */
  61696. scope?: any);
  61697. }
  61698. /**
  61699. * Represent a list of observers registered to multiple Observables object.
  61700. */
  61701. export class MultiObserver<T> {
  61702. private _observers;
  61703. private _observables;
  61704. /**
  61705. * Release associated resources
  61706. */
  61707. dispose(): void;
  61708. /**
  61709. * Raise a callback when one of the observable will notify
  61710. * @param observables defines a list of observables to watch
  61711. * @param callback defines the callback to call on notification
  61712. * @param mask defines the mask used to filter notifications
  61713. * @param scope defines the current scope used to restore the JS context
  61714. * @returns the new MultiObserver
  61715. */
  61716. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61717. }
  61718. /**
  61719. * The Observable class is a simple implementation of the Observable pattern.
  61720. *
  61721. * 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.
  61722. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61723. * 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).
  61724. * 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.
  61725. */
  61726. export class Observable<T> {
  61727. private _observers;
  61728. private _eventState;
  61729. private _onObserverAdded;
  61730. /**
  61731. * Creates a new observable
  61732. * @param onObserverAdded defines a callback to call when a new observer is added
  61733. */
  61734. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61735. /**
  61736. * Create a new Observer with the specified callback
  61737. * @param callback the callback that will be executed for that Observer
  61738. * @param mask the mask used to filter observers
  61739. * @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.
  61740. * @param scope optional scope for the callback to be called from
  61741. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61742. * @returns the new observer created for the callback
  61743. */
  61744. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61745. /**
  61746. * Create a new Observer with the specified callback and unregisters after the next notification
  61747. * @param callback the callback that will be executed for that Observer
  61748. * @returns the new observer created for the callback
  61749. */
  61750. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61751. /**
  61752. * Remove an Observer from the Observable object
  61753. * @param observer the instance of the Observer to remove
  61754. * @returns false if it doesn't belong to this Observable
  61755. */
  61756. remove(observer: Nullable<Observer<T>>): boolean;
  61757. /**
  61758. * Remove a callback from the Observable object
  61759. * @param callback the callback to remove
  61760. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61761. * @returns false if it doesn't belong to this Observable
  61762. */
  61763. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61764. private _deferUnregister;
  61765. private _remove;
  61766. /**
  61767. * Notify all Observers by calling their respective callback with the given data
  61768. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61769. * @param eventData defines the data to send to all observers
  61770. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61771. * @param target defines the original target of the state
  61772. * @param currentTarget defines the current target of the state
  61773. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61774. */
  61775. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61776. /**
  61777. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61778. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61779. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61780. * and it is crucial that all callbacks will be executed.
  61781. * The order of the callbacks is kept, callbacks are not executed parallel.
  61782. *
  61783. * @param eventData The data to be sent to each callback
  61784. * @param mask is used to filter observers defaults to -1
  61785. * @param target defines the callback target (see EventState)
  61786. * @param currentTarget defines he current object in the bubbling phase
  61787. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61788. */
  61789. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61790. /**
  61791. * Notify a specific observer
  61792. * @param observer defines the observer to notify
  61793. * @param eventData defines the data to be sent to each callback
  61794. * @param mask is used to filter observers defaults to -1
  61795. */
  61796. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61797. /**
  61798. * Gets a boolean indicating if the observable has at least one observer
  61799. * @returns true is the Observable has at least one Observer registered
  61800. */
  61801. hasObservers(): boolean;
  61802. /**
  61803. * Clear the list of observers
  61804. */
  61805. clear(): void;
  61806. /**
  61807. * Clone the current observable
  61808. * @returns a new observable
  61809. */
  61810. clone(): Observable<T>;
  61811. /**
  61812. * Does this observable handles observer registered with a given mask
  61813. * @param mask defines the mask to be tested
  61814. * @return whether or not one observer registered with the given mask is handeled
  61815. **/
  61816. hasSpecificMask(mask?: number): boolean;
  61817. }
  61818. }
  61819. declare module BABYLON {
  61820. /**
  61821. * Class used to help managing file picking and drag'n'drop
  61822. * File Storage
  61823. */
  61824. export class FilesInputStore {
  61825. /**
  61826. * List of files ready to be loaded
  61827. */
  61828. static FilesToLoad: {
  61829. [key: string]: File;
  61830. };
  61831. }
  61832. }
  61833. declare module BABYLON {
  61834. /** Defines the cross module used constants to avoid circular dependncies */
  61835. export class Constants {
  61836. /** Defines that alpha blending is disabled */
  61837. static readonly ALPHA_DISABLE: number;
  61838. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61839. static readonly ALPHA_ADD: number;
  61840. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61841. static readonly ALPHA_COMBINE: number;
  61842. /** Defines that alpha blending to DEST - SRC * DEST */
  61843. static readonly ALPHA_SUBTRACT: number;
  61844. /** Defines that alpha blending to SRC * DEST */
  61845. static readonly ALPHA_MULTIPLY: number;
  61846. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61847. static readonly ALPHA_MAXIMIZED: number;
  61848. /** Defines that alpha blending to SRC + DEST */
  61849. static readonly ALPHA_ONEONE: number;
  61850. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61851. static readonly ALPHA_PREMULTIPLIED: number;
  61852. /**
  61853. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61854. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61855. */
  61856. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61857. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61858. static readonly ALPHA_INTERPOLATE: number;
  61859. /**
  61860. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61861. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61862. */
  61863. static readonly ALPHA_SCREENMODE: number;
  61864. /** Defines that the ressource is not delayed*/
  61865. static readonly DELAYLOADSTATE_NONE: number;
  61866. /** Defines that the ressource was successfully delay loaded */
  61867. static readonly DELAYLOADSTATE_LOADED: number;
  61868. /** Defines that the ressource is currently delay loading */
  61869. static readonly DELAYLOADSTATE_LOADING: number;
  61870. /** Defines that the ressource is delayed and has not started loading */
  61871. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61873. static readonly NEVER: number;
  61874. /** 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 */
  61875. static readonly ALWAYS: number;
  61876. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61877. static readonly LESS: number;
  61878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61879. static readonly EQUAL: number;
  61880. /** 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 */
  61881. static readonly LEQUAL: number;
  61882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61883. static readonly GREATER: number;
  61884. /** 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 */
  61885. static readonly GEQUAL: number;
  61886. /** 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 */
  61887. static readonly NOTEQUAL: number;
  61888. /** Passed to stencilOperation to specify that stencil value must be kept */
  61889. static readonly KEEP: number;
  61890. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61891. static readonly REPLACE: number;
  61892. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61893. static readonly INCR: number;
  61894. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61895. static readonly DECR: number;
  61896. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61897. static readonly INVERT: number;
  61898. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61899. static readonly INCR_WRAP: number;
  61900. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61901. static readonly DECR_WRAP: number;
  61902. /** Texture is not repeating outside of 0..1 UVs */
  61903. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61904. /** Texture is repeating outside of 0..1 UVs */
  61905. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61906. /** Texture is repeating and mirrored */
  61907. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61908. /** ALPHA */
  61909. static readonly TEXTUREFORMAT_ALPHA: number;
  61910. /** LUMINANCE */
  61911. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61912. /** LUMINANCE_ALPHA */
  61913. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61914. /** RGB */
  61915. static readonly TEXTUREFORMAT_RGB: number;
  61916. /** RGBA */
  61917. static readonly TEXTUREFORMAT_RGBA: number;
  61918. /** RED */
  61919. static readonly TEXTUREFORMAT_RED: number;
  61920. /** RED (2nd reference) */
  61921. static readonly TEXTUREFORMAT_R: number;
  61922. /** RG */
  61923. static readonly TEXTUREFORMAT_RG: number;
  61924. /** RED_INTEGER */
  61925. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61926. /** RED_INTEGER (2nd reference) */
  61927. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61928. /** RG_INTEGER */
  61929. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61930. /** RGB_INTEGER */
  61931. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61932. /** RGBA_INTEGER */
  61933. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61934. /** UNSIGNED_BYTE */
  61935. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61936. /** UNSIGNED_BYTE (2nd reference) */
  61937. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61938. /** FLOAT */
  61939. static readonly TEXTURETYPE_FLOAT: number;
  61940. /** HALF_FLOAT */
  61941. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61942. /** BYTE */
  61943. static readonly TEXTURETYPE_BYTE: number;
  61944. /** SHORT */
  61945. static readonly TEXTURETYPE_SHORT: number;
  61946. /** UNSIGNED_SHORT */
  61947. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61948. /** INT */
  61949. static readonly TEXTURETYPE_INT: number;
  61950. /** UNSIGNED_INT */
  61951. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61952. /** UNSIGNED_SHORT_4_4_4_4 */
  61953. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61954. /** UNSIGNED_SHORT_5_5_5_1 */
  61955. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61956. /** UNSIGNED_SHORT_5_6_5 */
  61957. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61958. /** UNSIGNED_INT_2_10_10_10_REV */
  61959. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61960. /** UNSIGNED_INT_24_8 */
  61961. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61962. /** UNSIGNED_INT_10F_11F_11F_REV */
  61963. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61964. /** UNSIGNED_INT_5_9_9_9_REV */
  61965. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61966. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61967. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61968. /** nearest is mag = nearest and min = nearest and mip = linear */
  61969. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61970. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61971. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61972. /** Trilinear is mag = linear and min = linear and mip = linear */
  61973. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61974. /** nearest is mag = nearest and min = nearest and mip = linear */
  61975. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61976. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61977. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61978. /** Trilinear is mag = linear and min = linear and mip = linear */
  61979. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61980. /** mag = nearest and min = nearest and mip = nearest */
  61981. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61982. /** mag = nearest and min = linear and mip = nearest */
  61983. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61984. /** mag = nearest and min = linear and mip = linear */
  61985. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61986. /** mag = nearest and min = linear and mip = none */
  61987. static readonly TEXTURE_NEAREST_LINEAR: number;
  61988. /** mag = nearest and min = nearest and mip = none */
  61989. static readonly TEXTURE_NEAREST_NEAREST: number;
  61990. /** mag = linear and min = nearest and mip = nearest */
  61991. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61992. /** mag = linear and min = nearest and mip = linear */
  61993. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61994. /** mag = linear and min = linear and mip = none */
  61995. static readonly TEXTURE_LINEAR_LINEAR: number;
  61996. /** mag = linear and min = nearest and mip = none */
  61997. static readonly TEXTURE_LINEAR_NEAREST: number;
  61998. /** Explicit coordinates mode */
  61999. static readonly TEXTURE_EXPLICIT_MODE: number;
  62000. /** Spherical coordinates mode */
  62001. static readonly TEXTURE_SPHERICAL_MODE: number;
  62002. /** Planar coordinates mode */
  62003. static readonly TEXTURE_PLANAR_MODE: number;
  62004. /** Cubic coordinates mode */
  62005. static readonly TEXTURE_CUBIC_MODE: number;
  62006. /** Projection coordinates mode */
  62007. static readonly TEXTURE_PROJECTION_MODE: number;
  62008. /** Skybox coordinates mode */
  62009. static readonly TEXTURE_SKYBOX_MODE: number;
  62010. /** Inverse Cubic coordinates mode */
  62011. static readonly TEXTURE_INVCUBIC_MODE: number;
  62012. /** Equirectangular coordinates mode */
  62013. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62014. /** Equirectangular Fixed coordinates mode */
  62015. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62016. /** Equirectangular Fixed Mirrored coordinates mode */
  62017. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62018. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62019. static readonly SCALEMODE_FLOOR: number;
  62020. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62021. static readonly SCALEMODE_NEAREST: number;
  62022. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62023. static readonly SCALEMODE_CEILING: number;
  62024. /**
  62025. * The dirty texture flag value
  62026. */
  62027. static readonly MATERIAL_TextureDirtyFlag: number;
  62028. /**
  62029. * The dirty light flag value
  62030. */
  62031. static readonly MATERIAL_LightDirtyFlag: number;
  62032. /**
  62033. * The dirty fresnel flag value
  62034. */
  62035. static readonly MATERIAL_FresnelDirtyFlag: number;
  62036. /**
  62037. * The dirty attribute flag value
  62038. */
  62039. static readonly MATERIAL_AttributesDirtyFlag: number;
  62040. /**
  62041. * The dirty misc flag value
  62042. */
  62043. static readonly MATERIAL_MiscDirtyFlag: number;
  62044. /**
  62045. * The all dirty flag value
  62046. */
  62047. static readonly MATERIAL_AllDirtyFlag: number;
  62048. /**
  62049. * Returns the triangle fill mode
  62050. */
  62051. static readonly MATERIAL_TriangleFillMode: number;
  62052. /**
  62053. * Returns the wireframe mode
  62054. */
  62055. static readonly MATERIAL_WireFrameFillMode: number;
  62056. /**
  62057. * Returns the point fill mode
  62058. */
  62059. static readonly MATERIAL_PointFillMode: number;
  62060. /**
  62061. * Returns the point list draw mode
  62062. */
  62063. static readonly MATERIAL_PointListDrawMode: number;
  62064. /**
  62065. * Returns the line list draw mode
  62066. */
  62067. static readonly MATERIAL_LineListDrawMode: number;
  62068. /**
  62069. * Returns the line loop draw mode
  62070. */
  62071. static readonly MATERIAL_LineLoopDrawMode: number;
  62072. /**
  62073. * Returns the line strip draw mode
  62074. */
  62075. static readonly MATERIAL_LineStripDrawMode: number;
  62076. /**
  62077. * Returns the triangle strip draw mode
  62078. */
  62079. static readonly MATERIAL_TriangleStripDrawMode: number;
  62080. /**
  62081. * Returns the triangle fan draw mode
  62082. */
  62083. static readonly MATERIAL_TriangleFanDrawMode: number;
  62084. /**
  62085. * Stores the clock-wise side orientation
  62086. */
  62087. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62088. /**
  62089. * Stores the counter clock-wise side orientation
  62090. */
  62091. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62092. /**
  62093. * Nothing
  62094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62095. */
  62096. static readonly ACTION_NothingTrigger: number;
  62097. /**
  62098. * On pick
  62099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62100. */
  62101. static readonly ACTION_OnPickTrigger: number;
  62102. /**
  62103. * On left pick
  62104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62105. */
  62106. static readonly ACTION_OnLeftPickTrigger: number;
  62107. /**
  62108. * On right pick
  62109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62110. */
  62111. static readonly ACTION_OnRightPickTrigger: number;
  62112. /**
  62113. * On center pick
  62114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62115. */
  62116. static readonly ACTION_OnCenterPickTrigger: number;
  62117. /**
  62118. * On pick down
  62119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62120. */
  62121. static readonly ACTION_OnPickDownTrigger: number;
  62122. /**
  62123. * On double pick
  62124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62125. */
  62126. static readonly ACTION_OnDoublePickTrigger: number;
  62127. /**
  62128. * On pick up
  62129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62130. */
  62131. static readonly ACTION_OnPickUpTrigger: number;
  62132. /**
  62133. * On pick out.
  62134. * This trigger will only be raised if you also declared a OnPickDown
  62135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62136. */
  62137. static readonly ACTION_OnPickOutTrigger: number;
  62138. /**
  62139. * On long press
  62140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62141. */
  62142. static readonly ACTION_OnLongPressTrigger: number;
  62143. /**
  62144. * On pointer over
  62145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62146. */
  62147. static readonly ACTION_OnPointerOverTrigger: number;
  62148. /**
  62149. * On pointer out
  62150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62151. */
  62152. static readonly ACTION_OnPointerOutTrigger: number;
  62153. /**
  62154. * On every frame
  62155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62156. */
  62157. static readonly ACTION_OnEveryFrameTrigger: number;
  62158. /**
  62159. * On intersection enter
  62160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62161. */
  62162. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62163. /**
  62164. * On intersection exit
  62165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62166. */
  62167. static readonly ACTION_OnIntersectionExitTrigger: number;
  62168. /**
  62169. * On key down
  62170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62171. */
  62172. static readonly ACTION_OnKeyDownTrigger: number;
  62173. /**
  62174. * On key up
  62175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62176. */
  62177. static readonly ACTION_OnKeyUpTrigger: number;
  62178. /**
  62179. * Billboard mode will only apply to Y axis
  62180. */
  62181. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62182. /**
  62183. * Billboard mode will apply to all axes
  62184. */
  62185. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62186. /**
  62187. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62188. */
  62189. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62190. /**
  62191. * Gets or sets base Assets URL
  62192. */
  62193. static readonly PARTICLES_BaseAssetsUrl: string;
  62194. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62195. * Test order :
  62196. * Is the bounding sphere outside the frustum ?
  62197. * If not, are the bounding box vertices outside the frustum ?
  62198. * It not, then the cullable object is in the frustum.
  62199. */
  62200. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62201. /** Culling strategy : Bounding Sphere Only.
  62202. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62203. * It's also less accurate than the standard because some not visible objects can still be selected.
  62204. * Test : is the bounding sphere outside the frustum ?
  62205. * If not, then the cullable object is in the frustum.
  62206. */
  62207. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62208. /** Culling strategy : Optimistic Inclusion.
  62209. * This in an inclusion test first, then the standard exclusion test.
  62210. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62211. * 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.
  62212. * Anyway, it's as accurate as the standard strategy.
  62213. * Test :
  62214. * Is the cullable object bounding sphere center in the frustum ?
  62215. * If not, apply the default culling strategy.
  62216. */
  62217. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62218. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62219. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62220. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62221. * 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.
  62222. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62223. * Test :
  62224. * Is the cullable object bounding sphere center in the frustum ?
  62225. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62226. */
  62227. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62228. /**
  62229. * No logging while loading
  62230. */
  62231. static readonly SCENELOADER_NO_LOGGING: number;
  62232. /**
  62233. * Minimal logging while loading
  62234. */
  62235. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62236. /**
  62237. * Summary logging while loading
  62238. */
  62239. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62240. /**
  62241. * Detailled logging while loading
  62242. */
  62243. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62244. }
  62245. }
  62246. declare module BABYLON {
  62247. /**
  62248. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62249. * Babylon.js
  62250. */
  62251. export class DomManagement {
  62252. /**
  62253. * Checks if the window object exists
  62254. * @returns true if the window object exists
  62255. */
  62256. static IsWindowObjectExist(): boolean;
  62257. /**
  62258. * Extracts text content from a DOM element hierarchy
  62259. * @param element defines the root element
  62260. * @returns a string
  62261. */
  62262. static GetDOMTextContent(element: HTMLElement): string;
  62263. }
  62264. }
  62265. declare module BABYLON {
  62266. /**
  62267. * Logger used througouht the application to allow configuration of
  62268. * the log level required for the messages.
  62269. */
  62270. export class Logger {
  62271. /**
  62272. * No log
  62273. */
  62274. static readonly NoneLogLevel: number;
  62275. /**
  62276. * Only message logs
  62277. */
  62278. static readonly MessageLogLevel: number;
  62279. /**
  62280. * Only warning logs
  62281. */
  62282. static readonly WarningLogLevel: number;
  62283. /**
  62284. * Only error logs
  62285. */
  62286. static readonly ErrorLogLevel: number;
  62287. /**
  62288. * All logs
  62289. */
  62290. static readonly AllLogLevel: number;
  62291. private static _LogCache;
  62292. /**
  62293. * Gets a value indicating the number of loading errors
  62294. * @ignorenaming
  62295. */
  62296. static errorsCount: number;
  62297. /**
  62298. * Callback called when a new log is added
  62299. */
  62300. static OnNewCacheEntry: (entry: string) => void;
  62301. private static _AddLogEntry;
  62302. private static _FormatMessage;
  62303. private static _LogDisabled;
  62304. private static _LogEnabled;
  62305. private static _WarnDisabled;
  62306. private static _WarnEnabled;
  62307. private static _ErrorDisabled;
  62308. private static _ErrorEnabled;
  62309. /**
  62310. * Log a message to the console
  62311. */
  62312. static Log: (message: string) => void;
  62313. /**
  62314. * Write a warning message to the console
  62315. */
  62316. static Warn: (message: string) => void;
  62317. /**
  62318. * Write an error message to the console
  62319. */
  62320. static Error: (message: string) => void;
  62321. /**
  62322. * Gets current log cache (list of logs)
  62323. */
  62324. static readonly LogCache: string;
  62325. /**
  62326. * Clears the log cache
  62327. */
  62328. static ClearLogCache(): void;
  62329. /**
  62330. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62331. */
  62332. static LogLevels: number;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /** @hidden */
  62337. export class _TypeStore {
  62338. /** @hidden */
  62339. static RegisteredTypes: {
  62340. [key: string]: Object;
  62341. };
  62342. /** @hidden */
  62343. static GetClass(fqdn: string): any;
  62344. }
  62345. }
  62346. declare module BABYLON {
  62347. /**
  62348. * Class containing a set of static utilities functions for deep copy.
  62349. */
  62350. export class DeepCopier {
  62351. /**
  62352. * Tries to copy an object by duplicating every property
  62353. * @param source defines the source object
  62354. * @param destination defines the target object
  62355. * @param doNotCopyList defines a list of properties to avoid
  62356. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62357. */
  62358. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62359. }
  62360. }
  62361. declare module BABYLON {
  62362. /**
  62363. * Class containing a set of static utilities functions for precision date
  62364. */
  62365. export class PrecisionDate {
  62366. /**
  62367. * Gets either window.performance.now() if supported or Date.now() else
  62368. */
  62369. static readonly Now: number;
  62370. }
  62371. }
  62372. declare module BABYLON {
  62373. /** @hidden */
  62374. export class _DevTools {
  62375. static WarnImport(name: string): string;
  62376. }
  62377. }
  62378. declare module BABYLON {
  62379. /**
  62380. * Class used to evalaute queries containing `and` and `or` operators
  62381. */
  62382. export class AndOrNotEvaluator {
  62383. /**
  62384. * Evaluate a query
  62385. * @param query defines the query to evaluate
  62386. * @param evaluateCallback defines the callback used to filter result
  62387. * @returns true if the query matches
  62388. */
  62389. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62390. private static _HandleParenthesisContent;
  62391. private static _SimplifyNegation;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Class used to store custom tags
  62397. */
  62398. export class Tags {
  62399. /**
  62400. * Adds support for tags on the given object
  62401. * @param obj defines the object to use
  62402. */
  62403. static EnableFor(obj: any): void;
  62404. /**
  62405. * Removes tags support
  62406. * @param obj defines the object to use
  62407. */
  62408. static DisableFor(obj: any): void;
  62409. /**
  62410. * Gets a boolean indicating if the given object has tags
  62411. * @param obj defines the object to use
  62412. * @returns a boolean
  62413. */
  62414. static HasTags(obj: any): boolean;
  62415. /**
  62416. * Gets the tags available on a given object
  62417. * @param obj defines the object to use
  62418. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62419. * @returns the tags
  62420. */
  62421. static GetTags(obj: any, asString?: boolean): any;
  62422. /**
  62423. * Adds tags to an object
  62424. * @param obj defines the object to use
  62425. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62426. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62427. */
  62428. static AddTagsTo(obj: any, tagsString: string): void;
  62429. /**
  62430. * @hidden
  62431. */
  62432. static _AddTagTo(obj: any, tag: string): void;
  62433. /**
  62434. * Removes specific tags from a specific object
  62435. * @param obj defines the object to use
  62436. * @param tagsString defines the tags to remove
  62437. */
  62438. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62439. /**
  62440. * @hidden
  62441. */
  62442. static _RemoveTagFrom(obj: any, tag: string): void;
  62443. /**
  62444. * Defines if tags hosted on an object match a given query
  62445. * @param obj defines the object to use
  62446. * @param tagsQuery defines the tag query
  62447. * @returns a boolean
  62448. */
  62449. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /**
  62454. * Manages the defines for the Material
  62455. */
  62456. export class MaterialDefines {
  62457. private _keys;
  62458. private _isDirty;
  62459. /** @hidden */
  62460. _renderId: number;
  62461. /** @hidden */
  62462. _areLightsDirty: boolean;
  62463. /** @hidden */
  62464. _areAttributesDirty: boolean;
  62465. /** @hidden */
  62466. _areTexturesDirty: boolean;
  62467. /** @hidden */
  62468. _areFresnelDirty: boolean;
  62469. /** @hidden */
  62470. _areMiscDirty: boolean;
  62471. /** @hidden */
  62472. _areImageProcessingDirty: boolean;
  62473. /** @hidden */
  62474. _normals: boolean;
  62475. /** @hidden */
  62476. _uvs: boolean;
  62477. /** @hidden */
  62478. _needNormals: boolean;
  62479. /** @hidden */
  62480. _needUVs: boolean;
  62481. /**
  62482. * Specifies if the material needs to be re-calculated
  62483. */
  62484. readonly isDirty: boolean;
  62485. /**
  62486. * Marks the material to indicate that it has been re-calculated
  62487. */
  62488. markAsProcessed(): void;
  62489. /**
  62490. * Marks the material to indicate that it needs to be re-calculated
  62491. */
  62492. markAsUnprocessed(): void;
  62493. /**
  62494. * Marks the material to indicate all of its defines need to be re-calculated
  62495. */
  62496. markAllAsDirty(): void;
  62497. /**
  62498. * Marks the material to indicate that image processing needs to be re-calculated
  62499. */
  62500. markAsImageProcessingDirty(): void;
  62501. /**
  62502. * Marks the material to indicate the lights need to be re-calculated
  62503. */
  62504. markAsLightDirty(): void;
  62505. /**
  62506. * Marks the attribute state as changed
  62507. */
  62508. markAsAttributesDirty(): void;
  62509. /**
  62510. * Marks the texture state as changed
  62511. */
  62512. markAsTexturesDirty(): void;
  62513. /**
  62514. * Marks the fresnel state as changed
  62515. */
  62516. markAsFresnelDirty(): void;
  62517. /**
  62518. * Marks the misc state as changed
  62519. */
  62520. markAsMiscDirty(): void;
  62521. /**
  62522. * Rebuilds the material defines
  62523. */
  62524. rebuild(): void;
  62525. /**
  62526. * Specifies if two material defines are equal
  62527. * @param other - A material define instance to compare to
  62528. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62529. */
  62530. isEqual(other: MaterialDefines): boolean;
  62531. /**
  62532. * Clones this instance's defines to another instance
  62533. * @param other - material defines to clone values to
  62534. */
  62535. cloneTo(other: MaterialDefines): void;
  62536. /**
  62537. * Resets the material define values
  62538. */
  62539. reset(): void;
  62540. /**
  62541. * Converts the material define values to a string
  62542. * @returns - String of material define information
  62543. */
  62544. toString(): string;
  62545. }
  62546. }
  62547. declare module BABYLON {
  62548. /**
  62549. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62550. */
  62551. export class PerformanceMonitor {
  62552. private _enabled;
  62553. private _rollingFrameTime;
  62554. private _lastFrameTimeMs;
  62555. /**
  62556. * constructor
  62557. * @param frameSampleSize The number of samples required to saturate the sliding window
  62558. */
  62559. constructor(frameSampleSize?: number);
  62560. /**
  62561. * Samples current frame
  62562. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62563. */
  62564. sampleFrame(timeMs?: number): void;
  62565. /**
  62566. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62567. */
  62568. readonly averageFrameTime: number;
  62569. /**
  62570. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62571. */
  62572. readonly averageFrameTimeVariance: number;
  62573. /**
  62574. * Returns the frame time of the most recent frame
  62575. */
  62576. readonly instantaneousFrameTime: number;
  62577. /**
  62578. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62579. */
  62580. readonly averageFPS: number;
  62581. /**
  62582. * Returns the average framerate in frames per second using the most recent frame time
  62583. */
  62584. readonly instantaneousFPS: number;
  62585. /**
  62586. * Returns true if enough samples have been taken to completely fill the sliding window
  62587. */
  62588. readonly isSaturated: boolean;
  62589. /**
  62590. * Enables contributions to the sliding window sample set
  62591. */
  62592. enable(): void;
  62593. /**
  62594. * Disables contributions to the sliding window sample set
  62595. * Samples will not be interpolated over the disabled period
  62596. */
  62597. disable(): void;
  62598. /**
  62599. * Returns true if sampling is enabled
  62600. */
  62601. readonly isEnabled: boolean;
  62602. /**
  62603. * Resets performance monitor
  62604. */
  62605. reset(): void;
  62606. }
  62607. /**
  62608. * RollingAverage
  62609. *
  62610. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62611. */
  62612. export class RollingAverage {
  62613. /**
  62614. * Current average
  62615. */
  62616. average: number;
  62617. /**
  62618. * Current variance
  62619. */
  62620. variance: number;
  62621. protected _samples: Array<number>;
  62622. protected _sampleCount: number;
  62623. protected _pos: number;
  62624. protected _m2: number;
  62625. /**
  62626. * constructor
  62627. * @param length The number of samples required to saturate the sliding window
  62628. */
  62629. constructor(length: number);
  62630. /**
  62631. * Adds a sample to the sample set
  62632. * @param v The sample value
  62633. */
  62634. add(v: number): void;
  62635. /**
  62636. * Returns previously added values or null if outside of history or outside the sliding window domain
  62637. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62638. * @return Value previously recorded with add() or null if outside of range
  62639. */
  62640. history(i: number): number;
  62641. /**
  62642. * Returns true if enough samples have been taken to completely fill the sliding window
  62643. * @return true if sample-set saturated
  62644. */
  62645. isSaturated(): boolean;
  62646. /**
  62647. * Resets the rolling average (equivalent to 0 samples taken so far)
  62648. */
  62649. reset(): void;
  62650. /**
  62651. * Wraps a value around the sample range boundaries
  62652. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62653. * @return Wrapped position in sample range
  62654. */
  62655. protected _wrapPosition(i: number): number;
  62656. }
  62657. }
  62658. declare module BABYLON {
  62659. /**
  62660. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62661. * The underlying implementation relies on an associative array to ensure the best performances.
  62662. * The value can be anything including 'null' but except 'undefined'
  62663. */
  62664. export class StringDictionary<T> {
  62665. /**
  62666. * This will clear this dictionary and copy the content from the 'source' one.
  62667. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62668. * @param source the dictionary to take the content from and copy to this dictionary
  62669. */
  62670. copyFrom(source: StringDictionary<T>): void;
  62671. /**
  62672. * Get a value based from its key
  62673. * @param key the given key to get the matching value from
  62674. * @return the value if found, otherwise undefined is returned
  62675. */
  62676. get(key: string): T | undefined;
  62677. /**
  62678. * Get a value from its key or add it if it doesn't exist.
  62679. * This method will ensure you that a given key/data will be present in the dictionary.
  62680. * @param key the given key to get the matching value from
  62681. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62682. * The factory will only be invoked if there's no data for the given key.
  62683. * @return the value corresponding to the key.
  62684. */
  62685. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62686. /**
  62687. * Get a value from its key if present in the dictionary otherwise add it
  62688. * @param key the key to get the value from
  62689. * @param val if there's no such key/value pair in the dictionary add it with this value
  62690. * @return the value corresponding to the key
  62691. */
  62692. getOrAdd(key: string, val: T): T;
  62693. /**
  62694. * Check if there's a given key in the dictionary
  62695. * @param key the key to check for
  62696. * @return true if the key is present, false otherwise
  62697. */
  62698. contains(key: string): boolean;
  62699. /**
  62700. * Add a new key and its corresponding value
  62701. * @param key the key to add
  62702. * @param value the value corresponding to the key
  62703. * @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
  62704. */
  62705. add(key: string, value: T): boolean;
  62706. /**
  62707. * Update a specific value associated to a key
  62708. * @param key defines the key to use
  62709. * @param value defines the value to store
  62710. * @returns true if the value was updated (or false if the key was not found)
  62711. */
  62712. set(key: string, value: T): boolean;
  62713. /**
  62714. * Get the element of the given key and remove it from the dictionary
  62715. * @param key defines the key to search
  62716. * @returns the value associated with the key or null if not found
  62717. */
  62718. getAndRemove(key: string): Nullable<T>;
  62719. /**
  62720. * Remove a key/value from the dictionary.
  62721. * @param key the key to remove
  62722. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62723. */
  62724. remove(key: string): boolean;
  62725. /**
  62726. * Clear the whole content of the dictionary
  62727. */
  62728. clear(): void;
  62729. /**
  62730. * Gets the current count
  62731. */
  62732. readonly count: number;
  62733. /**
  62734. * Execute a callback on each key/val of the dictionary.
  62735. * Note that you can remove any element in this dictionary in the callback implementation
  62736. * @param callback the callback to execute on a given key/value pair
  62737. */
  62738. forEach(callback: (key: string, val: T) => void): void;
  62739. /**
  62740. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62741. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62742. * Note that you can remove any element in this dictionary in the callback implementation
  62743. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62744. * @returns the first item
  62745. */
  62746. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62747. private _count;
  62748. private _data;
  62749. }
  62750. }
  62751. declare module BABYLON {
  62752. /**
  62753. * Helper class that provides a small promise polyfill
  62754. */
  62755. export class PromisePolyfill {
  62756. /**
  62757. * Static function used to check if the polyfill is required
  62758. * If this is the case then the function will inject the polyfill to window.Promise
  62759. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62760. */
  62761. static Apply(force?: boolean): void;
  62762. }
  62763. }
  62764. declare module BABYLON {
  62765. /**
  62766. * Class used to store data that will be store in GPU memory
  62767. */
  62768. export class Buffer {
  62769. private _engine;
  62770. private _buffer;
  62771. /** @hidden */
  62772. _data: Nullable<DataArray>;
  62773. private _updatable;
  62774. private _instanced;
  62775. /**
  62776. * Gets the byte stride.
  62777. */
  62778. readonly byteStride: number;
  62779. /**
  62780. * Constructor
  62781. * @param engine the engine
  62782. * @param data the data to use for this buffer
  62783. * @param updatable whether the data is updatable
  62784. * @param stride the stride (optional)
  62785. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62786. * @param instanced whether the buffer is instanced (optional)
  62787. * @param useBytes set to true if the stride in in bytes (optional)
  62788. */
  62789. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62790. /**
  62791. * Create a new VertexBuffer based on the current buffer
  62792. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62793. * @param offset defines offset in the buffer (0 by default)
  62794. * @param size defines the size in floats of attributes (position is 3 for instance)
  62795. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62796. * @param instanced defines if the vertex buffer contains indexed data
  62797. * @param useBytes defines if the offset and stride are in bytes
  62798. * @returns the new vertex buffer
  62799. */
  62800. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62801. /**
  62802. * Gets a boolean indicating if the Buffer is updatable?
  62803. * @returns true if the buffer is updatable
  62804. */
  62805. isUpdatable(): boolean;
  62806. /**
  62807. * Gets current buffer's data
  62808. * @returns a DataArray or null
  62809. */
  62810. getData(): Nullable<DataArray>;
  62811. /**
  62812. * Gets underlying native buffer
  62813. * @returns underlying native buffer
  62814. */
  62815. getBuffer(): Nullable<WebGLBuffer>;
  62816. /**
  62817. * Gets the stride in float32 units (i.e. byte stride / 4).
  62818. * May not be an integer if the byte stride is not divisible by 4.
  62819. * DEPRECATED. Use byteStride instead.
  62820. * @returns the stride in float32 units
  62821. */
  62822. getStrideSize(): number;
  62823. /**
  62824. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62825. * @param data defines the data to store
  62826. */
  62827. create(data?: Nullable<DataArray>): void;
  62828. /** @hidden */
  62829. _rebuild(): void;
  62830. /**
  62831. * Update current buffer data
  62832. * @param data defines the data to store
  62833. */
  62834. update(data: DataArray): void;
  62835. /**
  62836. * Updates the data directly.
  62837. * @param data the new data
  62838. * @param offset the new offset
  62839. * @param vertexCount the vertex count (optional)
  62840. * @param useBytes set to true if the offset is in bytes
  62841. */
  62842. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62843. /**
  62844. * Release all resources
  62845. */
  62846. dispose(): void;
  62847. }
  62848. /**
  62849. * Specialized buffer used to store vertex data
  62850. */
  62851. export class VertexBuffer {
  62852. /** @hidden */
  62853. _buffer: Buffer;
  62854. private _kind;
  62855. private _size;
  62856. private _ownsBuffer;
  62857. private _instanced;
  62858. private _instanceDivisor;
  62859. /**
  62860. * The byte type.
  62861. */
  62862. static readonly BYTE: number;
  62863. /**
  62864. * The unsigned byte type.
  62865. */
  62866. static readonly UNSIGNED_BYTE: number;
  62867. /**
  62868. * The short type.
  62869. */
  62870. static readonly SHORT: number;
  62871. /**
  62872. * The unsigned short type.
  62873. */
  62874. static readonly UNSIGNED_SHORT: number;
  62875. /**
  62876. * The integer type.
  62877. */
  62878. static readonly INT: number;
  62879. /**
  62880. * The unsigned integer type.
  62881. */
  62882. static readonly UNSIGNED_INT: number;
  62883. /**
  62884. * The float type.
  62885. */
  62886. static readonly FLOAT: number;
  62887. /**
  62888. * Gets or sets the instance divisor when in instanced mode
  62889. */
  62890. instanceDivisor: number;
  62891. /**
  62892. * Gets the byte stride.
  62893. */
  62894. readonly byteStride: number;
  62895. /**
  62896. * Gets the byte offset.
  62897. */
  62898. readonly byteOffset: number;
  62899. /**
  62900. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62901. */
  62902. readonly normalized: boolean;
  62903. /**
  62904. * Gets the data type of each component in the array.
  62905. */
  62906. readonly type: number;
  62907. /**
  62908. * Constructor
  62909. * @param engine the engine
  62910. * @param data the data to use for this vertex buffer
  62911. * @param kind the vertex buffer kind
  62912. * @param updatable whether the data is updatable
  62913. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62914. * @param stride the stride (optional)
  62915. * @param instanced whether the buffer is instanced (optional)
  62916. * @param offset the offset of the data (optional)
  62917. * @param size the number of components (optional)
  62918. * @param type the type of the component (optional)
  62919. * @param normalized whether the data contains normalized data (optional)
  62920. * @param useBytes set to true if stride and offset are in bytes (optional)
  62921. */
  62922. 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);
  62923. /** @hidden */
  62924. _rebuild(): void;
  62925. /**
  62926. * Returns the kind of the VertexBuffer (string)
  62927. * @returns a string
  62928. */
  62929. getKind(): string;
  62930. /**
  62931. * Gets a boolean indicating if the VertexBuffer is updatable?
  62932. * @returns true if the buffer is updatable
  62933. */
  62934. isUpdatable(): boolean;
  62935. /**
  62936. * Gets current buffer's data
  62937. * @returns a DataArray or null
  62938. */
  62939. getData(): Nullable<DataArray>;
  62940. /**
  62941. * Gets underlying native buffer
  62942. * @returns underlying native buffer
  62943. */
  62944. getBuffer(): Nullable<WebGLBuffer>;
  62945. /**
  62946. * Gets the stride in float32 units (i.e. byte stride / 4).
  62947. * May not be an integer if the byte stride is not divisible by 4.
  62948. * DEPRECATED. Use byteStride instead.
  62949. * @returns the stride in float32 units
  62950. */
  62951. getStrideSize(): number;
  62952. /**
  62953. * Returns the offset as a multiple of the type byte length.
  62954. * DEPRECATED. Use byteOffset instead.
  62955. * @returns the offset in bytes
  62956. */
  62957. getOffset(): number;
  62958. /**
  62959. * Returns the number of components per vertex attribute (integer)
  62960. * @returns the size in float
  62961. */
  62962. getSize(): number;
  62963. /**
  62964. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62965. * @returns true if this buffer is instanced
  62966. */
  62967. getIsInstanced(): boolean;
  62968. /**
  62969. * Returns the instancing divisor, zero for non-instanced (integer).
  62970. * @returns a number
  62971. */
  62972. getInstanceDivisor(): number;
  62973. /**
  62974. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62975. * @param data defines the data to store
  62976. */
  62977. create(data?: DataArray): void;
  62978. /**
  62979. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62980. * This function will create a new buffer if the current one is not updatable
  62981. * @param data defines the data to store
  62982. */
  62983. update(data: DataArray): void;
  62984. /**
  62985. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62986. * Returns the directly updated WebGLBuffer.
  62987. * @param data the new data
  62988. * @param offset the new offset
  62989. * @param useBytes set to true if the offset is in bytes
  62990. */
  62991. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62992. /**
  62993. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62994. */
  62995. dispose(): void;
  62996. /**
  62997. * Enumerates each value of this vertex buffer as numbers.
  62998. * @param count the number of values to enumerate
  62999. * @param callback the callback function called for each value
  63000. */
  63001. forEach(count: number, callback: (value: number, index: number) => void): void;
  63002. /**
  63003. * Positions
  63004. */
  63005. static readonly PositionKind: string;
  63006. /**
  63007. * Normals
  63008. */
  63009. static readonly NormalKind: string;
  63010. /**
  63011. * Tangents
  63012. */
  63013. static readonly TangentKind: string;
  63014. /**
  63015. * Texture coordinates
  63016. */
  63017. static readonly UVKind: string;
  63018. /**
  63019. * Texture coordinates 2
  63020. */
  63021. static readonly UV2Kind: string;
  63022. /**
  63023. * Texture coordinates 3
  63024. */
  63025. static readonly UV3Kind: string;
  63026. /**
  63027. * Texture coordinates 4
  63028. */
  63029. static readonly UV4Kind: string;
  63030. /**
  63031. * Texture coordinates 5
  63032. */
  63033. static readonly UV5Kind: string;
  63034. /**
  63035. * Texture coordinates 6
  63036. */
  63037. static readonly UV6Kind: string;
  63038. /**
  63039. * Colors
  63040. */
  63041. static readonly ColorKind: string;
  63042. /**
  63043. * Matrix indices (for bones)
  63044. */
  63045. static readonly MatricesIndicesKind: string;
  63046. /**
  63047. * Matrix weights (for bones)
  63048. */
  63049. static readonly MatricesWeightsKind: string;
  63050. /**
  63051. * Additional matrix indices (for bones)
  63052. */
  63053. static readonly MatricesIndicesExtraKind: string;
  63054. /**
  63055. * Additional matrix weights (for bones)
  63056. */
  63057. static readonly MatricesWeightsExtraKind: string;
  63058. /**
  63059. * Deduces the stride given a kind.
  63060. * @param kind The kind string to deduce
  63061. * @returns The deduced stride
  63062. */
  63063. static DeduceStride(kind: string): number;
  63064. /**
  63065. * Gets the byte length of the given type.
  63066. * @param type the type
  63067. * @returns the number of bytes
  63068. */
  63069. static GetTypeByteLength(type: number): number;
  63070. /**
  63071. * Enumerates each value of the given parameters as numbers.
  63072. * @param data the data to enumerate
  63073. * @param byteOffset the byte offset of the data
  63074. * @param byteStride the byte stride of the data
  63075. * @param componentCount the number of components per element
  63076. * @param componentType the type of the component
  63077. * @param count the total number of components
  63078. * @param normalized whether the data is normalized
  63079. * @param callback the callback function called for each value
  63080. */
  63081. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63082. private static _GetFloatValue;
  63083. }
  63084. }
  63085. declare module BABYLON {
  63086. /**
  63087. * Class representing spherical polynomial coefficients to the 3rd degree
  63088. */
  63089. export class SphericalPolynomial {
  63090. /**
  63091. * The x coefficients of the spherical polynomial
  63092. */
  63093. x: Vector3;
  63094. /**
  63095. * The y coefficients of the spherical polynomial
  63096. */
  63097. y: Vector3;
  63098. /**
  63099. * The z coefficients of the spherical polynomial
  63100. */
  63101. z: Vector3;
  63102. /**
  63103. * The xx coefficients of the spherical polynomial
  63104. */
  63105. xx: Vector3;
  63106. /**
  63107. * The yy coefficients of the spherical polynomial
  63108. */
  63109. yy: Vector3;
  63110. /**
  63111. * The zz coefficients of the spherical polynomial
  63112. */
  63113. zz: Vector3;
  63114. /**
  63115. * The xy coefficients of the spherical polynomial
  63116. */
  63117. xy: Vector3;
  63118. /**
  63119. * The yz coefficients of the spherical polynomial
  63120. */
  63121. yz: Vector3;
  63122. /**
  63123. * The zx coefficients of the spherical polynomial
  63124. */
  63125. zx: Vector3;
  63126. /**
  63127. * Adds an ambient color to the spherical polynomial
  63128. * @param color the color to add
  63129. */
  63130. addAmbient(color: Color3): void;
  63131. /**
  63132. * Scales the spherical polynomial by the given amount
  63133. * @param scale the amount to scale
  63134. */
  63135. scale(scale: number): void;
  63136. /**
  63137. * Gets the spherical polynomial from harmonics
  63138. * @param harmonics the spherical harmonics
  63139. * @returns the spherical polynomial
  63140. */
  63141. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63142. /**
  63143. * Constructs a spherical polynomial from an array.
  63144. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63145. * @returns the spherical polynomial
  63146. */
  63147. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63148. }
  63149. /**
  63150. * Class representing spherical harmonics coefficients to the 3rd degree
  63151. */
  63152. export class SphericalHarmonics {
  63153. /**
  63154. * The l0,0 coefficients of the spherical harmonics
  63155. */
  63156. l00: Vector3;
  63157. /**
  63158. * The l1,-1 coefficients of the spherical harmonics
  63159. */
  63160. l1_1: Vector3;
  63161. /**
  63162. * The l1,0 coefficients of the spherical harmonics
  63163. */
  63164. l10: Vector3;
  63165. /**
  63166. * The l1,1 coefficients of the spherical harmonics
  63167. */
  63168. l11: Vector3;
  63169. /**
  63170. * The l2,-2 coefficients of the spherical harmonics
  63171. */
  63172. l2_2: Vector3;
  63173. /**
  63174. * The l2,-1 coefficients of the spherical harmonics
  63175. */
  63176. l2_1: Vector3;
  63177. /**
  63178. * The l2,0 coefficients of the spherical harmonics
  63179. */
  63180. l20: Vector3;
  63181. /**
  63182. * The l2,1 coefficients of the spherical harmonics
  63183. */
  63184. l21: Vector3;
  63185. /**
  63186. * The l2,2 coefficients of the spherical harmonics
  63187. */
  63188. lL22: Vector3;
  63189. /**
  63190. * Adds a light to the spherical harmonics
  63191. * @param direction the direction of the light
  63192. * @param color the color of the light
  63193. * @param deltaSolidAngle the delta solid angle of the light
  63194. */
  63195. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63196. /**
  63197. * Scales the spherical harmonics by the given amount
  63198. * @param scale the amount to scale
  63199. */
  63200. scale(scale: number): void;
  63201. /**
  63202. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63203. *
  63204. * ```
  63205. * E_lm = A_l * L_lm
  63206. * ```
  63207. *
  63208. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63209. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63210. * the scaling factors are given in equation 9.
  63211. */
  63212. convertIncidentRadianceToIrradiance(): void;
  63213. /**
  63214. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63215. *
  63216. * ```
  63217. * L = (1/pi) * E * rho
  63218. * ```
  63219. *
  63220. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63221. */
  63222. convertIrradianceToLambertianRadiance(): void;
  63223. /**
  63224. * Gets the spherical harmonics from polynomial
  63225. * @param polynomial the spherical polynomial
  63226. * @returns the spherical harmonics
  63227. */
  63228. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63229. /**
  63230. * Constructs a spherical harmonics from an array.
  63231. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63232. * @returns the spherical harmonics
  63233. */
  63234. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63235. }
  63236. }
  63237. declare module BABYLON {
  63238. /**
  63239. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63240. */
  63241. export interface CubeMapInfo {
  63242. /**
  63243. * The pixel array for the front face.
  63244. * This is stored in format, left to right, up to down format.
  63245. */
  63246. front: Nullable<ArrayBufferView>;
  63247. /**
  63248. * The pixel array for the back face.
  63249. * This is stored in format, left to right, up to down format.
  63250. */
  63251. back: Nullable<ArrayBufferView>;
  63252. /**
  63253. * The pixel array for the left face.
  63254. * This is stored in format, left to right, up to down format.
  63255. */
  63256. left: Nullable<ArrayBufferView>;
  63257. /**
  63258. * The pixel array for the right face.
  63259. * This is stored in format, left to right, up to down format.
  63260. */
  63261. right: Nullable<ArrayBufferView>;
  63262. /**
  63263. * The pixel array for the up face.
  63264. * This is stored in format, left to right, up to down format.
  63265. */
  63266. up: Nullable<ArrayBufferView>;
  63267. /**
  63268. * The pixel array for the down face.
  63269. * This is stored in format, left to right, up to down format.
  63270. */
  63271. down: Nullable<ArrayBufferView>;
  63272. /**
  63273. * The size of the cubemap stored.
  63274. *
  63275. * Each faces will be size * size pixels.
  63276. */
  63277. size: number;
  63278. /**
  63279. * The format of the texture.
  63280. *
  63281. * RGBA, RGB.
  63282. */
  63283. format: number;
  63284. /**
  63285. * The type of the texture data.
  63286. *
  63287. * UNSIGNED_INT, FLOAT.
  63288. */
  63289. type: number;
  63290. /**
  63291. * Specifies whether the texture is in gamma space.
  63292. */
  63293. gammaSpace: boolean;
  63294. }
  63295. /**
  63296. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63297. */
  63298. export class PanoramaToCubeMapTools {
  63299. private static FACE_FRONT;
  63300. private static FACE_BACK;
  63301. private static FACE_RIGHT;
  63302. private static FACE_LEFT;
  63303. private static FACE_DOWN;
  63304. private static FACE_UP;
  63305. /**
  63306. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63307. *
  63308. * @param float32Array The source data.
  63309. * @param inputWidth The width of the input panorama.
  63310. * @param inputHeight The height of the input panorama.
  63311. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63312. * @return The cubemap data
  63313. */
  63314. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63315. private static CreateCubemapTexture;
  63316. private static CalcProjectionSpherical;
  63317. }
  63318. }
  63319. declare module BABYLON {
  63320. /**
  63321. * Helper class dealing with the extraction of spherical polynomial dataArray
  63322. * from a cube map.
  63323. */
  63324. export class CubeMapToSphericalPolynomialTools {
  63325. private static FileFaces;
  63326. /**
  63327. * Converts a texture to the according Spherical Polynomial data.
  63328. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63329. *
  63330. * @param texture The texture to extract the information from.
  63331. * @return The Spherical Polynomial data.
  63332. */
  63333. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63334. /**
  63335. * Converts a cubemap to the according Spherical Polynomial data.
  63336. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63337. *
  63338. * @param cubeInfo The Cube map to extract the information from.
  63339. * @return The Spherical Polynomial data.
  63340. */
  63341. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63342. }
  63343. }
  63344. declare module BABYLON {
  63345. /**
  63346. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63347. * during the life time of the application.
  63348. */
  63349. export class EngineStore {
  63350. /** Gets the list of created engines */
  63351. static Instances: Engine[];
  63352. /**
  63353. * Gets the latest created engine
  63354. */
  63355. static readonly LastCreatedEngine: Nullable<Engine>;
  63356. /**
  63357. * Gets the latest created scene
  63358. */
  63359. static readonly LastCreatedScene: Nullable<Scene>;
  63360. }
  63361. }
  63362. declare module BABYLON {
  63363. /**
  63364. * Define options used to create a render target texture
  63365. */
  63366. export class RenderTargetCreationOptions {
  63367. /**
  63368. * Specifies is mipmaps must be generated
  63369. */
  63370. generateMipMaps?: boolean;
  63371. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63372. generateDepthBuffer?: boolean;
  63373. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63374. generateStencilBuffer?: boolean;
  63375. /** Defines texture type (int by default) */
  63376. type?: number;
  63377. /** Defines sampling mode (trilinear by default) */
  63378. samplingMode?: number;
  63379. /** Defines format (RGBA by default) */
  63380. format?: number;
  63381. }
  63382. }
  63383. declare module BABYLON {
  63384. /**
  63385. * @hidden
  63386. **/
  63387. export class _AlphaState {
  63388. private _isAlphaBlendDirty;
  63389. private _isBlendFunctionParametersDirty;
  63390. private _isBlendEquationParametersDirty;
  63391. private _isBlendConstantsDirty;
  63392. private _alphaBlend;
  63393. private _blendFunctionParameters;
  63394. private _blendEquationParameters;
  63395. private _blendConstants;
  63396. /**
  63397. * Initializes the state.
  63398. */
  63399. constructor();
  63400. readonly isDirty: boolean;
  63401. alphaBlend: boolean;
  63402. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63403. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63404. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63405. reset(): void;
  63406. apply(gl: WebGLRenderingContext): void;
  63407. }
  63408. }
  63409. declare module BABYLON {
  63410. /**
  63411. * @hidden
  63412. **/
  63413. export class _DepthCullingState {
  63414. private _isDepthTestDirty;
  63415. private _isDepthMaskDirty;
  63416. private _isDepthFuncDirty;
  63417. private _isCullFaceDirty;
  63418. private _isCullDirty;
  63419. private _isZOffsetDirty;
  63420. private _isFrontFaceDirty;
  63421. private _depthTest;
  63422. private _depthMask;
  63423. private _depthFunc;
  63424. private _cull;
  63425. private _cullFace;
  63426. private _zOffset;
  63427. private _frontFace;
  63428. /**
  63429. * Initializes the state.
  63430. */
  63431. constructor();
  63432. readonly isDirty: boolean;
  63433. zOffset: number;
  63434. cullFace: Nullable<number>;
  63435. cull: Nullable<boolean>;
  63436. depthFunc: Nullable<number>;
  63437. depthMask: boolean;
  63438. depthTest: boolean;
  63439. frontFace: Nullable<number>;
  63440. reset(): void;
  63441. apply(gl: WebGLRenderingContext): void;
  63442. }
  63443. }
  63444. declare module BABYLON {
  63445. /**
  63446. * @hidden
  63447. **/
  63448. export class _StencilState {
  63449. /** 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 */
  63450. static readonly ALWAYS: number;
  63451. /** Passed to stencilOperation to specify that stencil value must be kept */
  63452. static readonly KEEP: number;
  63453. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63454. static readonly REPLACE: number;
  63455. private _isStencilTestDirty;
  63456. private _isStencilMaskDirty;
  63457. private _isStencilFuncDirty;
  63458. private _isStencilOpDirty;
  63459. private _stencilTest;
  63460. private _stencilMask;
  63461. private _stencilFunc;
  63462. private _stencilFuncRef;
  63463. private _stencilFuncMask;
  63464. private _stencilOpStencilFail;
  63465. private _stencilOpDepthFail;
  63466. private _stencilOpStencilDepthPass;
  63467. readonly isDirty: boolean;
  63468. stencilFunc: number;
  63469. stencilFuncRef: number;
  63470. stencilFuncMask: number;
  63471. stencilOpStencilFail: number;
  63472. stencilOpDepthFail: number;
  63473. stencilOpStencilDepthPass: number;
  63474. stencilMask: number;
  63475. stencilTest: boolean;
  63476. constructor();
  63477. reset(): void;
  63478. apply(gl: WebGLRenderingContext): void;
  63479. }
  63480. }
  63481. declare module BABYLON {
  63482. /**
  63483. * @hidden
  63484. **/
  63485. export class _TimeToken {
  63486. _startTimeQuery: Nullable<WebGLQuery>;
  63487. _endTimeQuery: Nullable<WebGLQuery>;
  63488. _timeElapsedQuery: Nullable<WebGLQuery>;
  63489. _timeElapsedQueryEnded: boolean;
  63490. }
  63491. }
  63492. declare module BABYLON {
  63493. /**
  63494. * Internal interface used to track InternalTexture already bound to the GL context
  63495. */
  63496. export interface IInternalTextureTracker {
  63497. /**
  63498. * Gets or set the previous tracker in the list
  63499. */
  63500. previous: Nullable<IInternalTextureTracker>;
  63501. /**
  63502. * Gets or set the next tracker in the list
  63503. */
  63504. next: Nullable<IInternalTextureTracker>;
  63505. }
  63506. /**
  63507. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63508. */
  63509. export class DummyInternalTextureTracker {
  63510. /**
  63511. * Gets or set the previous tracker in the list
  63512. */
  63513. previous: Nullable<IInternalTextureTracker>;
  63514. /**
  63515. * Gets or set the next tracker in the list
  63516. */
  63517. next: Nullable<IInternalTextureTracker>;
  63518. }
  63519. }
  63520. declare module BABYLON {
  63521. /**
  63522. * Class used to store data associated with WebGL texture data for the engine
  63523. * This class should not be used directly
  63524. */
  63525. export class InternalTexture implements IInternalTextureTracker {
  63526. /** hidden */
  63527. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63528. /**
  63529. * The source of the texture data is unknown
  63530. */
  63531. static DATASOURCE_UNKNOWN: number;
  63532. /**
  63533. * Texture data comes from an URL
  63534. */
  63535. static DATASOURCE_URL: number;
  63536. /**
  63537. * Texture data is only used for temporary storage
  63538. */
  63539. static DATASOURCE_TEMP: number;
  63540. /**
  63541. * Texture data comes from raw data (ArrayBuffer)
  63542. */
  63543. static DATASOURCE_RAW: number;
  63544. /**
  63545. * Texture content is dynamic (video or dynamic texture)
  63546. */
  63547. static DATASOURCE_DYNAMIC: number;
  63548. /**
  63549. * Texture content is generated by rendering to it
  63550. */
  63551. static DATASOURCE_RENDERTARGET: number;
  63552. /**
  63553. * Texture content is part of a multi render target process
  63554. */
  63555. static DATASOURCE_MULTIRENDERTARGET: number;
  63556. /**
  63557. * Texture data comes from a cube data file
  63558. */
  63559. static DATASOURCE_CUBE: number;
  63560. /**
  63561. * Texture data comes from a raw cube data
  63562. */
  63563. static DATASOURCE_CUBERAW: number;
  63564. /**
  63565. * Texture data come from a prefiltered cube data file
  63566. */
  63567. static DATASOURCE_CUBEPREFILTERED: number;
  63568. /**
  63569. * Texture content is raw 3D data
  63570. */
  63571. static DATASOURCE_RAW3D: number;
  63572. /**
  63573. * Texture content is a depth texture
  63574. */
  63575. static DATASOURCE_DEPTHTEXTURE: number;
  63576. /**
  63577. * Texture data comes from a raw cube data encoded with RGBD
  63578. */
  63579. static DATASOURCE_CUBERAW_RGBD: number;
  63580. /**
  63581. * Defines if the texture is ready
  63582. */
  63583. isReady: boolean;
  63584. /**
  63585. * Defines if the texture is a cube texture
  63586. */
  63587. isCube: boolean;
  63588. /**
  63589. * Defines if the texture contains 3D data
  63590. */
  63591. is3D: boolean;
  63592. /**
  63593. * Gets the URL used to load this texture
  63594. */
  63595. url: string;
  63596. /**
  63597. * Gets the sampling mode of the texture
  63598. */
  63599. samplingMode: number;
  63600. /**
  63601. * Gets a boolean indicating if the texture needs mipmaps generation
  63602. */
  63603. generateMipMaps: boolean;
  63604. /**
  63605. * Gets the number of samples used by the texture (WebGL2+ only)
  63606. */
  63607. samples: number;
  63608. /**
  63609. * Gets the type of the texture (int, float...)
  63610. */
  63611. type: number;
  63612. /**
  63613. * Gets the format of the texture (RGB, RGBA...)
  63614. */
  63615. format: number;
  63616. /**
  63617. * Observable called when the texture is loaded
  63618. */
  63619. onLoadedObservable: Observable<InternalTexture>;
  63620. /**
  63621. * Gets the width of the texture
  63622. */
  63623. width: number;
  63624. /**
  63625. * Gets the height of the texture
  63626. */
  63627. height: number;
  63628. /**
  63629. * Gets the depth of the texture
  63630. */
  63631. depth: number;
  63632. /**
  63633. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63634. */
  63635. baseWidth: number;
  63636. /**
  63637. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63638. */
  63639. baseHeight: number;
  63640. /**
  63641. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63642. */
  63643. baseDepth: number;
  63644. /**
  63645. * Gets a boolean indicating if the texture is inverted on Y axis
  63646. */
  63647. invertY: boolean;
  63648. /**
  63649. * Gets or set the previous tracker in the list
  63650. */
  63651. previous: Nullable<IInternalTextureTracker>;
  63652. /**
  63653. * Gets or set the next tracker in the list
  63654. */
  63655. next: Nullable<IInternalTextureTracker>;
  63656. /** @hidden */
  63657. _invertVScale: boolean;
  63658. /** @hidden */
  63659. _initialSlot: number;
  63660. /** @hidden */
  63661. _designatedSlot: number;
  63662. /** @hidden */
  63663. _dataSource: number;
  63664. /** @hidden */
  63665. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63666. /** @hidden */
  63667. _bufferView: Nullable<ArrayBufferView>;
  63668. /** @hidden */
  63669. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63670. /** @hidden */
  63671. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63672. /** @hidden */
  63673. _size: number;
  63674. /** @hidden */
  63675. _extension: string;
  63676. /** @hidden */
  63677. _files: Nullable<string[]>;
  63678. /** @hidden */
  63679. _workingCanvas: HTMLCanvasElement;
  63680. /** @hidden */
  63681. _workingContext: CanvasRenderingContext2D;
  63682. /** @hidden */
  63683. _framebuffer: Nullable<WebGLFramebuffer>;
  63684. /** @hidden */
  63685. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63686. /** @hidden */
  63687. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63688. /** @hidden */
  63689. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63690. /** @hidden */
  63691. _attachments: Nullable<number[]>;
  63692. /** @hidden */
  63693. _cachedCoordinatesMode: Nullable<number>;
  63694. /** @hidden */
  63695. _cachedWrapU: Nullable<number>;
  63696. /** @hidden */
  63697. _cachedWrapV: Nullable<number>;
  63698. /** @hidden */
  63699. _cachedWrapR: Nullable<number>;
  63700. /** @hidden */
  63701. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63702. /** @hidden */
  63703. _isDisabled: boolean;
  63704. /** @hidden */
  63705. _compression: Nullable<string>;
  63706. /** @hidden */
  63707. _generateStencilBuffer: boolean;
  63708. /** @hidden */
  63709. _generateDepthBuffer: boolean;
  63710. /** @hidden */
  63711. _comparisonFunction: number;
  63712. /** @hidden */
  63713. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63714. /** @hidden */
  63715. _lodGenerationScale: number;
  63716. /** @hidden */
  63717. _lodGenerationOffset: number;
  63718. /** @hidden */
  63719. _lodTextureHigh: BaseTexture;
  63720. /** @hidden */
  63721. _lodTextureMid: BaseTexture;
  63722. /** @hidden */
  63723. _lodTextureLow: BaseTexture;
  63724. /** @hidden */
  63725. _isRGBD: boolean;
  63726. /** @hidden */
  63727. _webGLTexture: Nullable<WebGLTexture>;
  63728. /** @hidden */
  63729. _references: number;
  63730. private _engine;
  63731. /**
  63732. * Gets the Engine the texture belongs to.
  63733. * @returns The babylon engine
  63734. */
  63735. getEngine(): Engine;
  63736. /**
  63737. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63738. */
  63739. readonly dataSource: number;
  63740. /**
  63741. * Creates a new InternalTexture
  63742. * @param engine defines the engine to use
  63743. * @param dataSource defines the type of data that will be used
  63744. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63745. */
  63746. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63747. /**
  63748. * Increments the number of references (ie. the number of Texture that point to it)
  63749. */
  63750. incrementReferences(): void;
  63751. /**
  63752. * Change the size of the texture (not the size of the content)
  63753. * @param width defines the new width
  63754. * @param height defines the new height
  63755. * @param depth defines the new depth (1 by default)
  63756. */
  63757. updateSize(width: int, height: int, depth?: int): void;
  63758. /** @hidden */
  63759. _rebuild(): void;
  63760. /** @hidden */
  63761. _swapAndDie(target: InternalTexture): void;
  63762. /**
  63763. * Dispose the current allocated resources
  63764. */
  63765. dispose(): void;
  63766. }
  63767. }
  63768. declare module BABYLON {
  63769. /**
  63770. * This represents the main contract an easing function should follow.
  63771. * Easing functions are used throughout the animation system.
  63772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63773. */
  63774. export interface IEasingFunction {
  63775. /**
  63776. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63777. * of the easing function.
  63778. * The link below provides some of the most common examples of easing functions.
  63779. * @see https://easings.net/
  63780. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63781. * @returns the corresponding value on the curve defined by the easing function
  63782. */
  63783. ease(gradient: number): number;
  63784. }
  63785. /**
  63786. * Base class used for every default easing function.
  63787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63788. */
  63789. export class EasingFunction implements IEasingFunction {
  63790. /**
  63791. * Interpolation follows the mathematical formula associated with the easing function.
  63792. */
  63793. static readonly EASINGMODE_EASEIN: number;
  63794. /**
  63795. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63796. */
  63797. static readonly EASINGMODE_EASEOUT: number;
  63798. /**
  63799. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63800. */
  63801. static readonly EASINGMODE_EASEINOUT: number;
  63802. private _easingMode;
  63803. /**
  63804. * Sets the easing mode of the current function.
  63805. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63806. */
  63807. setEasingMode(easingMode: number): void;
  63808. /**
  63809. * Gets the current easing mode.
  63810. * @returns the easing mode
  63811. */
  63812. getEasingMode(): number;
  63813. /**
  63814. * @hidden
  63815. */
  63816. easeInCore(gradient: number): number;
  63817. /**
  63818. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63819. * of the easing function.
  63820. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63821. * @returns the corresponding value on the curve defined by the easing function
  63822. */
  63823. ease(gradient: number): number;
  63824. }
  63825. /**
  63826. * Easing function with a circle shape (see link below).
  63827. * @see https://easings.net/#easeInCirc
  63828. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63829. */
  63830. export class CircleEase extends EasingFunction implements IEasingFunction {
  63831. /** @hidden */
  63832. easeInCore(gradient: number): number;
  63833. }
  63834. /**
  63835. * Easing function with a ease back shape (see link below).
  63836. * @see https://easings.net/#easeInBack
  63837. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63838. */
  63839. export class BackEase extends EasingFunction implements IEasingFunction {
  63840. /** Defines the amplitude of the function */
  63841. amplitude: number;
  63842. /**
  63843. * Instantiates a back ease easing
  63844. * @see https://easings.net/#easeInBack
  63845. * @param amplitude Defines the amplitude of the function
  63846. */
  63847. constructor(
  63848. /** Defines the amplitude of the function */
  63849. amplitude?: number);
  63850. /** @hidden */
  63851. easeInCore(gradient: number): number;
  63852. }
  63853. /**
  63854. * Easing function with a bouncing shape (see link below).
  63855. * @see https://easings.net/#easeInBounce
  63856. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63857. */
  63858. export class BounceEase extends EasingFunction implements IEasingFunction {
  63859. /** Defines the number of bounces */
  63860. bounces: number;
  63861. /** Defines the amplitude of the bounce */
  63862. bounciness: number;
  63863. /**
  63864. * Instantiates a bounce easing
  63865. * @see https://easings.net/#easeInBounce
  63866. * @param bounces Defines the number of bounces
  63867. * @param bounciness Defines the amplitude of the bounce
  63868. */
  63869. constructor(
  63870. /** Defines the number of bounces */
  63871. bounces?: number,
  63872. /** Defines the amplitude of the bounce */
  63873. bounciness?: number);
  63874. /** @hidden */
  63875. easeInCore(gradient: number): number;
  63876. }
  63877. /**
  63878. * Easing function with a power of 3 shape (see link below).
  63879. * @see https://easings.net/#easeInCubic
  63880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63881. */
  63882. export class CubicEase extends EasingFunction implements IEasingFunction {
  63883. /** @hidden */
  63884. easeInCore(gradient: number): number;
  63885. }
  63886. /**
  63887. * Easing function with an elastic shape (see link below).
  63888. * @see https://easings.net/#easeInElastic
  63889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63890. */
  63891. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63892. /** Defines the number of oscillations*/
  63893. oscillations: number;
  63894. /** Defines the amplitude of the oscillations*/
  63895. springiness: number;
  63896. /**
  63897. * Instantiates an elastic easing function
  63898. * @see https://easings.net/#easeInElastic
  63899. * @param oscillations Defines the number of oscillations
  63900. * @param springiness Defines the amplitude of the oscillations
  63901. */
  63902. constructor(
  63903. /** Defines the number of oscillations*/
  63904. oscillations?: number,
  63905. /** Defines the amplitude of the oscillations*/
  63906. springiness?: number);
  63907. /** @hidden */
  63908. easeInCore(gradient: number): number;
  63909. }
  63910. /**
  63911. * Easing function with an exponential shape (see link below).
  63912. * @see https://easings.net/#easeInExpo
  63913. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63914. */
  63915. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63916. /** Defines the exponent of the function */
  63917. exponent: number;
  63918. /**
  63919. * Instantiates an exponential easing function
  63920. * @see https://easings.net/#easeInExpo
  63921. * @param exponent Defines the exponent of the function
  63922. */
  63923. constructor(
  63924. /** Defines the exponent of the function */
  63925. exponent?: number);
  63926. /** @hidden */
  63927. easeInCore(gradient: number): number;
  63928. }
  63929. /**
  63930. * Easing function with a power shape (see link below).
  63931. * @see https://easings.net/#easeInQuad
  63932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63933. */
  63934. export class PowerEase extends EasingFunction implements IEasingFunction {
  63935. /** Defines the power of the function */
  63936. power: number;
  63937. /**
  63938. * Instantiates an power base easing function
  63939. * @see https://easings.net/#easeInQuad
  63940. * @param power Defines the power of the function
  63941. */
  63942. constructor(
  63943. /** Defines the power of the function */
  63944. power?: number);
  63945. /** @hidden */
  63946. easeInCore(gradient: number): number;
  63947. }
  63948. /**
  63949. * Easing function with a power of 2 shape (see link below).
  63950. * @see https://easings.net/#easeInQuad
  63951. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63952. */
  63953. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63954. /** @hidden */
  63955. easeInCore(gradient: number): number;
  63956. }
  63957. /**
  63958. * Easing function with a power of 4 shape (see link below).
  63959. * @see https://easings.net/#easeInQuart
  63960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63961. */
  63962. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63963. /** @hidden */
  63964. easeInCore(gradient: number): number;
  63965. }
  63966. /**
  63967. * Easing function with a power of 5 shape (see link below).
  63968. * @see https://easings.net/#easeInQuint
  63969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63970. */
  63971. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63972. /** @hidden */
  63973. easeInCore(gradient: number): number;
  63974. }
  63975. /**
  63976. * Easing function with a sin shape (see link below).
  63977. * @see https://easings.net/#easeInSine
  63978. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63979. */
  63980. export class SineEase extends EasingFunction implements IEasingFunction {
  63981. /** @hidden */
  63982. easeInCore(gradient: number): number;
  63983. }
  63984. /**
  63985. * Easing function with a bezier shape (see link below).
  63986. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63988. */
  63989. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63990. /** Defines the x component of the start tangent in the bezier curve */
  63991. x1: number;
  63992. /** Defines the y component of the start tangent in the bezier curve */
  63993. y1: number;
  63994. /** Defines the x component of the end tangent in the bezier curve */
  63995. x2: number;
  63996. /** Defines the y component of the end tangent in the bezier curve */
  63997. y2: number;
  63998. /**
  63999. * Instantiates a bezier function
  64000. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64001. * @param x1 Defines the x component of the start tangent in the bezier curve
  64002. * @param y1 Defines the y component of the start tangent in the bezier curve
  64003. * @param x2 Defines the x component of the end tangent in the bezier curve
  64004. * @param y2 Defines the y component of the end tangent in the bezier curve
  64005. */
  64006. constructor(
  64007. /** Defines the x component of the start tangent in the bezier curve */
  64008. x1?: number,
  64009. /** Defines the y component of the start tangent in the bezier curve */
  64010. y1?: number,
  64011. /** Defines the x component of the end tangent in the bezier curve */
  64012. x2?: number,
  64013. /** Defines the y component of the end tangent in the bezier curve */
  64014. y2?: number);
  64015. /** @hidden */
  64016. easeInCore(gradient: number): number;
  64017. }
  64018. }
  64019. declare module BABYLON {
  64020. /**
  64021. * Defines an interface which represents an animation key frame
  64022. */
  64023. export interface IAnimationKey {
  64024. /**
  64025. * Frame of the key frame
  64026. */
  64027. frame: number;
  64028. /**
  64029. * Value at the specifies key frame
  64030. */
  64031. value: any;
  64032. /**
  64033. * The input tangent for the cubic hermite spline
  64034. */
  64035. inTangent?: any;
  64036. /**
  64037. * The output tangent for the cubic hermite spline
  64038. */
  64039. outTangent?: any;
  64040. /**
  64041. * The animation interpolation type
  64042. */
  64043. interpolation?: AnimationKeyInterpolation;
  64044. }
  64045. /**
  64046. * Enum for the animation key frame interpolation type
  64047. */
  64048. export enum AnimationKeyInterpolation {
  64049. /**
  64050. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64051. */
  64052. STEP = 1
  64053. }
  64054. }
  64055. declare module BABYLON {
  64056. /**
  64057. * Represents the range of an animation
  64058. */
  64059. export class AnimationRange {
  64060. /**The name of the animation range**/
  64061. name: string;
  64062. /**The starting frame of the animation */
  64063. from: number;
  64064. /**The ending frame of the animation*/
  64065. to: number;
  64066. /**
  64067. * Initializes the range of an animation
  64068. * @param name The name of the animation range
  64069. * @param from The starting frame of the animation
  64070. * @param to The ending frame of the animation
  64071. */
  64072. constructor(
  64073. /**The name of the animation range**/
  64074. name: string,
  64075. /**The starting frame of the animation */
  64076. from: number,
  64077. /**The ending frame of the animation*/
  64078. to: number);
  64079. /**
  64080. * Makes a copy of the animation range
  64081. * @returns A copy of the animation range
  64082. */
  64083. clone(): AnimationRange;
  64084. }
  64085. }
  64086. declare module BABYLON {
  64087. /**
  64088. * Composed of a frame, and an action function
  64089. */
  64090. export class AnimationEvent {
  64091. /** The frame for which the event is triggered **/
  64092. frame: number;
  64093. /** The event to perform when triggered **/
  64094. action: (currentFrame: number) => void;
  64095. /** Specifies if the event should be triggered only once**/
  64096. onlyOnce?: boolean | undefined;
  64097. /**
  64098. * Specifies if the animation event is done
  64099. */
  64100. isDone: boolean;
  64101. /**
  64102. * Initializes the animation event
  64103. * @param frame The frame for which the event is triggered
  64104. * @param action The event to perform when triggered
  64105. * @param onlyOnce Specifies if the event should be triggered only once
  64106. */
  64107. constructor(
  64108. /** The frame for which the event is triggered **/
  64109. frame: number,
  64110. /** The event to perform when triggered **/
  64111. action: (currentFrame: number) => void,
  64112. /** Specifies if the event should be triggered only once**/
  64113. onlyOnce?: boolean | undefined);
  64114. /** @hidden */
  64115. _clone(): AnimationEvent;
  64116. }
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * Interface used to define a behavior
  64121. */
  64122. export interface Behavior<T> {
  64123. /** gets or sets behavior's name */
  64124. name: string;
  64125. /**
  64126. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64127. */
  64128. init(): void;
  64129. /**
  64130. * Called when the behavior is attached to a target
  64131. * @param target defines the target where the behavior is attached to
  64132. */
  64133. attach(target: T): void;
  64134. /**
  64135. * Called when the behavior is detached from its target
  64136. */
  64137. detach(): void;
  64138. }
  64139. /**
  64140. * Interface implemented by classes supporting behaviors
  64141. */
  64142. export interface IBehaviorAware<T> {
  64143. /**
  64144. * Attach a behavior
  64145. * @param behavior defines the behavior to attach
  64146. * @returns the current host
  64147. */
  64148. addBehavior(behavior: Behavior<T>): T;
  64149. /**
  64150. * Remove a behavior from the current object
  64151. * @param behavior defines the behavior to detach
  64152. * @returns the current host
  64153. */
  64154. removeBehavior(behavior: Behavior<T>): T;
  64155. /**
  64156. * Gets a behavior using its name to search
  64157. * @param name defines the name to search
  64158. * @returns the behavior or null if not found
  64159. */
  64160. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64161. }
  64162. }
  64163. declare module BABYLON {
  64164. /**
  64165. * @hidden
  64166. */
  64167. export class IntersectionInfo {
  64168. bu: Nullable<number>;
  64169. bv: Nullable<number>;
  64170. distance: number;
  64171. faceId: number;
  64172. subMeshId: number;
  64173. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64174. }
  64175. }
  64176. declare module BABYLON {
  64177. /**
  64178. * Class used to store bounding sphere information
  64179. */
  64180. export class BoundingSphere {
  64181. /**
  64182. * Gets the center of the bounding sphere in local space
  64183. */
  64184. readonly center: Vector3;
  64185. /**
  64186. * Radius of the bounding sphere in local space
  64187. */
  64188. radius: number;
  64189. /**
  64190. * Gets the center of the bounding sphere in world space
  64191. */
  64192. readonly centerWorld: Vector3;
  64193. /**
  64194. * Radius of the bounding sphere in world space
  64195. */
  64196. radiusWorld: number;
  64197. /**
  64198. * Gets the minimum vector in local space
  64199. */
  64200. readonly minimum: Vector3;
  64201. /**
  64202. * Gets the maximum vector in local space
  64203. */
  64204. readonly maximum: Vector3;
  64205. private _worldMatrix;
  64206. private static readonly TmpVector3;
  64207. /**
  64208. * Creates a new bounding sphere
  64209. * @param min defines the minimum vector (in local space)
  64210. * @param max defines the maximum vector (in local space)
  64211. * @param worldMatrix defines the new world matrix
  64212. */
  64213. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64214. /**
  64215. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64216. * @param min defines the new minimum vector (in local space)
  64217. * @param max defines the new maximum vector (in local space)
  64218. * @param worldMatrix defines the new world matrix
  64219. */
  64220. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64221. /**
  64222. * Scale the current bounding sphere by applying a scale factor
  64223. * @param factor defines the scale factor to apply
  64224. * @returns the current bounding box
  64225. */
  64226. scale(factor: number): BoundingSphere;
  64227. /**
  64228. * Gets the world matrix of the bounding box
  64229. * @returns a matrix
  64230. */
  64231. getWorldMatrix(): DeepImmutable<Matrix>;
  64232. /** @hidden */
  64233. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64234. /**
  64235. * Tests if the bounding sphere is intersecting the frustum planes
  64236. * @param frustumPlanes defines the frustum planes to test
  64237. * @returns true if there is an intersection
  64238. */
  64239. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64240. /**
  64241. * Tests if the bounding sphere center is in between the frustum planes.
  64242. * Used for optimistic fast inclusion.
  64243. * @param frustumPlanes defines the frustum planes to test
  64244. * @returns true if the sphere center is in between the frustum planes
  64245. */
  64246. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64247. /**
  64248. * Tests if a point is inside the bounding sphere
  64249. * @param point defines the point to test
  64250. * @returns true if the point is inside the bounding sphere
  64251. */
  64252. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64253. /**
  64254. * Checks if two sphere intersct
  64255. * @param sphere0 sphere 0
  64256. * @param sphere1 sphere 1
  64257. * @returns true if the speres intersect
  64258. */
  64259. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Class used to store bounding box information
  64265. */
  64266. export class BoundingBox implements ICullable {
  64267. /**
  64268. * Gets the 8 vectors representing the bounding box in local space
  64269. */
  64270. readonly vectors: Vector3[];
  64271. /**
  64272. * Gets the center of the bounding box in local space
  64273. */
  64274. readonly center: Vector3;
  64275. /**
  64276. * Gets the center of the bounding box in world space
  64277. */
  64278. readonly centerWorld: Vector3;
  64279. /**
  64280. * Gets the extend size in local space
  64281. */
  64282. readonly extendSize: Vector3;
  64283. /**
  64284. * Gets the extend size in world space
  64285. */
  64286. readonly extendSizeWorld: Vector3;
  64287. /**
  64288. * Gets the OBB (object bounding box) directions
  64289. */
  64290. readonly directions: Vector3[];
  64291. /**
  64292. * Gets the 8 vectors representing the bounding box in world space
  64293. */
  64294. readonly vectorsWorld: Vector3[];
  64295. /**
  64296. * Gets the minimum vector in world space
  64297. */
  64298. readonly minimumWorld: Vector3;
  64299. /**
  64300. * Gets the maximum vector in world space
  64301. */
  64302. readonly maximumWorld: Vector3;
  64303. /**
  64304. * Gets the minimum vector in local space
  64305. */
  64306. readonly minimum: Vector3;
  64307. /**
  64308. * Gets the maximum vector in local space
  64309. */
  64310. readonly maximum: Vector3;
  64311. private _worldMatrix;
  64312. private static readonly TmpVector3;
  64313. /**
  64314. * @hidden
  64315. */
  64316. _tag: number;
  64317. /**
  64318. * Creates a new bounding box
  64319. * @param min defines the minimum vector (in local space)
  64320. * @param max defines the maximum vector (in local space)
  64321. * @param worldMatrix defines the new world matrix
  64322. */
  64323. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64324. /**
  64325. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64326. * @param min defines the new minimum vector (in local space)
  64327. * @param max defines the new maximum vector (in local space)
  64328. * @param worldMatrix defines the new world matrix
  64329. */
  64330. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64331. /**
  64332. * Scale the current bounding box by applying a scale factor
  64333. * @param factor defines the scale factor to apply
  64334. * @returns the current bounding box
  64335. */
  64336. scale(factor: number): BoundingBox;
  64337. /**
  64338. * Gets the world matrix of the bounding box
  64339. * @returns a matrix
  64340. */
  64341. getWorldMatrix(): DeepImmutable<Matrix>;
  64342. /** @hidden */
  64343. _update(world: DeepImmutable<Matrix>): void;
  64344. /**
  64345. * Tests if the bounding box is intersecting the frustum planes
  64346. * @param frustumPlanes defines the frustum planes to test
  64347. * @returns true if there is an intersection
  64348. */
  64349. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64350. /**
  64351. * Tests if the bounding box is entirely inside the frustum planes
  64352. * @param frustumPlanes defines the frustum planes to test
  64353. * @returns true if there is an inclusion
  64354. */
  64355. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64356. /**
  64357. * Tests if a point is inside the bounding box
  64358. * @param point defines the point to test
  64359. * @returns true if the point is inside the bounding box
  64360. */
  64361. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64362. /**
  64363. * Tests if the bounding box intersects with a bounding sphere
  64364. * @param sphere defines the sphere to test
  64365. * @returns true if there is an intersection
  64366. */
  64367. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64368. /**
  64369. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64370. * @param min defines the min vector to use
  64371. * @param max defines the max vector to use
  64372. * @returns true if there is an intersection
  64373. */
  64374. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64375. /**
  64376. * Tests if two bounding boxes are intersections
  64377. * @param box0 defines the first box to test
  64378. * @param box1 defines the second box to test
  64379. * @returns true if there is an intersection
  64380. */
  64381. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64382. /**
  64383. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64384. * @param minPoint defines the minimum vector of the bounding box
  64385. * @param maxPoint defines the maximum vector of the bounding box
  64386. * @param sphereCenter defines the sphere center
  64387. * @param sphereRadius defines the sphere radius
  64388. * @returns true if there is an intersection
  64389. */
  64390. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64391. /**
  64392. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64393. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64394. * @param frustumPlanes defines the frustum planes to test
  64395. * @return true if there is an inclusion
  64396. */
  64397. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64398. /**
  64399. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64400. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64401. * @param frustumPlanes defines the frustum planes to test
  64402. * @return true if there is an intersection
  64403. */
  64404. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64405. }
  64406. }
  64407. declare module BABYLON {
  64408. /** @hidden */
  64409. export class Collider {
  64410. /** Define if a collision was found */
  64411. collisionFound: boolean;
  64412. /**
  64413. * Define last intersection point in local space
  64414. */
  64415. intersectionPoint: Vector3;
  64416. /**
  64417. * Define last collided mesh
  64418. */
  64419. collidedMesh: Nullable<AbstractMesh>;
  64420. private _collisionPoint;
  64421. private _planeIntersectionPoint;
  64422. private _tempVector;
  64423. private _tempVector2;
  64424. private _tempVector3;
  64425. private _tempVector4;
  64426. private _edge;
  64427. private _baseToVertex;
  64428. private _destinationPoint;
  64429. private _slidePlaneNormal;
  64430. private _displacementVector;
  64431. /** @hidden */
  64432. _radius: Vector3;
  64433. /** @hidden */
  64434. _retry: number;
  64435. private _velocity;
  64436. private _basePoint;
  64437. private _epsilon;
  64438. /** @hidden */
  64439. _velocityWorldLength: number;
  64440. /** @hidden */
  64441. _basePointWorld: Vector3;
  64442. private _velocityWorld;
  64443. private _normalizedVelocity;
  64444. /** @hidden */
  64445. _initialVelocity: Vector3;
  64446. /** @hidden */
  64447. _initialPosition: Vector3;
  64448. private _nearestDistance;
  64449. private _collisionMask;
  64450. collisionMask: number;
  64451. /**
  64452. * Gets the plane normal used to compute the sliding response (in local space)
  64453. */
  64454. readonly slidePlaneNormal: Vector3;
  64455. /** @hidden */
  64456. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64457. /** @hidden */
  64458. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64459. /** @hidden */
  64460. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64461. /** @hidden */
  64462. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64463. /** @hidden */
  64464. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64465. /** @hidden */
  64466. _getResponse(pos: Vector3, vel: Vector3): void;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /**
  64471. * Interface for cullable objects
  64472. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64473. */
  64474. export interface ICullable {
  64475. /**
  64476. * Checks if the object or part of the object is in the frustum
  64477. * @param frustumPlanes Camera near/planes
  64478. * @returns true if the object is in frustum otherwise false
  64479. */
  64480. isInFrustum(frustumPlanes: Plane[]): boolean;
  64481. /**
  64482. * Checks if a cullable object (mesh...) is in the camera frustum
  64483. * Unlike isInFrustum this cheks the full bounding box
  64484. * @param frustumPlanes Camera near/planes
  64485. * @returns true if the object is in frustum otherwise false
  64486. */
  64487. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64488. }
  64489. /**
  64490. * Info for a bounding data of a mesh
  64491. */
  64492. export class BoundingInfo implements ICullable {
  64493. /**
  64494. * Bounding box for the mesh
  64495. */
  64496. readonly boundingBox: BoundingBox;
  64497. /**
  64498. * Bounding sphere for the mesh
  64499. */
  64500. readonly boundingSphere: BoundingSphere;
  64501. private _isLocked;
  64502. private static readonly TmpVector3;
  64503. /**
  64504. * Constructs bounding info
  64505. * @param minimum min vector of the bounding box/sphere
  64506. * @param maximum max vector of the bounding box/sphere
  64507. * @param worldMatrix defines the new world matrix
  64508. */
  64509. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64510. /**
  64511. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64512. * @param min defines the new minimum vector (in local space)
  64513. * @param max defines the new maximum vector (in local space)
  64514. * @param worldMatrix defines the new world matrix
  64515. */
  64516. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64517. /**
  64518. * min vector of the bounding box/sphere
  64519. */
  64520. readonly minimum: Vector3;
  64521. /**
  64522. * max vector of the bounding box/sphere
  64523. */
  64524. readonly maximum: Vector3;
  64525. /**
  64526. * If the info is locked and won't be updated to avoid perf overhead
  64527. */
  64528. isLocked: boolean;
  64529. /**
  64530. * Updates the bounding sphere and box
  64531. * @param world world matrix to be used to update
  64532. */
  64533. update(world: DeepImmutable<Matrix>): void;
  64534. /**
  64535. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64536. * @param center New center of the bounding info
  64537. * @param extend New extend of the bounding info
  64538. * @returns the current bounding info
  64539. */
  64540. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64541. /**
  64542. * Scale the current bounding info by applying a scale factor
  64543. * @param factor defines the scale factor to apply
  64544. * @returns the current bounding info
  64545. */
  64546. scale(factor: number): BoundingInfo;
  64547. /**
  64548. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64549. * @param frustumPlanes defines the frustum to test
  64550. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64551. * @returns true if the bounding info is in the frustum planes
  64552. */
  64553. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64554. /**
  64555. * Gets the world distance between the min and max points of the bounding box
  64556. */
  64557. readonly diagonalLength: number;
  64558. /**
  64559. * Checks if a cullable object (mesh...) is in the camera frustum
  64560. * Unlike isInFrustum this cheks the full bounding box
  64561. * @param frustumPlanes Camera near/planes
  64562. * @returns true if the object is in frustum otherwise false
  64563. */
  64564. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64565. /** @hidden */
  64566. _checkCollision(collider: Collider): boolean;
  64567. /**
  64568. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64569. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64570. * @param point the point to check intersection with
  64571. * @returns if the point intersects
  64572. */
  64573. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64574. /**
  64575. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64576. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64577. * @param boundingInfo the bounding info to check intersection with
  64578. * @param precise if the intersection should be done using OBB
  64579. * @returns if the bounding info intersects
  64580. */
  64581. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64582. }
  64583. }
  64584. declare module BABYLON {
  64585. /**
  64586. * Defines an array and its length.
  64587. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64588. */
  64589. export interface ISmartArrayLike<T> {
  64590. /**
  64591. * The data of the array.
  64592. */
  64593. data: Array<T>;
  64594. /**
  64595. * The active length of the array.
  64596. */
  64597. length: number;
  64598. }
  64599. /**
  64600. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64601. */
  64602. export class SmartArray<T> implements ISmartArrayLike<T> {
  64603. /**
  64604. * The full set of data from the array.
  64605. */
  64606. data: Array<T>;
  64607. /**
  64608. * The active length of the array.
  64609. */
  64610. length: number;
  64611. protected _id: number;
  64612. /**
  64613. * Instantiates a Smart Array.
  64614. * @param capacity defines the default capacity of the array.
  64615. */
  64616. constructor(capacity: number);
  64617. /**
  64618. * Pushes a value at the end of the active data.
  64619. * @param value defines the object to push in the array.
  64620. */
  64621. push(value: T): void;
  64622. /**
  64623. * Iterates over the active data and apply the lambda to them.
  64624. * @param func defines the action to apply on each value.
  64625. */
  64626. forEach(func: (content: T) => void): void;
  64627. /**
  64628. * Sorts the full sets of data.
  64629. * @param compareFn defines the comparison function to apply.
  64630. */
  64631. sort(compareFn: (a: T, b: T) => number): void;
  64632. /**
  64633. * Resets the active data to an empty array.
  64634. */
  64635. reset(): void;
  64636. /**
  64637. * Releases all the data from the array as well as the array.
  64638. */
  64639. dispose(): void;
  64640. /**
  64641. * Concats the active data with a given array.
  64642. * @param array defines the data to concatenate with.
  64643. */
  64644. concat(array: any): void;
  64645. /**
  64646. * Returns the position of a value in the active data.
  64647. * @param value defines the value to find the index for
  64648. * @returns the index if found in the active data otherwise -1
  64649. */
  64650. indexOf(value: T): number;
  64651. /**
  64652. * Returns whether an element is part of the active data.
  64653. * @param value defines the value to look for
  64654. * @returns true if found in the active data otherwise false
  64655. */
  64656. contains(value: T): boolean;
  64657. private static _GlobalId;
  64658. }
  64659. /**
  64660. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64661. * The data in this array can only be present once
  64662. */
  64663. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64664. private _duplicateId;
  64665. /**
  64666. * Pushes a value at the end of the active data.
  64667. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64668. * @param value defines the object to push in the array.
  64669. */
  64670. push(value: T): void;
  64671. /**
  64672. * Pushes a value at the end of the active data.
  64673. * If the data is already present, it won t be added again
  64674. * @param value defines the object to push in the array.
  64675. * @returns true if added false if it was already present
  64676. */
  64677. pushNoDuplicate(value: T): boolean;
  64678. /**
  64679. * Resets the active data to an empty array.
  64680. */
  64681. reset(): void;
  64682. /**
  64683. * Concats the active data with a given array.
  64684. * This ensures no dupplicate will be present in the result.
  64685. * @param array defines the data to concatenate with.
  64686. */
  64687. concatWithNoDuplicate(array: any): void;
  64688. }
  64689. }
  64690. declare module BABYLON {
  64691. /**
  64692. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64693. * separate meshes. This can be use to improve performances.
  64694. * @see http://doc.babylonjs.com/how_to/multi_materials
  64695. */
  64696. export class MultiMaterial extends Material {
  64697. private _subMaterials;
  64698. /**
  64699. * Gets or Sets the list of Materials used within the multi material.
  64700. * They need to be ordered according to the submeshes order in the associated mesh
  64701. */
  64702. subMaterials: Nullable<Material>[];
  64703. /**
  64704. * Function used to align with Node.getChildren()
  64705. * @returns the list of Materials used within the multi material
  64706. */
  64707. getChildren(): Nullable<Material>[];
  64708. /**
  64709. * Instantiates a new Multi Material
  64710. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64711. * separate meshes. This can be use to improve performances.
  64712. * @see http://doc.babylonjs.com/how_to/multi_materials
  64713. * @param name Define the name in the scene
  64714. * @param scene Define the scene the material belongs to
  64715. */
  64716. constructor(name: string, scene: Scene);
  64717. private _hookArray;
  64718. /**
  64719. * Get one of the submaterial by its index in the submaterials array
  64720. * @param index The index to look the sub material at
  64721. * @returns The Material if the index has been defined
  64722. */
  64723. getSubMaterial(index: number): Nullable<Material>;
  64724. /**
  64725. * Get the list of active textures for the whole sub materials list.
  64726. * @returns All the textures that will be used during the rendering
  64727. */
  64728. getActiveTextures(): BaseTexture[];
  64729. /**
  64730. * Gets the current class name of the material e.g. "MultiMaterial"
  64731. * Mainly use in serialization.
  64732. * @returns the class name
  64733. */
  64734. getClassName(): string;
  64735. /**
  64736. * Checks if the material is ready to render the requested sub mesh
  64737. * @param mesh Define the mesh the submesh belongs to
  64738. * @param subMesh Define the sub mesh to look readyness for
  64739. * @param useInstances Define whether or not the material is used with instances
  64740. * @returns true if ready, otherwise false
  64741. */
  64742. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64743. /**
  64744. * Clones the current material and its related sub materials
  64745. * @param name Define the name of the newly cloned material
  64746. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64747. * @returns the cloned material
  64748. */
  64749. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64750. /**
  64751. * Serializes the materials into a JSON representation.
  64752. * @returns the JSON representation
  64753. */
  64754. serialize(): any;
  64755. /**
  64756. * Dispose the material and release its associated resources
  64757. * @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)
  64758. * @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)
  64759. * @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)
  64760. */
  64761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64762. /**
  64763. * Creates a MultiMaterial from parsed MultiMaterial data.
  64764. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64765. * @param scene defines the hosting scene
  64766. * @returns a new MultiMaterial
  64767. */
  64768. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64769. }
  64770. }
  64771. declare module BABYLON {
  64772. /**
  64773. * Class used to represent data loading progression
  64774. */
  64775. export class SceneLoaderFlags {
  64776. private static _ForceFullSceneLoadingForIncremental;
  64777. private static _ShowLoadingScreen;
  64778. private static _CleanBoneMatrixWeights;
  64779. private static _loggingLevel;
  64780. /**
  64781. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64782. */
  64783. static ForceFullSceneLoadingForIncremental: boolean;
  64784. /**
  64785. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64786. */
  64787. static ShowLoadingScreen: boolean;
  64788. /**
  64789. * Defines the current logging level (while loading the scene)
  64790. * @ignorenaming
  64791. */
  64792. static loggingLevel: number;
  64793. /**
  64794. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64795. */
  64796. static CleanBoneMatrixWeights: boolean;
  64797. }
  64798. }
  64799. declare module BABYLON {
  64800. /**
  64801. * 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.
  64802. * @see https://doc.babylonjs.com/how_to/transformnode
  64803. */
  64804. export class TransformNode extends Node {
  64805. /**
  64806. * Object will not rotate to face the camera
  64807. */
  64808. static BILLBOARDMODE_NONE: number;
  64809. /**
  64810. * Object will rotate to face the camera but only on the x axis
  64811. */
  64812. static BILLBOARDMODE_X: number;
  64813. /**
  64814. * Object will rotate to face the camera but only on the y axis
  64815. */
  64816. static BILLBOARDMODE_Y: number;
  64817. /**
  64818. * Object will rotate to face the camera but only on the z axis
  64819. */
  64820. static BILLBOARDMODE_Z: number;
  64821. /**
  64822. * Object will rotate to face the camera
  64823. */
  64824. static BILLBOARDMODE_ALL: number;
  64825. private _forward;
  64826. private _forwardInverted;
  64827. private _up;
  64828. private _right;
  64829. private _rightInverted;
  64830. private _position;
  64831. private _rotation;
  64832. private _rotationQuaternion;
  64833. protected _scaling: Vector3;
  64834. protected _isDirty: boolean;
  64835. private _transformToBoneReferal;
  64836. /**
  64837. * Set the billboard mode. Default is 0.
  64838. *
  64839. * | Value | Type | Description |
  64840. * | --- | --- | --- |
  64841. * | 0 | BILLBOARDMODE_NONE | |
  64842. * | 1 | BILLBOARDMODE_X | |
  64843. * | 2 | BILLBOARDMODE_Y | |
  64844. * | 4 | BILLBOARDMODE_Z | |
  64845. * | 7 | BILLBOARDMODE_ALL | |
  64846. *
  64847. */
  64848. billboardMode: number;
  64849. /**
  64850. * 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
  64851. */
  64852. scalingDeterminant: number;
  64853. /**
  64854. * Sets the distance of the object to max, often used by skybox
  64855. */
  64856. infiniteDistance: boolean;
  64857. /**
  64858. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64859. * By default the system will update normals to compensate
  64860. */
  64861. ignoreNonUniformScaling: boolean;
  64862. /** @hidden */
  64863. _poseMatrix: Matrix;
  64864. /** @hidden */
  64865. _localMatrix: Matrix;
  64866. private _absolutePosition;
  64867. private _pivotMatrix;
  64868. private _pivotMatrixInverse;
  64869. protected _postMultiplyPivotMatrix: boolean;
  64870. protected _isWorldMatrixFrozen: boolean;
  64871. /** @hidden */
  64872. _indexInSceneTransformNodesArray: number;
  64873. /**
  64874. * An event triggered after the world matrix is updated
  64875. */
  64876. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64877. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64878. /**
  64879. * Gets a string identifying the name of the class
  64880. * @returns "TransformNode" string
  64881. */
  64882. getClassName(): string;
  64883. /**
  64884. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64885. */
  64886. position: Vector3;
  64887. /**
  64888. * 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)).
  64889. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64890. */
  64891. rotation: Vector3;
  64892. /**
  64893. * 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)).
  64894. */
  64895. scaling: Vector3;
  64896. /**
  64897. * 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).
  64898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64899. */
  64900. rotationQuaternion: Nullable<Quaternion>;
  64901. /**
  64902. * The forward direction of that transform in world space.
  64903. */
  64904. readonly forward: Vector3;
  64905. /**
  64906. * The up direction of that transform in world space.
  64907. */
  64908. readonly up: Vector3;
  64909. /**
  64910. * The right direction of that transform in world space.
  64911. */
  64912. readonly right: Vector3;
  64913. /**
  64914. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64915. * @param matrix the matrix to copy the pose from
  64916. * @returns this TransformNode.
  64917. */
  64918. updatePoseMatrix(matrix: Matrix): TransformNode;
  64919. /**
  64920. * Returns the mesh Pose matrix.
  64921. * @returns the pose matrix
  64922. */
  64923. getPoseMatrix(): Matrix;
  64924. /** @hidden */
  64925. _isSynchronized(): boolean;
  64926. /** @hidden */
  64927. _initCache(): void;
  64928. /**
  64929. * Flag the transform node as dirty (Forcing it to update everything)
  64930. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64931. * @returns this transform node
  64932. */
  64933. markAsDirty(property: string): TransformNode;
  64934. /**
  64935. * Returns the current mesh absolute position.
  64936. * Returns a Vector3.
  64937. */
  64938. readonly absolutePosition: Vector3;
  64939. /**
  64940. * Sets a new matrix to apply before all other transformation
  64941. * @param matrix defines the transform matrix
  64942. * @returns the current TransformNode
  64943. */
  64944. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64945. /**
  64946. * Sets a new pivot matrix to the current node
  64947. * @param matrix defines the new pivot matrix to use
  64948. * @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
  64949. * @returns the current TransformNode
  64950. */
  64951. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64952. /**
  64953. * Returns the mesh pivot matrix.
  64954. * Default : Identity.
  64955. * @returns the matrix
  64956. */
  64957. getPivotMatrix(): Matrix;
  64958. /**
  64959. * Prevents the World matrix to be computed any longer.
  64960. * @returns the TransformNode.
  64961. */
  64962. freezeWorldMatrix(): TransformNode;
  64963. /**
  64964. * Allows back the World matrix computation.
  64965. * @returns the TransformNode.
  64966. */
  64967. unfreezeWorldMatrix(): this;
  64968. /**
  64969. * True if the World matrix has been frozen.
  64970. */
  64971. readonly isWorldMatrixFrozen: boolean;
  64972. /**
  64973. * Retuns the mesh absolute position in the World.
  64974. * @returns a Vector3.
  64975. */
  64976. getAbsolutePosition(): Vector3;
  64977. /**
  64978. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64979. * @param absolutePosition the absolute position to set
  64980. * @returns the TransformNode.
  64981. */
  64982. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64983. /**
  64984. * Sets the mesh position in its local space.
  64985. * @param vector3 the position to set in localspace
  64986. * @returns the TransformNode.
  64987. */
  64988. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64989. /**
  64990. * Returns the mesh position in the local space from the current World matrix values.
  64991. * @returns a new Vector3.
  64992. */
  64993. getPositionExpressedInLocalSpace(): Vector3;
  64994. /**
  64995. * Translates the mesh along the passed Vector3 in its local space.
  64996. * @param vector3 the distance to translate in localspace
  64997. * @returns the TransformNode.
  64998. */
  64999. locallyTranslate(vector3: Vector3): TransformNode;
  65000. private static _lookAtVectorCache;
  65001. /**
  65002. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65003. * @param targetPoint the position (must be in same space as current mesh) to look at
  65004. * @param yawCor optional yaw (y-axis) correction in radians
  65005. * @param pitchCor optional pitch (x-axis) correction in radians
  65006. * @param rollCor optional roll (z-axis) correction in radians
  65007. * @param space the choosen space of the target
  65008. * @returns the TransformNode.
  65009. */
  65010. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65011. /**
  65012. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65013. * This Vector3 is expressed in the World space.
  65014. * @param localAxis axis to rotate
  65015. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65016. */
  65017. getDirection(localAxis: Vector3): Vector3;
  65018. /**
  65019. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65020. * localAxis is expressed in the mesh local space.
  65021. * result is computed in the Wordl space from the mesh World matrix.
  65022. * @param localAxis axis to rotate
  65023. * @param result the resulting transformnode
  65024. * @returns this TransformNode.
  65025. */
  65026. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65027. /**
  65028. * Sets this transform node rotation to the given local axis.
  65029. * @param localAxis the axis in local space
  65030. * @param yawCor optional yaw (y-axis) correction in radians
  65031. * @param pitchCor optional pitch (x-axis) correction in radians
  65032. * @param rollCor optional roll (z-axis) correction in radians
  65033. * @returns this TransformNode
  65034. */
  65035. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65036. /**
  65037. * Sets a new pivot point to the current node
  65038. * @param point defines the new pivot point to use
  65039. * @param space defines if the point is in world or local space (local by default)
  65040. * @returns the current TransformNode
  65041. */
  65042. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65043. /**
  65044. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65045. * @returns the pivot point
  65046. */
  65047. getPivotPoint(): Vector3;
  65048. /**
  65049. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65050. * @param result the vector3 to store the result
  65051. * @returns this TransformNode.
  65052. */
  65053. getPivotPointToRef(result: Vector3): TransformNode;
  65054. /**
  65055. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65056. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65057. */
  65058. getAbsolutePivotPoint(): Vector3;
  65059. /**
  65060. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65061. * @param result vector3 to store the result
  65062. * @returns this TransformNode.
  65063. */
  65064. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65065. /**
  65066. * Defines the passed node as the parent of the current node.
  65067. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65068. * @param node the node ot set as the parent
  65069. * @returns this TransformNode.
  65070. */
  65071. setParent(node: Nullable<Node>): TransformNode;
  65072. private _nonUniformScaling;
  65073. /**
  65074. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65075. */
  65076. readonly nonUniformScaling: boolean;
  65077. /** @hidden */
  65078. _updateNonUniformScalingState(value: boolean): boolean;
  65079. /**
  65080. * Attach the current TransformNode to another TransformNode associated with a bone
  65081. * @param bone Bone affecting the TransformNode
  65082. * @param affectedTransformNode TransformNode associated with the bone
  65083. * @returns this object
  65084. */
  65085. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65086. /**
  65087. * Detach the transform node if its associated with a bone
  65088. * @returns this object
  65089. */
  65090. detachFromBone(): TransformNode;
  65091. private static _rotationAxisCache;
  65092. /**
  65093. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65094. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65095. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65096. * The passed axis is also normalized.
  65097. * @param axis the axis to rotate around
  65098. * @param amount the amount to rotate in radians
  65099. * @param space Space to rotate in (Default: local)
  65100. * @returns the TransformNode.
  65101. */
  65102. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65103. /**
  65104. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65105. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65106. * The passed axis is also normalized. .
  65107. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65108. * @param point the point to rotate around
  65109. * @param axis the axis to rotate around
  65110. * @param amount the amount to rotate in radians
  65111. * @returns the TransformNode
  65112. */
  65113. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65114. /**
  65115. * Translates the mesh along the axis vector for the passed distance in the given space.
  65116. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65117. * @param axis the axis to translate in
  65118. * @param distance the distance to translate
  65119. * @param space Space to rotate in (Default: local)
  65120. * @returns the TransformNode.
  65121. */
  65122. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65123. /**
  65124. * Adds a rotation step to the mesh current rotation.
  65125. * x, y, z are Euler angles expressed in radians.
  65126. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65127. * This means this rotation is made in the mesh local space only.
  65128. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65129. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65130. * ```javascript
  65131. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65132. * ```
  65133. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65134. * 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.
  65135. * @param x Rotation to add
  65136. * @param y Rotation to add
  65137. * @param z Rotation to add
  65138. * @returns the TransformNode.
  65139. */
  65140. addRotation(x: number, y: number, z: number): TransformNode;
  65141. /**
  65142. * Computes the world matrix of the node
  65143. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65144. * @returns the world matrix
  65145. */
  65146. computeWorldMatrix(force?: boolean): Matrix;
  65147. protected _afterComputeWorldMatrix(): void;
  65148. /**
  65149. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65150. * @param func callback function to add
  65151. *
  65152. * @returns the TransformNode.
  65153. */
  65154. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65155. /**
  65156. * Removes a registered callback function.
  65157. * @param func callback function to remove
  65158. * @returns the TransformNode.
  65159. */
  65160. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65161. /**
  65162. * Gets the position of the current mesh in camera space
  65163. * @param camera defines the camera to use
  65164. * @returns a position
  65165. */
  65166. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65167. /**
  65168. * Returns the distance from the mesh to the active camera
  65169. * @param camera defines the camera to use
  65170. * @returns the distance
  65171. */
  65172. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65173. /**
  65174. * Clone the current transform node
  65175. * @param name Name of the new clone
  65176. * @param newParent New parent for the clone
  65177. * @param doNotCloneChildren Do not clone children hierarchy
  65178. * @returns the new transform node
  65179. */
  65180. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65181. /**
  65182. * Serializes the objects information.
  65183. * @param currentSerializationObject defines the object to serialize in
  65184. * @returns the serialized object
  65185. */
  65186. serialize(currentSerializationObject?: any): any;
  65187. /**
  65188. * Returns a new TransformNode object parsed from the source provided.
  65189. * @param parsedTransformNode is the source.
  65190. * @param scene the scne the object belongs to
  65191. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65192. * @returns a new TransformNode object parsed from the source provided.
  65193. */
  65194. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65195. /**
  65196. * Get all child-transformNodes of this node
  65197. * @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
  65198. * @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
  65199. * @returns an array of TransformNode
  65200. */
  65201. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65202. /**
  65203. * Releases resources associated with this transform node.
  65204. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65205. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65206. */
  65207. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65208. }
  65209. }
  65210. declare module BABYLON {
  65211. /**
  65212. * Class used to override all child animations of a given target
  65213. */
  65214. export class AnimationPropertiesOverride {
  65215. /**
  65216. * Gets or sets a value indicating if animation blending must be used
  65217. */
  65218. enableBlending: boolean;
  65219. /**
  65220. * Gets or sets the blending speed to use when enableBlending is true
  65221. */
  65222. blendingSpeed: number;
  65223. /**
  65224. * Gets or sets the default loop mode to use
  65225. */
  65226. loopMode: number;
  65227. }
  65228. }
  65229. declare module BABYLON {
  65230. /**
  65231. * Class used to store bone information
  65232. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65233. */
  65234. export class Bone extends Node {
  65235. /**
  65236. * defines the bone name
  65237. */
  65238. name: string;
  65239. private static _tmpVecs;
  65240. private static _tmpQuat;
  65241. private static _tmpMats;
  65242. /**
  65243. * Gets the list of child bones
  65244. */
  65245. children: Bone[];
  65246. /** Gets the animations associated with this bone */
  65247. animations: Animation[];
  65248. /**
  65249. * Gets or sets bone length
  65250. */
  65251. length: number;
  65252. /**
  65253. * @hidden Internal only
  65254. * Set this value to map this bone to a different index in the transform matrices
  65255. * Set this value to -1 to exclude the bone from the transform matrices
  65256. */
  65257. _index: Nullable<number>;
  65258. private _skeleton;
  65259. private _localMatrix;
  65260. private _restPose;
  65261. private _baseMatrix;
  65262. private _absoluteTransform;
  65263. private _invertedAbsoluteTransform;
  65264. private _parent;
  65265. private _scalingDeterminant;
  65266. private _worldTransform;
  65267. private _localScaling;
  65268. private _localRotation;
  65269. private _localPosition;
  65270. private _needToDecompose;
  65271. private _needToCompose;
  65272. /** @hidden */
  65273. _linkedTransformNode: Nullable<TransformNode>;
  65274. /** @hidden */
  65275. /** @hidden */
  65276. _matrix: Matrix;
  65277. /**
  65278. * Create a new bone
  65279. * @param name defines the bone name
  65280. * @param skeleton defines the parent skeleton
  65281. * @param parentBone defines the parent (can be null if the bone is the root)
  65282. * @param localMatrix defines the local matrix
  65283. * @param restPose defines the rest pose matrix
  65284. * @param baseMatrix defines the base matrix
  65285. * @param index defines index of the bone in the hiearchy
  65286. */
  65287. constructor(
  65288. /**
  65289. * defines the bone name
  65290. */
  65291. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65292. /**
  65293. * Gets the current object class name.
  65294. * @return the class name
  65295. */
  65296. getClassName(): string;
  65297. /**
  65298. * Gets the parent skeleton
  65299. * @returns a skeleton
  65300. */
  65301. getSkeleton(): Skeleton;
  65302. /**
  65303. * Gets parent bone
  65304. * @returns a bone or null if the bone is the root of the bone hierarchy
  65305. */
  65306. getParent(): Nullable<Bone>;
  65307. /**
  65308. * Returns an array containing the root bones
  65309. * @returns an array containing the root bones
  65310. */
  65311. getChildren(): Array<Bone>;
  65312. /**
  65313. * Sets the parent bone
  65314. * @param parent defines the parent (can be null if the bone is the root)
  65315. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65316. */
  65317. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65318. /**
  65319. * Gets the local matrix
  65320. * @returns a matrix
  65321. */
  65322. getLocalMatrix(): Matrix;
  65323. /**
  65324. * Gets the base matrix (initial matrix which remains unchanged)
  65325. * @returns a matrix
  65326. */
  65327. getBaseMatrix(): Matrix;
  65328. /**
  65329. * Gets the rest pose matrix
  65330. * @returns a matrix
  65331. */
  65332. getRestPose(): Matrix;
  65333. /**
  65334. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65335. */
  65336. getWorldMatrix(): Matrix;
  65337. /**
  65338. * Sets the local matrix to rest pose matrix
  65339. */
  65340. returnToRest(): void;
  65341. /**
  65342. * Gets the inverse of the absolute transform matrix.
  65343. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65344. * @returns a matrix
  65345. */
  65346. getInvertedAbsoluteTransform(): Matrix;
  65347. /**
  65348. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65349. * @returns a matrix
  65350. */
  65351. getAbsoluteTransform(): Matrix;
  65352. /**
  65353. * Links with the given transform node.
  65354. * The local matrix of this bone is copied from the transform node every frame.
  65355. * @param transformNode defines the transform node to link to
  65356. */
  65357. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65358. /** Gets or sets current position (in local space) */
  65359. position: Vector3;
  65360. /** Gets or sets current rotation (in local space) */
  65361. rotation: Vector3;
  65362. /** Gets or sets current rotation quaternion (in local space) */
  65363. rotationQuaternion: Quaternion;
  65364. /** Gets or sets current scaling (in local space) */
  65365. scaling: Vector3;
  65366. /**
  65367. * Gets the animation properties override
  65368. */
  65369. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65370. private _decompose;
  65371. private _compose;
  65372. /**
  65373. * Update the base and local matrices
  65374. * @param matrix defines the new base or local matrix
  65375. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65376. * @param updateLocalMatrix defines if the local matrix should be updated
  65377. */
  65378. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65379. /** @hidden */
  65380. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65381. /**
  65382. * Flag the bone as dirty (Forcing it to update everything)
  65383. */
  65384. markAsDirty(): void;
  65385. private _markAsDirtyAndCompose;
  65386. private _markAsDirtyAndDecompose;
  65387. /**
  65388. * Translate the bone in local or world space
  65389. * @param vec The amount to translate the bone
  65390. * @param space The space that the translation is in
  65391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65392. */
  65393. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65394. /**
  65395. * Set the postion of the bone in local or world space
  65396. * @param position The position to set the bone
  65397. * @param space The space that the position is in
  65398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65399. */
  65400. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65401. /**
  65402. * Set the absolute position of the bone (world space)
  65403. * @param position The position to set the bone
  65404. * @param mesh The mesh that this bone is attached to
  65405. */
  65406. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65407. /**
  65408. * Scale the bone on the x, y and z axes (in local space)
  65409. * @param x The amount to scale the bone on the x axis
  65410. * @param y The amount to scale the bone on the y axis
  65411. * @param z The amount to scale the bone on the z axis
  65412. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65413. */
  65414. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65415. /**
  65416. * Set the bone scaling in local space
  65417. * @param scale defines the scaling vector
  65418. */
  65419. setScale(scale: Vector3): void;
  65420. /**
  65421. * Gets the current scaling in local space
  65422. * @returns the current scaling vector
  65423. */
  65424. getScale(): Vector3;
  65425. /**
  65426. * Gets the current scaling in local space and stores it in a target vector
  65427. * @param result defines the target vector
  65428. */
  65429. getScaleToRef(result: Vector3): void;
  65430. /**
  65431. * Set the yaw, pitch, and roll of the bone in local or world space
  65432. * @param yaw The rotation of the bone on the y axis
  65433. * @param pitch The rotation of the bone on the x axis
  65434. * @param roll The rotation of the bone on the z axis
  65435. * @param space The space that the axes of rotation are in
  65436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65437. */
  65438. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65439. /**
  65440. * Add a rotation to the bone on an axis in local or world space
  65441. * @param axis The axis to rotate the bone on
  65442. * @param amount The amount to rotate the bone
  65443. * @param space The space that the axis is in
  65444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65445. */
  65446. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65447. /**
  65448. * Set the rotation of the bone to a particular axis angle in local or world space
  65449. * @param axis The axis to rotate the bone on
  65450. * @param angle The angle that the bone should be rotated to
  65451. * @param space The space that the axis is in
  65452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65453. */
  65454. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65455. /**
  65456. * Set the euler rotation of the bone in local of world space
  65457. * @param rotation The euler rotation that the bone should be set to
  65458. * @param space The space that the rotation is in
  65459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65460. */
  65461. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65462. /**
  65463. * Set the quaternion rotation of the bone in local of world space
  65464. * @param quat The quaternion rotation that the bone should be set to
  65465. * @param space The space that the rotation is in
  65466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65467. */
  65468. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65469. /**
  65470. * Set the rotation matrix of the bone in local of world space
  65471. * @param rotMat The rotation matrix that the bone should be set to
  65472. * @param space The space that the rotation is in
  65473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65474. */
  65475. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65476. private _rotateWithMatrix;
  65477. private _getNegativeRotationToRef;
  65478. /**
  65479. * Get the position of the bone in local or world space
  65480. * @param space The space that the returned position is in
  65481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65482. * @returns The position of the bone
  65483. */
  65484. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65485. /**
  65486. * Copy the position of the bone to a vector3 in local or world space
  65487. * @param space The space that the returned position is in
  65488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65489. * @param result The vector3 to copy the position to
  65490. */
  65491. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65492. /**
  65493. * Get the absolute position of the bone (world space)
  65494. * @param mesh The mesh that this bone is attached to
  65495. * @returns The absolute position of the bone
  65496. */
  65497. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65498. /**
  65499. * Copy the absolute position of the bone (world space) to the result param
  65500. * @param mesh The mesh that this bone is attached to
  65501. * @param result The vector3 to copy the absolute position to
  65502. */
  65503. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65504. /**
  65505. * Compute the absolute transforms of this bone and its children
  65506. */
  65507. computeAbsoluteTransforms(): void;
  65508. /**
  65509. * Get the world direction from an axis that is in the local space of the bone
  65510. * @param localAxis The local direction that is used to compute the world direction
  65511. * @param mesh The mesh that this bone is attached to
  65512. * @returns The world direction
  65513. */
  65514. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65515. /**
  65516. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65517. * @param localAxis The local direction that is used to compute the world direction
  65518. * @param mesh The mesh that this bone is attached to
  65519. * @param result The vector3 that the world direction will be copied to
  65520. */
  65521. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65522. /**
  65523. * Get the euler rotation of the bone in local or world space
  65524. * @param space The space that the rotation should be in
  65525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65526. * @returns The euler rotation
  65527. */
  65528. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65529. /**
  65530. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65531. * @param space The space that the rotation should be in
  65532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65533. * @param result The vector3 that the rotation should be copied to
  65534. */
  65535. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65536. /**
  65537. * Get the quaternion rotation of the bone in either local or world space
  65538. * @param space The space that the rotation should be in
  65539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65540. * @returns The quaternion rotation
  65541. */
  65542. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65543. /**
  65544. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65545. * @param space The space that the rotation should be in
  65546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65547. * @param result The quaternion that the rotation should be copied to
  65548. */
  65549. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65550. /**
  65551. * Get the rotation matrix of the bone in local or world space
  65552. * @param space The space that the rotation should be in
  65553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65554. * @returns The rotation matrix
  65555. */
  65556. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65557. /**
  65558. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65559. * @param space The space that the rotation should be in
  65560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65561. * @param result The quaternion that the rotation should be copied to
  65562. */
  65563. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65564. /**
  65565. * Get the world position of a point that is in the local space of the bone
  65566. * @param position The local position
  65567. * @param mesh The mesh that this bone is attached to
  65568. * @returns The world position
  65569. */
  65570. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65571. /**
  65572. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65573. * @param position The local position
  65574. * @param mesh The mesh that this bone is attached to
  65575. * @param result The vector3 that the world position should be copied to
  65576. */
  65577. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65578. /**
  65579. * Get the local position of a point that is in world space
  65580. * @param position The world position
  65581. * @param mesh The mesh that this bone is attached to
  65582. * @returns The local position
  65583. */
  65584. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65585. /**
  65586. * Get the local position of a point that is in world space and copy it to the result param
  65587. * @param position The world position
  65588. * @param mesh The mesh that this bone is attached to
  65589. * @param result The vector3 that the local position should be copied to
  65590. */
  65591. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65592. }
  65593. }
  65594. declare module BABYLON {
  65595. /**
  65596. * Class for creating a cube texture
  65597. */
  65598. export class CubeTexture extends BaseTexture {
  65599. private _delayedOnLoad;
  65600. /**
  65601. * The url of the texture
  65602. */
  65603. url: string;
  65604. /**
  65605. * Gets or sets the center of the bounding box associated with the cube texture.
  65606. * It must define where the camera used to render the texture was set
  65607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65608. */
  65609. boundingBoxPosition: Vector3;
  65610. private _boundingBoxSize;
  65611. /**
  65612. * Gets or sets the size of the bounding box associated with the cube texture
  65613. * When defined, the cubemap will switch to local mode
  65614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65615. * @example https://www.babylonjs-playground.com/#RNASML
  65616. */
  65617. /**
  65618. * Returns the bounding box size
  65619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65620. */
  65621. boundingBoxSize: Vector3;
  65622. protected _rotationY: number;
  65623. /**
  65624. * Sets texture matrix rotation angle around Y axis in radians.
  65625. */
  65626. /**
  65627. * Gets texture matrix rotation angle around Y axis radians.
  65628. */
  65629. rotationY: number;
  65630. /**
  65631. * Are mip maps generated for this texture or not.
  65632. */
  65633. readonly noMipmap: boolean;
  65634. private _noMipmap;
  65635. private _files;
  65636. private _extensions;
  65637. private _textureMatrix;
  65638. private _format;
  65639. private _createPolynomials;
  65640. /** @hidden */
  65641. _prefiltered: boolean;
  65642. /**
  65643. * Creates a cube texture from an array of image urls
  65644. * @param files defines an array of image urls
  65645. * @param scene defines the hosting scene
  65646. * @param noMipmap specifies if mip maps are not used
  65647. * @returns a cube texture
  65648. */
  65649. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65650. /**
  65651. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65652. * @param url defines the url of the prefiltered texture
  65653. * @param scene defines the scene the texture is attached to
  65654. * @param forcedExtension defines the extension of the file if different from the url
  65655. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65656. * @return the prefiltered texture
  65657. */
  65658. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65659. /**
  65660. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65661. * as prefiltered data.
  65662. * @param rootUrl defines the url of the texture or the root name of the six images
  65663. * @param scene defines the scene the texture is attached to
  65664. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65665. * @param noMipmap defines if mipmaps should be created or not
  65666. * @param files defines the six files to load for the different faces
  65667. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65668. * @param onError defines a callback triggered in case of error during load
  65669. * @param format defines the internal format to use for the texture once loaded
  65670. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65671. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65672. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65673. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65674. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65675. * @return the cube texture
  65676. */
  65677. 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);
  65678. /**
  65679. * Get the current class name of the texture useful for serialization or dynamic coding.
  65680. * @returns "CubeTexture"
  65681. */
  65682. getClassName(): string;
  65683. /**
  65684. * Update the url (and optional buffer) of this texture if url was null during construction.
  65685. * @param url the url of the texture
  65686. * @param forcedExtension defines the extension to use
  65687. * @param onLoad callback called when the texture is loaded (defaults to null)
  65688. */
  65689. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65690. /**
  65691. * Delays loading of the cube texture
  65692. * @param forcedExtension defines the extension to use
  65693. */
  65694. delayLoad(forcedExtension?: string): void;
  65695. /**
  65696. * Returns the reflection texture matrix
  65697. * @returns the reflection texture matrix
  65698. */
  65699. getReflectionTextureMatrix(): Matrix;
  65700. /**
  65701. * Sets the reflection texture matrix
  65702. * @param value Reflection texture matrix
  65703. */
  65704. setReflectionTextureMatrix(value: Matrix): void;
  65705. /**
  65706. * Parses text to create a cube texture
  65707. * @param parsedTexture define the serialized text to read from
  65708. * @param scene defines the hosting scene
  65709. * @param rootUrl defines the root url of the cube texture
  65710. * @returns a cube texture
  65711. */
  65712. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65713. /**
  65714. * Makes a clone, or deep copy, of the cube texture
  65715. * @returns a new cube texture
  65716. */
  65717. clone(): CubeTexture;
  65718. }
  65719. }
  65720. declare module BABYLON {
  65721. /** @hidden */
  65722. export var postprocessVertexShader: {
  65723. name: string;
  65724. shader: string;
  65725. };
  65726. }
  65727. declare module BABYLON {
  65728. /**
  65729. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65730. * This is the base of the follow, arc rotate cameras and Free camera
  65731. * @see http://doc.babylonjs.com/features/cameras
  65732. */
  65733. export class TargetCamera extends Camera {
  65734. private static _RigCamTransformMatrix;
  65735. private static _TargetTransformMatrix;
  65736. private static _TargetFocalPoint;
  65737. /**
  65738. * Define the current direction the camera is moving to
  65739. */
  65740. cameraDirection: Vector3;
  65741. /**
  65742. * Define the current rotation the camera is rotating to
  65743. */
  65744. cameraRotation: Vector2;
  65745. /**
  65746. * When set, the up vector of the camera will be updated by the rotation of the camera
  65747. */
  65748. updateUpVectorFromRotation: boolean;
  65749. private _tmpQuaternion;
  65750. /**
  65751. * Define the current rotation of the camera
  65752. */
  65753. rotation: Vector3;
  65754. /**
  65755. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65756. */
  65757. rotationQuaternion: Quaternion;
  65758. /**
  65759. * Define the current speed of the camera
  65760. */
  65761. speed: number;
  65762. /**
  65763. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65764. * around all axis.
  65765. */
  65766. noRotationConstraint: boolean;
  65767. /**
  65768. * Define the current target of the camera as an object or a position.
  65769. */
  65770. lockedTarget: any;
  65771. /** @hidden */
  65772. _currentTarget: Vector3;
  65773. /** @hidden */
  65774. _initialFocalDistance: number;
  65775. /** @hidden */
  65776. _viewMatrix: Matrix;
  65777. /** @hidden */
  65778. _camMatrix: Matrix;
  65779. /** @hidden */
  65780. _cameraTransformMatrix: Matrix;
  65781. /** @hidden */
  65782. _cameraRotationMatrix: Matrix;
  65783. /** @hidden */
  65784. _referencePoint: Vector3;
  65785. /** @hidden */
  65786. _transformedReferencePoint: Vector3;
  65787. protected _globalCurrentTarget: Vector3;
  65788. protected _globalCurrentUpVector: Vector3;
  65789. /** @hidden */
  65790. _reset: () => void;
  65791. private _defaultUp;
  65792. /**
  65793. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65794. * This is the base of the follow, arc rotate cameras and Free camera
  65795. * @see http://doc.babylonjs.com/features/cameras
  65796. * @param name Defines the name of the camera in the scene
  65797. * @param position Defines the start position of the camera in the scene
  65798. * @param scene Defines the scene the camera belongs to
  65799. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65800. */
  65801. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65802. /**
  65803. * Gets the position in front of the camera at a given distance.
  65804. * @param distance The distance from the camera we want the position to be
  65805. * @returns the position
  65806. */
  65807. getFrontPosition(distance: number): Vector3;
  65808. /** @hidden */
  65809. _getLockedTargetPosition(): Nullable<Vector3>;
  65810. private _storedPosition;
  65811. private _storedRotation;
  65812. private _storedRotationQuaternion;
  65813. /**
  65814. * Store current camera state of the camera (fov, position, rotation, etc..)
  65815. * @returns the camera
  65816. */
  65817. storeState(): Camera;
  65818. /**
  65819. * Restored camera state. You must call storeState() first
  65820. * @returns whether it was successful or not
  65821. * @hidden
  65822. */
  65823. _restoreStateValues(): boolean;
  65824. /** @hidden */
  65825. _initCache(): void;
  65826. /** @hidden */
  65827. _updateCache(ignoreParentClass?: boolean): void;
  65828. /** @hidden */
  65829. _isSynchronizedViewMatrix(): boolean;
  65830. /** @hidden */
  65831. _computeLocalCameraSpeed(): number;
  65832. /**
  65833. * Defines the target the camera should look at.
  65834. * This will automatically adapt alpha beta and radius to fit within the new target.
  65835. * @param target Defines the new target as a Vector or a mesh
  65836. */
  65837. setTarget(target: Vector3): void;
  65838. /**
  65839. * Return the current target position of the camera. This value is expressed in local space.
  65840. * @returns the target position
  65841. */
  65842. getTarget(): Vector3;
  65843. /** @hidden */
  65844. _decideIfNeedsToMove(): boolean;
  65845. /** @hidden */
  65846. _updatePosition(): void;
  65847. /** @hidden */
  65848. _checkInputs(): void;
  65849. protected _updateCameraRotationMatrix(): void;
  65850. /**
  65851. * 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)
  65852. * @returns the current camera
  65853. */
  65854. private _rotateUpVectorWithCameraRotationMatrix;
  65855. private _cachedRotationZ;
  65856. private _cachedQuaternionRotationZ;
  65857. /** @hidden */
  65858. _getViewMatrix(): Matrix;
  65859. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65860. /**
  65861. * @hidden
  65862. */
  65863. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65864. /**
  65865. * @hidden
  65866. */
  65867. _updateRigCameras(): void;
  65868. private _getRigCamPositionAndTarget;
  65869. /**
  65870. * Gets the current object class name.
  65871. * @return the class name
  65872. */
  65873. getClassName(): string;
  65874. }
  65875. }
  65876. declare module BABYLON {
  65877. /**
  65878. * @ignore
  65879. * This is a list of all the different input types that are available in the application.
  65880. * Fo instance: ArcRotateCameraGamepadInput...
  65881. */
  65882. export var CameraInputTypes: {};
  65883. /**
  65884. * This is the contract to implement in order to create a new input class.
  65885. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65886. */
  65887. export interface ICameraInput<TCamera extends Camera> {
  65888. /**
  65889. * Defines the camera the input is attached to.
  65890. */
  65891. camera: Nullable<TCamera>;
  65892. /**
  65893. * Gets the class name of the current intput.
  65894. * @returns the class name
  65895. */
  65896. getClassName(): string;
  65897. /**
  65898. * Get the friendly name associated with the input class.
  65899. * @returns the input friendly name
  65900. */
  65901. getSimpleName(): string;
  65902. /**
  65903. * Attach the input controls to a specific dom element to get the input from.
  65904. * @param element Defines the element the controls should be listened from
  65905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65906. */
  65907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65908. /**
  65909. * Detach the current controls from the specified dom element.
  65910. * @param element Defines the element to stop listening the inputs from
  65911. */
  65912. detachControl(element: Nullable<HTMLElement>): void;
  65913. /**
  65914. * Update the current camera state depending on the inputs that have been used this frame.
  65915. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65916. */
  65917. checkInputs?: () => void;
  65918. }
  65919. /**
  65920. * Represents a map of input types to input instance or input index to input instance.
  65921. */
  65922. export interface CameraInputsMap<TCamera extends Camera> {
  65923. /**
  65924. * Accessor to the input by input type.
  65925. */
  65926. [name: string]: ICameraInput<TCamera>;
  65927. /**
  65928. * Accessor to the input by input index.
  65929. */
  65930. [idx: number]: ICameraInput<TCamera>;
  65931. }
  65932. /**
  65933. * This represents the input manager used within a camera.
  65934. * It helps dealing with all the different kind of input attached to a camera.
  65935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65936. */
  65937. export class CameraInputsManager<TCamera extends Camera> {
  65938. /**
  65939. * Defines the list of inputs attahed to the camera.
  65940. */
  65941. attached: CameraInputsMap<TCamera>;
  65942. /**
  65943. * Defines the dom element the camera is collecting inputs from.
  65944. * This is null if the controls have not been attached.
  65945. */
  65946. attachedElement: Nullable<HTMLElement>;
  65947. /**
  65948. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65949. */
  65950. noPreventDefault: boolean;
  65951. /**
  65952. * Defined the camera the input manager belongs to.
  65953. */
  65954. camera: TCamera;
  65955. /**
  65956. * Update the current camera state depending on the inputs that have been used this frame.
  65957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65958. */
  65959. checkInputs: () => void;
  65960. /**
  65961. * Instantiate a new Camera Input Manager.
  65962. * @param camera Defines the camera the input manager blongs to
  65963. */
  65964. constructor(camera: TCamera);
  65965. /**
  65966. * Add an input method to a camera
  65967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65968. * @param input camera input method
  65969. */
  65970. add(input: ICameraInput<TCamera>): void;
  65971. /**
  65972. * Remove a specific input method from a camera
  65973. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65974. * @param inputToRemove camera input method
  65975. */
  65976. remove(inputToRemove: ICameraInput<TCamera>): void;
  65977. /**
  65978. * Remove a specific input type from a camera
  65979. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65980. * @param inputType the type of the input to remove
  65981. */
  65982. removeByType(inputType: string): void;
  65983. private _addCheckInputs;
  65984. /**
  65985. * Attach the input controls to the currently attached dom element to listen the events from.
  65986. * @param input Defines the input to attach
  65987. */
  65988. attachInput(input: ICameraInput<TCamera>): void;
  65989. /**
  65990. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65991. * @param element Defines the dom element to collect the events from
  65992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65993. */
  65994. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65995. /**
  65996. * Detach the current manager inputs controls from a specific dom element.
  65997. * @param element Defines the dom element to collect the events from
  65998. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65999. */
  66000. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66001. /**
  66002. * Rebuild the dynamic inputCheck function from the current list of
  66003. * defined inputs in the manager.
  66004. */
  66005. rebuildInputCheck(): void;
  66006. /**
  66007. * Remove all attached input methods from a camera
  66008. */
  66009. clear(): void;
  66010. /**
  66011. * Serialize the current input manager attached to a camera.
  66012. * This ensures than once parsed,
  66013. * the input associated to the camera will be identical to the current ones
  66014. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66015. */
  66016. serialize(serializedCamera: any): void;
  66017. /**
  66018. * Parses an input manager serialized JSON to restore the previous list of inputs
  66019. * and states associated to a camera.
  66020. * @param parsedCamera Defines the JSON to parse
  66021. */
  66022. parse(parsedCamera: any): void;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /**
  66027. * Gather the list of keyboard event types as constants.
  66028. */
  66029. export class KeyboardEventTypes {
  66030. /**
  66031. * The keydown event is fired when a key becomes active (pressed).
  66032. */
  66033. static readonly KEYDOWN: number;
  66034. /**
  66035. * The keyup event is fired when a key has been released.
  66036. */
  66037. static readonly KEYUP: number;
  66038. }
  66039. /**
  66040. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66041. */
  66042. export class KeyboardInfo {
  66043. /**
  66044. * Defines the type of event (KeyboardEventTypes)
  66045. */
  66046. type: number;
  66047. /**
  66048. * Defines the related dom event
  66049. */
  66050. event: KeyboardEvent;
  66051. /**
  66052. * Instantiates a new keyboard info.
  66053. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66054. * @param type Defines the type of event (KeyboardEventTypes)
  66055. * @param event Defines the related dom event
  66056. */
  66057. constructor(
  66058. /**
  66059. * Defines the type of event (KeyboardEventTypes)
  66060. */
  66061. type: number,
  66062. /**
  66063. * Defines the related dom event
  66064. */
  66065. event: KeyboardEvent);
  66066. }
  66067. /**
  66068. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66069. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66070. */
  66071. export class KeyboardInfoPre extends KeyboardInfo {
  66072. /**
  66073. * Defines the type of event (KeyboardEventTypes)
  66074. */
  66075. type: number;
  66076. /**
  66077. * Defines the related dom event
  66078. */
  66079. event: KeyboardEvent;
  66080. /**
  66081. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66082. */
  66083. skipOnPointerObservable: boolean;
  66084. /**
  66085. * Instantiates a new keyboard pre info.
  66086. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66087. * @param type Defines the type of event (KeyboardEventTypes)
  66088. * @param event Defines the related dom event
  66089. */
  66090. constructor(
  66091. /**
  66092. * Defines the type of event (KeyboardEventTypes)
  66093. */
  66094. type: number,
  66095. /**
  66096. * Defines the related dom event
  66097. */
  66098. event: KeyboardEvent);
  66099. }
  66100. }
  66101. declare module BABYLON {
  66102. /**
  66103. * Manage the keyboard inputs to control the movement of a free camera.
  66104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66105. */
  66106. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66107. /**
  66108. * Defines the camera the input is attached to.
  66109. */
  66110. camera: FreeCamera;
  66111. /**
  66112. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66113. */
  66114. keysUp: number[];
  66115. /**
  66116. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66117. */
  66118. keysDown: number[];
  66119. /**
  66120. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66121. */
  66122. keysLeft: number[];
  66123. /**
  66124. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66125. */
  66126. keysRight: number[];
  66127. private _keys;
  66128. private _onCanvasBlurObserver;
  66129. private _onKeyboardObserver;
  66130. private _engine;
  66131. private _scene;
  66132. /**
  66133. * Attach the input controls to a specific dom element to get the input from.
  66134. * @param element Defines the element the controls should be listened from
  66135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66136. */
  66137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66138. /**
  66139. * Detach the current controls from the specified dom element.
  66140. * @param element Defines the element to stop listening the inputs from
  66141. */
  66142. detachControl(element: Nullable<HTMLElement>): void;
  66143. /**
  66144. * Update the current camera state depending on the inputs that have been used this frame.
  66145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66146. */
  66147. checkInputs(): void;
  66148. /**
  66149. * Gets the class name of the current intput.
  66150. * @returns the class name
  66151. */
  66152. getClassName(): string;
  66153. /** @hidden */
  66154. _onLostFocus(): void;
  66155. /**
  66156. * Get the friendly name associated with the input class.
  66157. * @returns the input friendly name
  66158. */
  66159. getSimpleName(): string;
  66160. }
  66161. }
  66162. declare module BABYLON {
  66163. /**
  66164. * Interface describing all the common properties and methods a shadow light needs to implement.
  66165. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66166. * as well as binding the different shadow properties to the effects.
  66167. */
  66168. export interface IShadowLight extends Light {
  66169. /**
  66170. * The light id in the scene (used in scene.findLighById for instance)
  66171. */
  66172. id: string;
  66173. /**
  66174. * The position the shdow will be casted from.
  66175. */
  66176. position: Vector3;
  66177. /**
  66178. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66179. */
  66180. direction: Vector3;
  66181. /**
  66182. * The transformed position. Position of the light in world space taking parenting in account.
  66183. */
  66184. transformedPosition: Vector3;
  66185. /**
  66186. * The transformed direction. Direction of the light in world space taking parenting in account.
  66187. */
  66188. transformedDirection: Vector3;
  66189. /**
  66190. * The friendly name of the light in the scene.
  66191. */
  66192. name: string;
  66193. /**
  66194. * Defines the shadow projection clipping minimum z value.
  66195. */
  66196. shadowMinZ: number;
  66197. /**
  66198. * Defines the shadow projection clipping maximum z value.
  66199. */
  66200. shadowMaxZ: number;
  66201. /**
  66202. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66203. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66204. */
  66205. computeTransformedInformation(): boolean;
  66206. /**
  66207. * Gets the scene the light belongs to.
  66208. * @returns The scene
  66209. */
  66210. getScene(): Scene;
  66211. /**
  66212. * Callback defining a custom Projection Matrix Builder.
  66213. * This can be used to override the default projection matrix computation.
  66214. */
  66215. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66216. /**
  66217. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66218. * @param matrix The materix to updated with the projection information
  66219. * @param viewMatrix The transform matrix of the light
  66220. * @param renderList The list of mesh to render in the map
  66221. * @returns The current light
  66222. */
  66223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66224. /**
  66225. * Gets the current depth scale used in ESM.
  66226. * @returns The scale
  66227. */
  66228. getDepthScale(): number;
  66229. /**
  66230. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66231. * @returns true if a cube texture needs to be use
  66232. */
  66233. needCube(): boolean;
  66234. /**
  66235. * Detects if the projection matrix requires to be recomputed this frame.
  66236. * @returns true if it requires to be recomputed otherwise, false.
  66237. */
  66238. needProjectionMatrixCompute(): boolean;
  66239. /**
  66240. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66241. */
  66242. forceProjectionMatrixCompute(): void;
  66243. /**
  66244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66247. */
  66248. getShadowDirection(faceIndex?: number): Vector3;
  66249. /**
  66250. * Gets the minZ used for shadow according to both the scene and the light.
  66251. * @param activeCamera The camera we are returning the min for
  66252. * @returns the depth min z
  66253. */
  66254. getDepthMinZ(activeCamera: Camera): number;
  66255. /**
  66256. * Gets the maxZ used for shadow according to both the scene and the light.
  66257. * @param activeCamera The camera we are returning the max for
  66258. * @returns the depth max z
  66259. */
  66260. getDepthMaxZ(activeCamera: Camera): number;
  66261. }
  66262. /**
  66263. * Base implementation IShadowLight
  66264. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66265. */
  66266. export abstract class ShadowLight extends Light implements IShadowLight {
  66267. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66268. protected _position: Vector3;
  66269. protected _setPosition(value: Vector3): void;
  66270. /**
  66271. * Sets the position the shadow will be casted from. Also use as the light position for both
  66272. * point and spot lights.
  66273. */
  66274. /**
  66275. * Sets the position the shadow will be casted from. Also use as the light position for both
  66276. * point and spot lights.
  66277. */
  66278. position: Vector3;
  66279. protected _direction: Vector3;
  66280. protected _setDirection(value: Vector3): void;
  66281. /**
  66282. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66283. * Also use as the light direction on spot and directional lights.
  66284. */
  66285. /**
  66286. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66287. * Also use as the light direction on spot and directional lights.
  66288. */
  66289. direction: Vector3;
  66290. private _shadowMinZ;
  66291. /**
  66292. * Gets the shadow projection clipping minimum z value.
  66293. */
  66294. /**
  66295. * Sets the shadow projection clipping minimum z value.
  66296. */
  66297. shadowMinZ: number;
  66298. private _shadowMaxZ;
  66299. /**
  66300. * Sets the shadow projection clipping maximum z value.
  66301. */
  66302. /**
  66303. * Gets the shadow projection clipping maximum z value.
  66304. */
  66305. shadowMaxZ: number;
  66306. /**
  66307. * Callback defining a custom Projection Matrix Builder.
  66308. * This can be used to override the default projection matrix computation.
  66309. */
  66310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66311. /**
  66312. * The transformed position. Position of the light in world space taking parenting in account.
  66313. */
  66314. transformedPosition: Vector3;
  66315. /**
  66316. * The transformed direction. Direction of the light in world space taking parenting in account.
  66317. */
  66318. transformedDirection: Vector3;
  66319. private _needProjectionMatrixCompute;
  66320. /**
  66321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66323. */
  66324. computeTransformedInformation(): boolean;
  66325. /**
  66326. * Return the depth scale used for the shadow map.
  66327. * @returns the depth scale.
  66328. */
  66329. getDepthScale(): number;
  66330. /**
  66331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66334. */
  66335. getShadowDirection(faceIndex?: number): Vector3;
  66336. /**
  66337. * Returns the ShadowLight absolute position in the World.
  66338. * @returns the position vector in world space
  66339. */
  66340. getAbsolutePosition(): Vector3;
  66341. /**
  66342. * Sets the ShadowLight direction toward the passed target.
  66343. * @param target The point to target in local space
  66344. * @returns the updated ShadowLight direction
  66345. */
  66346. setDirectionToTarget(target: Vector3): Vector3;
  66347. /**
  66348. * Returns the light rotation in euler definition.
  66349. * @returns the x y z rotation in local space.
  66350. */
  66351. getRotation(): Vector3;
  66352. /**
  66353. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66354. * @returns true if a cube texture needs to be use
  66355. */
  66356. needCube(): boolean;
  66357. /**
  66358. * Detects if the projection matrix requires to be recomputed this frame.
  66359. * @returns true if it requires to be recomputed otherwise, false.
  66360. */
  66361. needProjectionMatrixCompute(): boolean;
  66362. /**
  66363. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66364. */
  66365. forceProjectionMatrixCompute(): void;
  66366. /** @hidden */
  66367. _initCache(): void;
  66368. /** @hidden */
  66369. _isSynchronized(): boolean;
  66370. /**
  66371. * Computes the world matrix of the node
  66372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66373. * @returns the world matrix
  66374. */
  66375. computeWorldMatrix(force?: boolean): Matrix;
  66376. /**
  66377. * Gets the minZ used for shadow according to both the scene and the light.
  66378. * @param activeCamera The camera we are returning the min for
  66379. * @returns the depth min z
  66380. */
  66381. getDepthMinZ(activeCamera: Camera): number;
  66382. /**
  66383. * Gets the maxZ used for shadow according to both the scene and the light.
  66384. * @param activeCamera The camera we are returning the max for
  66385. * @returns the depth max z
  66386. */
  66387. getDepthMaxZ(activeCamera: Camera): number;
  66388. /**
  66389. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66390. * @param matrix The materix to updated with the projection information
  66391. * @param viewMatrix The transform matrix of the light
  66392. * @param renderList The list of mesh to render in the map
  66393. * @returns The current light
  66394. */
  66395. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66396. }
  66397. }
  66398. declare module BABYLON {
  66399. /**
  66400. * "Static Class" containing the most commonly used helper while dealing with material for
  66401. * rendering purpose.
  66402. *
  66403. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66404. *
  66405. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66406. */
  66407. export class MaterialHelper {
  66408. /**
  66409. * Bind the current view position to an effect.
  66410. * @param effect The effect to be bound
  66411. * @param scene The scene the eyes position is used from
  66412. */
  66413. static BindEyePosition(effect: Effect, scene: Scene): void;
  66414. /**
  66415. * Helps preparing the defines values about the UVs in used in the effect.
  66416. * UVs are shared as much as we can accross channels in the shaders.
  66417. * @param texture The texture we are preparing the UVs for
  66418. * @param defines The defines to update
  66419. * @param key The channel key "diffuse", "specular"... used in the shader
  66420. */
  66421. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66422. /**
  66423. * Binds a texture matrix value to its corrsponding uniform
  66424. * @param texture The texture to bind the matrix for
  66425. * @param uniformBuffer The uniform buffer receivin the data
  66426. * @param key The channel key "diffuse", "specular"... used in the shader
  66427. */
  66428. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66429. /**
  66430. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66431. * @param mesh defines the current mesh
  66432. * @param scene defines the current scene
  66433. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66434. * @param pointsCloud defines if point cloud rendering has to be turned on
  66435. * @param fogEnabled defines if fog has to be turned on
  66436. * @param alphaTest defines if alpha testing has to be turned on
  66437. * @param defines defines the current list of defines
  66438. */
  66439. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66440. /**
  66441. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66442. * @param scene defines the current scene
  66443. * @param engine defines the current engine
  66444. * @param defines specifies the list of active defines
  66445. * @param useInstances defines if instances have to be turned on
  66446. * @param useClipPlane defines if clip plane have to be turned on
  66447. */
  66448. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66449. /**
  66450. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66451. * @param mesh The mesh containing the geometry data we will draw
  66452. * @param defines The defines to update
  66453. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66454. * @param useBones Precise whether bones should be used or not (override mesh info)
  66455. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66456. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66457. * @returns false if defines are considered not dirty and have not been checked
  66458. */
  66459. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66460. /**
  66461. * Prepares the defines related to the light information passed in parameter
  66462. * @param scene The scene we are intending to draw
  66463. * @param mesh The mesh the effect is compiling for
  66464. * @param defines The defines to update
  66465. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66466. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66467. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66468. * @returns true if normals will be required for the rest of the effect
  66469. */
  66470. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66471. /**
  66472. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66473. * that won t be acctive due to defines being turned off.
  66474. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66475. * @param samplersList The samplers list
  66476. * @param defines The defines helping in the list generation
  66477. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66478. */
  66479. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66480. /**
  66481. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66482. * @param defines The defines to update while falling back
  66483. * @param fallbacks The authorized effect fallbacks
  66484. * @param maxSimultaneousLights The maximum number of lights allowed
  66485. * @param rank the current rank of the Effect
  66486. * @returns The newly affected rank
  66487. */
  66488. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66489. /**
  66490. * Prepares the list of attributes required for morph targets according to the effect defines.
  66491. * @param attribs The current list of supported attribs
  66492. * @param mesh The mesh to prepare the morph targets attributes for
  66493. * @param defines The current Defines of the effect
  66494. */
  66495. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66496. /**
  66497. * Prepares the list of attributes required for bones according to the effect defines.
  66498. * @param attribs The current list of supported attribs
  66499. * @param mesh The mesh to prepare the bones attributes for
  66500. * @param defines The current Defines of the effect
  66501. * @param fallbacks The current efffect fallback strategy
  66502. */
  66503. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66504. /**
  66505. * Prepares the list of attributes required for instances according to the effect defines.
  66506. * @param attribs The current list of supported attribs
  66507. * @param defines The current Defines of the effect
  66508. */
  66509. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66510. /**
  66511. * Binds the light shadow information to the effect for the given mesh.
  66512. * @param light The light containing the generator
  66513. * @param scene The scene the lights belongs to
  66514. * @param mesh The mesh we are binding the information to render
  66515. * @param lightIndex The light index in the effect used to render the mesh
  66516. * @param effect The effect we are binding the data to
  66517. */
  66518. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66519. /**
  66520. * Binds the light information to the effect.
  66521. * @param light The light containing the generator
  66522. * @param effect The effect we are binding the data to
  66523. * @param lightIndex The light index in the effect used to render
  66524. */
  66525. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66526. /**
  66527. * Binds the lights information from the scene to the effect for the given mesh.
  66528. * @param scene The scene the lights belongs to
  66529. * @param mesh The mesh we are binding the information to render
  66530. * @param effect The effect we are binding the data to
  66531. * @param defines The generated defines for the effect
  66532. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66533. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66534. */
  66535. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66536. private static _tempFogColor;
  66537. /**
  66538. * Binds the fog information from the scene to the effect for the given mesh.
  66539. * @param scene The scene the lights belongs to
  66540. * @param mesh The mesh we are binding the information to render
  66541. * @param effect The effect we are binding the data to
  66542. * @param linearSpace Defines if the fog effect is applied in linear space
  66543. */
  66544. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66545. /**
  66546. * Binds the bones information from the mesh to the effect.
  66547. * @param mesh The mesh we are binding the information to render
  66548. * @param effect The effect we are binding the data to
  66549. */
  66550. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66551. /**
  66552. * Binds the morph targets information from the mesh to the effect.
  66553. * @param abstractMesh The mesh we are binding the information to render
  66554. * @param effect The effect we are binding the data to
  66555. */
  66556. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66557. /**
  66558. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66559. * @param defines The generated defines used in the effect
  66560. * @param effect The effect we are binding the data to
  66561. * @param scene The scene we are willing to render with logarithmic scale for
  66562. */
  66563. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66564. /**
  66565. * Binds the clip plane information from the scene to the effect.
  66566. * @param scene The scene the clip plane information are extracted from
  66567. * @param effect The effect we are binding the data to
  66568. */
  66569. static BindClipPlane(effect: Effect, scene: Scene): void;
  66570. }
  66571. }
  66572. declare module BABYLON {
  66573. /** @hidden */
  66574. export var kernelBlurVaryingDeclaration: {
  66575. name: string;
  66576. shader: string;
  66577. };
  66578. }
  66579. declare module BABYLON {
  66580. /** @hidden */
  66581. export var kernelBlurFragment: {
  66582. name: string;
  66583. shader: string;
  66584. };
  66585. }
  66586. declare module BABYLON {
  66587. /** @hidden */
  66588. export var kernelBlurFragment2: {
  66589. name: string;
  66590. shader: string;
  66591. };
  66592. }
  66593. declare module BABYLON {
  66594. /** @hidden */
  66595. export var kernelBlurPixelShader: {
  66596. name: string;
  66597. shader: string;
  66598. };
  66599. }
  66600. declare module BABYLON {
  66601. /** @hidden */
  66602. export var kernelBlurVertex: {
  66603. name: string;
  66604. shader: string;
  66605. };
  66606. }
  66607. declare module BABYLON {
  66608. /** @hidden */
  66609. export var kernelBlurVertexShader: {
  66610. name: string;
  66611. shader: string;
  66612. };
  66613. }
  66614. declare module BABYLON {
  66615. /**
  66616. * The Blur Post Process which blurs an image based on a kernel and direction.
  66617. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66618. */
  66619. export class BlurPostProcess extends PostProcess {
  66620. /** The direction in which to blur the image. */
  66621. direction: Vector2;
  66622. private blockCompilation;
  66623. protected _kernel: number;
  66624. protected _idealKernel: number;
  66625. protected _packedFloat: boolean;
  66626. private _staticDefines;
  66627. /**
  66628. * Sets the length in pixels of the blur sample region
  66629. */
  66630. /**
  66631. * Gets the length in pixels of the blur sample region
  66632. */
  66633. kernel: number;
  66634. /**
  66635. * Sets wether or not the blur needs to unpack/repack floats
  66636. */
  66637. /**
  66638. * Gets wether or not the blur is unpacking/repacking floats
  66639. */
  66640. packedFloat: boolean;
  66641. /**
  66642. * Creates a new instance BlurPostProcess
  66643. * @param name The name of the effect.
  66644. * @param direction The direction in which to blur the image.
  66645. * @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.
  66646. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66647. * @param camera The camera to apply the render pass to.
  66648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66649. * @param engine The engine which the post process will be applied. (default: current engine)
  66650. * @param reusable If the post process can be reused on the same frame. (default: false)
  66651. * @param textureType Type of textures used when performing the post process. (default: 0)
  66652. * @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)
  66653. */
  66654. constructor(name: string,
  66655. /** The direction in which to blur the image. */
  66656. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66657. /**
  66658. * Updates the effect with the current post process compile time values and recompiles the shader.
  66659. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66660. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66661. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66662. * @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
  66663. * @param onCompiled Called when the shader has been compiled.
  66664. * @param onError Called if there is an error when compiling a shader.
  66665. */
  66666. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66667. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66668. /**
  66669. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66670. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66671. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66672. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66673. * The gaps between physical kernels are compensated for in the weighting of the samples
  66674. * @param idealKernel Ideal blur kernel.
  66675. * @return Nearest best kernel.
  66676. */
  66677. protected _nearestBestKernel(idealKernel: number): number;
  66678. /**
  66679. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66680. * @param x The point on the Gaussian distribution to sample.
  66681. * @return the value of the Gaussian function at x.
  66682. */
  66683. protected _gaussianWeight(x: number): number;
  66684. /**
  66685. * Generates a string that can be used as a floating point number in GLSL.
  66686. * @param x Value to print.
  66687. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66688. * @return GLSL float string.
  66689. */
  66690. protected _glslFloat(x: number, decimalFigures?: number): string;
  66691. }
  66692. }
  66693. declare module BABYLON {
  66694. /** @hidden */
  66695. export var shadowMapPixelShader: {
  66696. name: string;
  66697. shader: string;
  66698. };
  66699. }
  66700. declare module BABYLON {
  66701. /** @hidden */
  66702. export var bonesDeclaration: {
  66703. name: string;
  66704. shader: string;
  66705. };
  66706. }
  66707. declare module BABYLON {
  66708. /** @hidden */
  66709. export var morphTargetsVertexGlobalDeclaration: {
  66710. name: string;
  66711. shader: string;
  66712. };
  66713. }
  66714. declare module BABYLON {
  66715. /** @hidden */
  66716. export var morphTargetsVertexDeclaration: {
  66717. name: string;
  66718. shader: string;
  66719. };
  66720. }
  66721. declare module BABYLON {
  66722. /** @hidden */
  66723. export var instancesDeclaration: {
  66724. name: string;
  66725. shader: string;
  66726. };
  66727. }
  66728. declare module BABYLON {
  66729. /** @hidden */
  66730. export var helperFunctions: {
  66731. name: string;
  66732. shader: string;
  66733. };
  66734. }
  66735. declare module BABYLON {
  66736. /** @hidden */
  66737. export var morphTargetsVertex: {
  66738. name: string;
  66739. shader: string;
  66740. };
  66741. }
  66742. declare module BABYLON {
  66743. /** @hidden */
  66744. export var instancesVertex: {
  66745. name: string;
  66746. shader: string;
  66747. };
  66748. }
  66749. declare module BABYLON {
  66750. /** @hidden */
  66751. export var bonesVertex: {
  66752. name: string;
  66753. shader: string;
  66754. };
  66755. }
  66756. declare module BABYLON {
  66757. /** @hidden */
  66758. export var shadowMapVertexShader: {
  66759. name: string;
  66760. shader: string;
  66761. };
  66762. }
  66763. declare module BABYLON {
  66764. /** @hidden */
  66765. export var depthBoxBlurPixelShader: {
  66766. name: string;
  66767. shader: string;
  66768. };
  66769. }
  66770. declare module BABYLON {
  66771. /**
  66772. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66773. */
  66774. export interface ICustomShaderOptions {
  66775. /**
  66776. * Gets or sets the custom shader name to use
  66777. */
  66778. shaderName: string;
  66779. /**
  66780. * The list of attribute names used in the shader
  66781. */
  66782. attributes?: string[];
  66783. /**
  66784. * The list of unifrom names used in the shader
  66785. */
  66786. uniforms?: string[];
  66787. /**
  66788. * The list of sampler names used in the shader
  66789. */
  66790. samplers?: string[];
  66791. /**
  66792. * The list of defines used in the shader
  66793. */
  66794. defines?: string[];
  66795. }
  66796. /**
  66797. * Interface to implement to create a shadow generator compatible with BJS.
  66798. */
  66799. export interface IShadowGenerator {
  66800. /**
  66801. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66802. * @returns The render target texture if present otherwise, null
  66803. */
  66804. getShadowMap(): Nullable<RenderTargetTexture>;
  66805. /**
  66806. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66807. * @returns The render target texture if the shadow map is present otherwise, null
  66808. */
  66809. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66810. /**
  66811. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66812. * @param subMesh The submesh we want to render in the shadow map
  66813. * @param useInstances Defines wether will draw in the map using instances
  66814. * @returns true if ready otherwise, false
  66815. */
  66816. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66817. /**
  66818. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66819. * @param defines Defines of the material we want to update
  66820. * @param lightIndex Index of the light in the enabled light list of the material
  66821. */
  66822. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66823. /**
  66824. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66825. * defined in the generator but impacting the effect).
  66826. * It implies the unifroms available on the materials are the standard BJS ones.
  66827. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66828. * @param effect The effect we are binfing the information for
  66829. */
  66830. bindShadowLight(lightIndex: string, effect: Effect): void;
  66831. /**
  66832. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66833. * (eq to shadow prjection matrix * light transform matrix)
  66834. * @returns The transform matrix used to create the shadow map
  66835. */
  66836. getTransformMatrix(): Matrix;
  66837. /**
  66838. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66839. * Cube and 2D textures for instance.
  66840. */
  66841. recreateShadowMap(): void;
  66842. /**
  66843. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66844. * @param onCompiled Callback triggered at the and of the effects compilation
  66845. * @param options Sets of optional options forcing the compilation with different modes
  66846. */
  66847. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66848. useInstances: boolean;
  66849. }>): void;
  66850. /**
  66851. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66852. * @param options Sets of optional options forcing the compilation with different modes
  66853. * @returns A promise that resolves when the compilation completes
  66854. */
  66855. forceCompilationAsync(options?: Partial<{
  66856. useInstances: boolean;
  66857. }>): Promise<void>;
  66858. /**
  66859. * Serializes the shadow generator setup to a json object.
  66860. * @returns The serialized JSON object
  66861. */
  66862. serialize(): any;
  66863. /**
  66864. * Disposes the Shadow map and related Textures and effects.
  66865. */
  66866. dispose(): void;
  66867. }
  66868. /**
  66869. * Default implementation IShadowGenerator.
  66870. * This is the main object responsible of generating shadows in the framework.
  66871. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66872. */
  66873. export class ShadowGenerator implements IShadowGenerator {
  66874. /**
  66875. * Shadow generator mode None: no filtering applied.
  66876. */
  66877. static readonly FILTER_NONE: number;
  66878. /**
  66879. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66880. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66881. */
  66882. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66883. /**
  66884. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66885. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66886. */
  66887. static readonly FILTER_POISSONSAMPLING: number;
  66888. /**
  66889. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66890. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66891. */
  66892. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66893. /**
  66894. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66895. * edge artifacts on steep falloff.
  66896. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66897. */
  66898. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66899. /**
  66900. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66901. * edge artifacts on steep falloff.
  66902. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66903. */
  66904. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66905. /**
  66906. * Shadow generator mode PCF: Percentage Closer Filtering
  66907. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66908. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66909. */
  66910. static readonly FILTER_PCF: number;
  66911. /**
  66912. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66913. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66914. * Contact Hardening
  66915. */
  66916. static readonly FILTER_PCSS: number;
  66917. /**
  66918. * Reserved for PCF and PCSS
  66919. * Highest Quality.
  66920. *
  66921. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66922. *
  66923. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66924. */
  66925. static readonly QUALITY_HIGH: number;
  66926. /**
  66927. * Reserved for PCF and PCSS
  66928. * Good tradeoff for quality/perf cross devices
  66929. *
  66930. * Execute PCF on a 3*3 kernel.
  66931. *
  66932. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66933. */
  66934. static readonly QUALITY_MEDIUM: number;
  66935. /**
  66936. * Reserved for PCF and PCSS
  66937. * The lowest quality but the fastest.
  66938. *
  66939. * Execute PCF on a 1*1 kernel.
  66940. *
  66941. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66942. */
  66943. static readonly QUALITY_LOW: number;
  66944. /** Gets or sets the custom shader name to use */
  66945. customShaderOptions: ICustomShaderOptions;
  66946. /**
  66947. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66948. */
  66949. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66950. private _bias;
  66951. /**
  66952. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66953. */
  66954. /**
  66955. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66956. */
  66957. bias: number;
  66958. private _normalBias;
  66959. /**
  66960. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66961. */
  66962. /**
  66963. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66964. */
  66965. normalBias: number;
  66966. private _blurBoxOffset;
  66967. /**
  66968. * Gets the blur box offset: offset applied during the blur pass.
  66969. * Only useful if useKernelBlur = false
  66970. */
  66971. /**
  66972. * Sets the blur box offset: offset applied during the blur pass.
  66973. * Only useful if useKernelBlur = false
  66974. */
  66975. blurBoxOffset: number;
  66976. private _blurScale;
  66977. /**
  66978. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66979. * 2 means half of the size.
  66980. */
  66981. /**
  66982. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66983. * 2 means half of the size.
  66984. */
  66985. blurScale: number;
  66986. private _blurKernel;
  66987. /**
  66988. * Gets the blur kernel: kernel size of the blur pass.
  66989. * Only useful if useKernelBlur = true
  66990. */
  66991. /**
  66992. * Sets the blur kernel: kernel size of the blur pass.
  66993. * Only useful if useKernelBlur = true
  66994. */
  66995. blurKernel: number;
  66996. private _useKernelBlur;
  66997. /**
  66998. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66999. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67000. */
  67001. /**
  67002. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67003. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67004. */
  67005. useKernelBlur: boolean;
  67006. private _depthScale;
  67007. /**
  67008. * Gets the depth scale used in ESM mode.
  67009. */
  67010. /**
  67011. * Sets the depth scale used in ESM mode.
  67012. * This can override the scale stored on the light.
  67013. */
  67014. depthScale: number;
  67015. private _filter;
  67016. /**
  67017. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67018. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67019. */
  67020. /**
  67021. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67022. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67023. */
  67024. filter: number;
  67025. /**
  67026. * Gets if the current filter is set to Poisson Sampling.
  67027. */
  67028. /**
  67029. * Sets the current filter to Poisson Sampling.
  67030. */
  67031. usePoissonSampling: boolean;
  67032. /**
  67033. * Gets if the current filter is set to ESM.
  67034. */
  67035. /**
  67036. * Sets the current filter is to ESM.
  67037. */
  67038. useExponentialShadowMap: boolean;
  67039. /**
  67040. * Gets if the current filter is set to filtered ESM.
  67041. */
  67042. /**
  67043. * Gets if the current filter is set to filtered ESM.
  67044. */
  67045. useBlurExponentialShadowMap: boolean;
  67046. /**
  67047. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67048. * exponential to prevent steep falloff artifacts).
  67049. */
  67050. /**
  67051. * Sets the current filter to "close ESM" (using the inverse of the
  67052. * exponential to prevent steep falloff artifacts).
  67053. */
  67054. useCloseExponentialShadowMap: boolean;
  67055. /**
  67056. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67057. * exponential to prevent steep falloff artifacts).
  67058. */
  67059. /**
  67060. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67061. * exponential to prevent steep falloff artifacts).
  67062. */
  67063. useBlurCloseExponentialShadowMap: boolean;
  67064. /**
  67065. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67066. */
  67067. /**
  67068. * Sets the current filter to "PCF" (percentage closer filtering).
  67069. */
  67070. usePercentageCloserFiltering: boolean;
  67071. private _filteringQuality;
  67072. /**
  67073. * Gets the PCF or PCSS Quality.
  67074. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67075. */
  67076. /**
  67077. * Sets the PCF or PCSS Quality.
  67078. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67079. */
  67080. filteringQuality: number;
  67081. /**
  67082. * Gets if the current filter is set to "PCSS" (contact hardening).
  67083. */
  67084. /**
  67085. * Sets the current filter to "PCSS" (contact hardening).
  67086. */
  67087. useContactHardeningShadow: boolean;
  67088. private _contactHardeningLightSizeUVRatio;
  67089. /**
  67090. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67091. * Using a ratio helps keeping shape stability independently of the map size.
  67092. *
  67093. * It does not account for the light projection as it was having too much
  67094. * instability during the light setup or during light position changes.
  67095. *
  67096. * Only valid if useContactHardeningShadow is true.
  67097. */
  67098. /**
  67099. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67100. * Using a ratio helps keeping shape stability independently of the map size.
  67101. *
  67102. * It does not account for the light projection as it was having too much
  67103. * instability during the light setup or during light position changes.
  67104. *
  67105. * Only valid if useContactHardeningShadow is true.
  67106. */
  67107. contactHardeningLightSizeUVRatio: number;
  67108. private _darkness;
  67109. /**
  67110. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67111. * 0 means strongest and 1 would means no shadow.
  67112. * @returns the darkness.
  67113. */
  67114. getDarkness(): number;
  67115. /**
  67116. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67117. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67118. * @returns the shadow generator allowing fluent coding.
  67119. */
  67120. setDarkness(darkness: number): ShadowGenerator;
  67121. private _transparencyShadow;
  67122. /**
  67123. * Sets the ability to have transparent shadow (boolean).
  67124. * @param transparent True if transparent else False
  67125. * @returns the shadow generator allowing fluent coding
  67126. */
  67127. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67128. private _shadowMap;
  67129. private _shadowMap2;
  67130. /**
  67131. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67132. * @returns The render target texture if present otherwise, null
  67133. */
  67134. getShadowMap(): Nullable<RenderTargetTexture>;
  67135. /**
  67136. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67137. * @returns The render target texture if the shadow map is present otherwise, null
  67138. */
  67139. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67140. /**
  67141. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67142. * @param mesh Mesh to add
  67143. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67144. * @returns the Shadow Generator itself
  67145. */
  67146. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67147. /**
  67148. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67149. * @param mesh Mesh to remove
  67150. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67151. * @returns the Shadow Generator itself
  67152. */
  67153. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67154. /**
  67155. * Controls the extent to which the shadows fade out at the edge of the frustum
  67156. * Used only by directionals and spots
  67157. */
  67158. frustumEdgeFalloff: number;
  67159. private _light;
  67160. /**
  67161. * Returns the associated light object.
  67162. * @returns the light generating the shadow
  67163. */
  67164. getLight(): IShadowLight;
  67165. /**
  67166. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67167. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67168. * It might on the other hand introduce peter panning.
  67169. */
  67170. forceBackFacesOnly: boolean;
  67171. private _scene;
  67172. private _lightDirection;
  67173. private _effect;
  67174. private _viewMatrix;
  67175. private _projectionMatrix;
  67176. private _transformMatrix;
  67177. private _cachedPosition;
  67178. private _cachedDirection;
  67179. private _cachedDefines;
  67180. private _currentRenderID;
  67181. private _boxBlurPostprocess;
  67182. private _kernelBlurXPostprocess;
  67183. private _kernelBlurYPostprocess;
  67184. private _blurPostProcesses;
  67185. private _mapSize;
  67186. private _currentFaceIndex;
  67187. private _currentFaceIndexCache;
  67188. private _textureType;
  67189. private _defaultTextureMatrix;
  67190. /** @hidden */
  67191. static _SceneComponentInitialization: (scene: Scene) => void;
  67192. /**
  67193. * Creates a ShadowGenerator object.
  67194. * A ShadowGenerator is the required tool to use the shadows.
  67195. * Each light casting shadows needs to use its own ShadowGenerator.
  67196. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67197. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67198. * @param light The light object generating the shadows.
  67199. * @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.
  67200. */
  67201. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67202. private _initializeGenerator;
  67203. private _initializeShadowMap;
  67204. private _initializeBlurRTTAndPostProcesses;
  67205. private _renderForShadowMap;
  67206. private _renderSubMeshForShadowMap;
  67207. private _applyFilterValues;
  67208. /**
  67209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67210. * @param onCompiled Callback triggered at the and of the effects compilation
  67211. * @param options Sets of optional options forcing the compilation with different modes
  67212. */
  67213. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67214. useInstances: boolean;
  67215. }>): void;
  67216. /**
  67217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67218. * @param options Sets of optional options forcing the compilation with different modes
  67219. * @returns A promise that resolves when the compilation completes
  67220. */
  67221. forceCompilationAsync(options?: Partial<{
  67222. useInstances: boolean;
  67223. }>): Promise<void>;
  67224. /**
  67225. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67226. * @param subMesh The submesh we want to render in the shadow map
  67227. * @param useInstances Defines wether will draw in the map using instances
  67228. * @returns true if ready otherwise, false
  67229. */
  67230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67231. /**
  67232. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67233. * @param defines Defines of the material we want to update
  67234. * @param lightIndex Index of the light in the enabled light list of the material
  67235. */
  67236. prepareDefines(defines: any, lightIndex: number): void;
  67237. /**
  67238. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67239. * defined in the generator but impacting the effect).
  67240. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67241. * @param effect The effect we are binfing the information for
  67242. */
  67243. bindShadowLight(lightIndex: string, effect: Effect): void;
  67244. /**
  67245. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67246. * (eq to shadow prjection matrix * light transform matrix)
  67247. * @returns The transform matrix used to create the shadow map
  67248. */
  67249. getTransformMatrix(): Matrix;
  67250. /**
  67251. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67252. * Cube and 2D textures for instance.
  67253. */
  67254. recreateShadowMap(): void;
  67255. private _disposeBlurPostProcesses;
  67256. private _disposeRTTandPostProcesses;
  67257. /**
  67258. * Disposes the ShadowGenerator.
  67259. * Returns nothing.
  67260. */
  67261. dispose(): void;
  67262. /**
  67263. * Serializes the shadow generator setup to a json object.
  67264. * @returns The serialized JSON object
  67265. */
  67266. serialize(): any;
  67267. /**
  67268. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67269. * @param parsedShadowGenerator The JSON object to parse
  67270. * @param scene The scene to create the shadow map for
  67271. * @returns The parsed shadow generator
  67272. */
  67273. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67274. }
  67275. }
  67276. declare module BABYLON {
  67277. /**
  67278. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67279. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67280. * 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.
  67281. */
  67282. export abstract class Light extends Node {
  67283. /**
  67284. * Falloff Default: light is falling off following the material specification:
  67285. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67286. */
  67287. static readonly FALLOFF_DEFAULT: number;
  67288. /**
  67289. * Falloff Physical: light is falling off following the inverse squared distance law.
  67290. */
  67291. static readonly FALLOFF_PHYSICAL: number;
  67292. /**
  67293. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67294. * to enhance interoperability with other engines.
  67295. */
  67296. static readonly FALLOFF_GLTF: number;
  67297. /**
  67298. * Falloff Standard: light is falling off like in the standard material
  67299. * to enhance interoperability with other materials.
  67300. */
  67301. static readonly FALLOFF_STANDARD: number;
  67302. /**
  67303. * If every light affecting the material is in this lightmapMode,
  67304. * material.lightmapTexture adds or multiplies
  67305. * (depends on material.useLightmapAsShadowmap)
  67306. * after every other light calculations.
  67307. */
  67308. static readonly LIGHTMAP_DEFAULT: number;
  67309. /**
  67310. * material.lightmapTexture as only diffuse lighting from this light
  67311. * adds only specular lighting from this light
  67312. * adds dynamic shadows
  67313. */
  67314. static readonly LIGHTMAP_SPECULAR: number;
  67315. /**
  67316. * material.lightmapTexture as only lighting
  67317. * no light calculation from this light
  67318. * only adds dynamic shadows from this light
  67319. */
  67320. static readonly LIGHTMAP_SHADOWSONLY: number;
  67321. /**
  67322. * Each light type uses the default quantity according to its type:
  67323. * point/spot lights use luminous intensity
  67324. * directional lights use illuminance
  67325. */
  67326. static readonly INTENSITYMODE_AUTOMATIC: number;
  67327. /**
  67328. * lumen (lm)
  67329. */
  67330. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67331. /**
  67332. * candela (lm/sr)
  67333. */
  67334. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67335. /**
  67336. * lux (lm/m^2)
  67337. */
  67338. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67339. /**
  67340. * nit (cd/m^2)
  67341. */
  67342. static readonly INTENSITYMODE_LUMINANCE: number;
  67343. /**
  67344. * Light type const id of the point light.
  67345. */
  67346. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67347. /**
  67348. * Light type const id of the directional light.
  67349. */
  67350. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67351. /**
  67352. * Light type const id of the spot light.
  67353. */
  67354. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67355. /**
  67356. * Light type const id of the hemispheric light.
  67357. */
  67358. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67359. /**
  67360. * Diffuse gives the basic color to an object.
  67361. */
  67362. diffuse: Color3;
  67363. /**
  67364. * Specular produces a highlight color on an object.
  67365. * Note: This is note affecting PBR materials.
  67366. */
  67367. specular: Color3;
  67368. /**
  67369. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67370. * falling off base on range or angle.
  67371. * This can be set to any values in Light.FALLOFF_x.
  67372. *
  67373. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67374. * other types of materials.
  67375. */
  67376. falloffType: number;
  67377. /**
  67378. * Strength of the light.
  67379. * Note: By default it is define in the framework own unit.
  67380. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67381. */
  67382. intensity: number;
  67383. private _range;
  67384. protected _inverseSquaredRange: number;
  67385. /**
  67386. * Defines how far from the source the light is impacting in scene units.
  67387. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67388. */
  67389. /**
  67390. * Defines how far from the source the light is impacting in scene units.
  67391. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67392. */
  67393. range: number;
  67394. /**
  67395. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67396. * of light.
  67397. */
  67398. private _photometricScale;
  67399. private _intensityMode;
  67400. /**
  67401. * Gets the photometric scale used to interpret the intensity.
  67402. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67403. */
  67404. /**
  67405. * Sets the photometric scale used to interpret the intensity.
  67406. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67407. */
  67408. intensityMode: number;
  67409. private _radius;
  67410. /**
  67411. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67412. */
  67413. /**
  67414. * sets the light radius used by PBR Materials to simulate soft area lights.
  67415. */
  67416. radius: number;
  67417. private _renderPriority;
  67418. /**
  67419. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67420. * exceeding the number allowed of the materials.
  67421. */
  67422. renderPriority: number;
  67423. private _shadowEnabled;
  67424. /**
  67425. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67426. * the current shadow generator.
  67427. */
  67428. /**
  67429. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67430. * the current shadow generator.
  67431. */
  67432. shadowEnabled: boolean;
  67433. private _includedOnlyMeshes;
  67434. /**
  67435. * Gets the only meshes impacted by this light.
  67436. */
  67437. /**
  67438. * Sets the only meshes impacted by this light.
  67439. */
  67440. includedOnlyMeshes: AbstractMesh[];
  67441. private _excludedMeshes;
  67442. /**
  67443. * Gets the meshes not impacted by this light.
  67444. */
  67445. /**
  67446. * Sets the meshes not impacted by this light.
  67447. */
  67448. excludedMeshes: AbstractMesh[];
  67449. private _excludeWithLayerMask;
  67450. /**
  67451. * Gets the layer id use to find what meshes are not impacted by the light.
  67452. * Inactive if 0
  67453. */
  67454. /**
  67455. * Sets the layer id use to find what meshes are not impacted by the light.
  67456. * Inactive if 0
  67457. */
  67458. excludeWithLayerMask: number;
  67459. private _includeOnlyWithLayerMask;
  67460. /**
  67461. * Gets the layer id use to find what meshes are impacted by the light.
  67462. * Inactive if 0
  67463. */
  67464. /**
  67465. * Sets the layer id use to find what meshes are impacted by the light.
  67466. * Inactive if 0
  67467. */
  67468. includeOnlyWithLayerMask: number;
  67469. private _lightmapMode;
  67470. /**
  67471. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67472. */
  67473. /**
  67474. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67475. */
  67476. lightmapMode: number;
  67477. /**
  67478. * Shadow generator associted to the light.
  67479. * @hidden Internal use only.
  67480. */
  67481. _shadowGenerator: Nullable<IShadowGenerator>;
  67482. /**
  67483. * @hidden Internal use only.
  67484. */
  67485. _excludedMeshesIds: string[];
  67486. /**
  67487. * @hidden Internal use only.
  67488. */
  67489. _includedOnlyMeshesIds: string[];
  67490. /**
  67491. * The current light unifom buffer.
  67492. * @hidden Internal use only.
  67493. */
  67494. _uniformBuffer: UniformBuffer;
  67495. /**
  67496. * Creates a Light object in the scene.
  67497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67498. * @param name The firendly name of the light
  67499. * @param scene The scene the light belongs too
  67500. */
  67501. constructor(name: string, scene: Scene);
  67502. protected abstract _buildUniformLayout(): void;
  67503. /**
  67504. * Sets the passed Effect "effect" with the Light information.
  67505. * @param effect The effect to update
  67506. * @param lightIndex The index of the light in the effect to update
  67507. * @returns The light
  67508. */
  67509. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67510. /**
  67511. * Returns the string "Light".
  67512. * @returns the class name
  67513. */
  67514. getClassName(): string;
  67515. /** @hidden */
  67516. readonly _isLight: boolean;
  67517. /**
  67518. * Converts the light information to a readable string for debug purpose.
  67519. * @param fullDetails Supports for multiple levels of logging within scene loading
  67520. * @returns the human readable light info
  67521. */
  67522. toString(fullDetails?: boolean): string;
  67523. /** @hidden */
  67524. protected _syncParentEnabledState(): void;
  67525. /**
  67526. * Set the enabled state of this node.
  67527. * @param value - the new enabled state
  67528. */
  67529. setEnabled(value: boolean): void;
  67530. /**
  67531. * Returns the Light associated shadow generator if any.
  67532. * @return the associated shadow generator.
  67533. */
  67534. getShadowGenerator(): Nullable<IShadowGenerator>;
  67535. /**
  67536. * Returns a Vector3, the absolute light position in the World.
  67537. * @returns the world space position of the light
  67538. */
  67539. getAbsolutePosition(): Vector3;
  67540. /**
  67541. * Specifies if the light will affect the passed mesh.
  67542. * @param mesh The mesh to test against the light
  67543. * @return true the mesh is affected otherwise, false.
  67544. */
  67545. canAffectMesh(mesh: AbstractMesh): boolean;
  67546. /**
  67547. * Sort function to order lights for rendering.
  67548. * @param a First Light object to compare to second.
  67549. * @param b Second Light object to compare first.
  67550. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67551. */
  67552. static CompareLightsPriority(a: Light, b: Light): number;
  67553. /**
  67554. * Releases resources associated with this node.
  67555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67557. */
  67558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67559. /**
  67560. * Returns the light type ID (integer).
  67561. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67562. */
  67563. getTypeID(): number;
  67564. /**
  67565. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67566. * @returns the scaled intensity in intensity mode unit
  67567. */
  67568. getScaledIntensity(): number;
  67569. /**
  67570. * Returns a new Light object, named "name", from the current one.
  67571. * @param name The name of the cloned light
  67572. * @returns the new created light
  67573. */
  67574. clone(name: string): Nullable<Light>;
  67575. /**
  67576. * Serializes the current light into a Serialization object.
  67577. * @returns the serialized object.
  67578. */
  67579. serialize(): any;
  67580. /**
  67581. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67582. * This new light is named "name" and added to the passed scene.
  67583. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67584. * @param name The friendly name of the light
  67585. * @param scene The scene the new light will belong to
  67586. * @returns the constructor function
  67587. */
  67588. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67589. /**
  67590. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67591. * @param parsedLight The JSON representation of the light
  67592. * @param scene The scene to create the parsed light in
  67593. * @returns the created light after parsing
  67594. */
  67595. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67596. private _hookArrayForExcluded;
  67597. private _hookArrayForIncludedOnly;
  67598. private _resyncMeshes;
  67599. /**
  67600. * Forces the meshes to update their light related information in their rendering used effects
  67601. * @hidden Internal Use Only
  67602. */
  67603. _markMeshesAsLightDirty(): void;
  67604. /**
  67605. * Recomputes the cached photometric scale if needed.
  67606. */
  67607. private _computePhotometricScale;
  67608. /**
  67609. * Returns the Photometric Scale according to the light type and intensity mode.
  67610. */
  67611. private _getPhotometricScale;
  67612. /**
  67613. * Reorder the light in the scene according to their defined priority.
  67614. * @hidden Internal Use Only
  67615. */
  67616. _reorderLightsInScene(): void;
  67617. /**
  67618. * Prepares the list of defines specific to the light type.
  67619. * @param defines the list of defines
  67620. * @param lightIndex defines the index of the light for the effect
  67621. */
  67622. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67623. }
  67624. }
  67625. declare module BABYLON {
  67626. /**
  67627. * Interface used to define Action
  67628. */
  67629. export interface IAction {
  67630. /**
  67631. * Trigger for the action
  67632. */
  67633. trigger: number;
  67634. /** Options of the trigger */
  67635. triggerOptions: any;
  67636. /**
  67637. * Gets the trigger parameters
  67638. * @returns the trigger parameters
  67639. */
  67640. getTriggerParameter(): any;
  67641. /**
  67642. * Internal only - executes current action event
  67643. * @hidden
  67644. */
  67645. _executeCurrent(evt?: ActionEvent): void;
  67646. /**
  67647. * Serialize placeholder for child classes
  67648. * @param parent of child
  67649. * @returns the serialized object
  67650. */
  67651. serialize(parent: any): any;
  67652. /**
  67653. * Internal only
  67654. * @hidden
  67655. */
  67656. _prepare(): void;
  67657. /**
  67658. * Internal only - manager for action
  67659. * @hidden
  67660. */
  67661. _actionManager: AbstractActionManager;
  67662. }
  67663. /**
  67664. * The action to be carried out following a trigger
  67665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67666. */
  67667. export class Action implements IAction {
  67668. /** the trigger, with or without parameters, for the action */
  67669. triggerOptions: any;
  67670. /**
  67671. * Trigger for the action
  67672. */
  67673. trigger: number;
  67674. /**
  67675. * Internal only - manager for action
  67676. * @hidden
  67677. */
  67678. _actionManager: ActionManager;
  67679. private _nextActiveAction;
  67680. private _child;
  67681. private _condition?;
  67682. private _triggerParameter;
  67683. /**
  67684. * An event triggered prior to action being executed.
  67685. */
  67686. onBeforeExecuteObservable: Observable<Action>;
  67687. /**
  67688. * Creates a new Action
  67689. * @param triggerOptions the trigger, with or without parameters, for the action
  67690. * @param condition an optional determinant of action
  67691. */
  67692. constructor(
  67693. /** the trigger, with or without parameters, for the action */
  67694. triggerOptions: any, condition?: Condition);
  67695. /**
  67696. * Internal only
  67697. * @hidden
  67698. */
  67699. _prepare(): void;
  67700. /**
  67701. * Gets the trigger parameters
  67702. * @returns the trigger parameters
  67703. */
  67704. getTriggerParameter(): any;
  67705. /**
  67706. * Internal only - executes current action event
  67707. * @hidden
  67708. */
  67709. _executeCurrent(evt?: ActionEvent): void;
  67710. /**
  67711. * Execute placeholder for child classes
  67712. * @param evt optional action event
  67713. */
  67714. execute(evt?: ActionEvent): void;
  67715. /**
  67716. * Skips to next active action
  67717. */
  67718. skipToNextActiveAction(): void;
  67719. /**
  67720. * Adds action to chain of actions, may be a DoNothingAction
  67721. * @param action defines the next action to execute
  67722. * @returns The action passed in
  67723. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67724. */
  67725. then(action: Action): Action;
  67726. /**
  67727. * Internal only
  67728. * @hidden
  67729. */
  67730. _getProperty(propertyPath: string): string;
  67731. /**
  67732. * Internal only
  67733. * @hidden
  67734. */
  67735. _getEffectiveTarget(target: any, propertyPath: string): any;
  67736. /**
  67737. * Serialize placeholder for child classes
  67738. * @param parent of child
  67739. * @returns the serialized object
  67740. */
  67741. serialize(parent: any): any;
  67742. /**
  67743. * Internal only called by serialize
  67744. * @hidden
  67745. */
  67746. protected _serialize(serializedAction: any, parent?: any): any;
  67747. /**
  67748. * Internal only
  67749. * @hidden
  67750. */
  67751. static _SerializeValueAsString: (value: any) => string;
  67752. /**
  67753. * Internal only
  67754. * @hidden
  67755. */
  67756. static _GetTargetProperty: (target: Scene | Node) => {
  67757. name: string;
  67758. targetType: string;
  67759. value: string;
  67760. };
  67761. }
  67762. }
  67763. declare module BABYLON {
  67764. /**
  67765. * A Condition applied to an Action
  67766. */
  67767. export class Condition {
  67768. /**
  67769. * Internal only - manager for action
  67770. * @hidden
  67771. */
  67772. _actionManager: ActionManager;
  67773. /**
  67774. * Internal only
  67775. * @hidden
  67776. */
  67777. _evaluationId: number;
  67778. /**
  67779. * Internal only
  67780. * @hidden
  67781. */
  67782. _currentResult: boolean;
  67783. /**
  67784. * Creates a new Condition
  67785. * @param actionManager the manager of the action the condition is applied to
  67786. */
  67787. constructor(actionManager: ActionManager);
  67788. /**
  67789. * Check if the current condition is valid
  67790. * @returns a boolean
  67791. */
  67792. isValid(): boolean;
  67793. /**
  67794. * Internal only
  67795. * @hidden
  67796. */
  67797. _getProperty(propertyPath: string): string;
  67798. /**
  67799. * Internal only
  67800. * @hidden
  67801. */
  67802. _getEffectiveTarget(target: any, propertyPath: string): any;
  67803. /**
  67804. * Serialize placeholder for child classes
  67805. * @returns the serialized object
  67806. */
  67807. serialize(): any;
  67808. /**
  67809. * Internal only
  67810. * @hidden
  67811. */
  67812. protected _serialize(serializedCondition: any): any;
  67813. }
  67814. /**
  67815. * Defines specific conditional operators as extensions of Condition
  67816. */
  67817. export class ValueCondition extends Condition {
  67818. /** path to specify the property of the target the conditional operator uses */
  67819. propertyPath: string;
  67820. /** the value compared by the conditional operator against the current value of the property */
  67821. value: any;
  67822. /** the conditional operator, default ValueCondition.IsEqual */
  67823. operator: number;
  67824. /**
  67825. * Internal only
  67826. * @hidden
  67827. */
  67828. private static _IsEqual;
  67829. /**
  67830. * Internal only
  67831. * @hidden
  67832. */
  67833. private static _IsDifferent;
  67834. /**
  67835. * Internal only
  67836. * @hidden
  67837. */
  67838. private static _IsGreater;
  67839. /**
  67840. * Internal only
  67841. * @hidden
  67842. */
  67843. private static _IsLesser;
  67844. /**
  67845. * returns the number for IsEqual
  67846. */
  67847. static readonly IsEqual: number;
  67848. /**
  67849. * Returns the number for IsDifferent
  67850. */
  67851. static readonly IsDifferent: number;
  67852. /**
  67853. * Returns the number for IsGreater
  67854. */
  67855. static readonly IsGreater: number;
  67856. /**
  67857. * Returns the number for IsLesser
  67858. */
  67859. static readonly IsLesser: number;
  67860. /**
  67861. * Internal only The action manager for the condition
  67862. * @hidden
  67863. */
  67864. _actionManager: ActionManager;
  67865. /**
  67866. * Internal only
  67867. * @hidden
  67868. */
  67869. private _target;
  67870. /**
  67871. * Internal only
  67872. * @hidden
  67873. */
  67874. private _effectiveTarget;
  67875. /**
  67876. * Internal only
  67877. * @hidden
  67878. */
  67879. private _property;
  67880. /**
  67881. * Creates a new ValueCondition
  67882. * @param actionManager manager for the action the condition applies to
  67883. * @param target for the action
  67884. * @param propertyPath path to specify the property of the target the conditional operator uses
  67885. * @param value the value compared by the conditional operator against the current value of the property
  67886. * @param operator the conditional operator, default ValueCondition.IsEqual
  67887. */
  67888. constructor(actionManager: ActionManager, target: any,
  67889. /** path to specify the property of the target the conditional operator uses */
  67890. propertyPath: string,
  67891. /** the value compared by the conditional operator against the current value of the property */
  67892. value: any,
  67893. /** the conditional operator, default ValueCondition.IsEqual */
  67894. operator?: number);
  67895. /**
  67896. * Compares the given value with the property value for the specified conditional operator
  67897. * @returns the result of the comparison
  67898. */
  67899. isValid(): boolean;
  67900. /**
  67901. * Serialize the ValueCondition into a JSON compatible object
  67902. * @returns serialization object
  67903. */
  67904. serialize(): any;
  67905. /**
  67906. * Gets the name of the conditional operator for the ValueCondition
  67907. * @param operator the conditional operator
  67908. * @returns the name
  67909. */
  67910. static GetOperatorName(operator: number): string;
  67911. }
  67912. /**
  67913. * Defines a predicate condition as an extension of Condition
  67914. */
  67915. export class PredicateCondition extends Condition {
  67916. /** defines the predicate function used to validate the condition */
  67917. predicate: () => boolean;
  67918. /**
  67919. * Internal only - manager for action
  67920. * @hidden
  67921. */
  67922. _actionManager: ActionManager;
  67923. /**
  67924. * Creates a new PredicateCondition
  67925. * @param actionManager manager for the action the condition applies to
  67926. * @param predicate defines the predicate function used to validate the condition
  67927. */
  67928. constructor(actionManager: ActionManager,
  67929. /** defines the predicate function used to validate the condition */
  67930. predicate: () => boolean);
  67931. /**
  67932. * @returns the validity of the predicate condition
  67933. */
  67934. isValid(): boolean;
  67935. }
  67936. /**
  67937. * Defines a state condition as an extension of Condition
  67938. */
  67939. export class StateCondition extends Condition {
  67940. /** Value to compare with target state */
  67941. value: string;
  67942. /**
  67943. * Internal only - manager for action
  67944. * @hidden
  67945. */
  67946. _actionManager: ActionManager;
  67947. /**
  67948. * Internal only
  67949. * @hidden
  67950. */
  67951. private _target;
  67952. /**
  67953. * Creates a new StateCondition
  67954. * @param actionManager manager for the action the condition applies to
  67955. * @param target of the condition
  67956. * @param value to compare with target state
  67957. */
  67958. constructor(actionManager: ActionManager, target: any,
  67959. /** Value to compare with target state */
  67960. value: string);
  67961. /**
  67962. * Gets a boolean indicating if the current condition is met
  67963. * @returns the validity of the state
  67964. */
  67965. isValid(): boolean;
  67966. /**
  67967. * Serialize the StateCondition into a JSON compatible object
  67968. * @returns serialization object
  67969. */
  67970. serialize(): any;
  67971. }
  67972. }
  67973. declare module BABYLON {
  67974. /**
  67975. * This defines an action responsible to toggle a boolean once triggered.
  67976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67977. */
  67978. export class SwitchBooleanAction extends Action {
  67979. /**
  67980. * The path to the boolean property in the target object
  67981. */
  67982. propertyPath: string;
  67983. private _target;
  67984. private _effectiveTarget;
  67985. private _property;
  67986. /**
  67987. * Instantiate the action
  67988. * @param triggerOptions defines the trigger options
  67989. * @param target defines the object containing the boolean
  67990. * @param propertyPath defines the path to the boolean property in the target object
  67991. * @param condition defines the trigger related conditions
  67992. */
  67993. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67994. /** @hidden */
  67995. _prepare(): void;
  67996. /**
  67997. * Execute the action toggle the boolean value.
  67998. */
  67999. execute(): void;
  68000. /**
  68001. * Serializes the actions and its related information.
  68002. * @param parent defines the object to serialize in
  68003. * @returns the serialized object
  68004. */
  68005. serialize(parent: any): any;
  68006. }
  68007. /**
  68008. * This defines an action responsible to set a the state field of the target
  68009. * to a desired value once triggered.
  68010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68011. */
  68012. export class SetStateAction extends Action {
  68013. /**
  68014. * The value to store in the state field.
  68015. */
  68016. value: string;
  68017. private _target;
  68018. /**
  68019. * Instantiate the action
  68020. * @param triggerOptions defines the trigger options
  68021. * @param target defines the object containing the state property
  68022. * @param value defines the value to store in the state field
  68023. * @param condition defines the trigger related conditions
  68024. */
  68025. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68026. /**
  68027. * Execute the action and store the value on the target state property.
  68028. */
  68029. execute(): void;
  68030. /**
  68031. * Serializes the actions and its related information.
  68032. * @param parent defines the object to serialize in
  68033. * @returns the serialized object
  68034. */
  68035. serialize(parent: any): any;
  68036. }
  68037. /**
  68038. * This defines an action responsible to set a property of the target
  68039. * to a desired value once triggered.
  68040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68041. */
  68042. export class SetValueAction extends Action {
  68043. /**
  68044. * The path of the property to set in the target.
  68045. */
  68046. propertyPath: string;
  68047. /**
  68048. * The value to set in the property
  68049. */
  68050. value: any;
  68051. private _target;
  68052. private _effectiveTarget;
  68053. private _property;
  68054. /**
  68055. * Instantiate the action
  68056. * @param triggerOptions defines the trigger options
  68057. * @param target defines the object containing the property
  68058. * @param propertyPath defines the path of the property to set in the target
  68059. * @param value defines the value to set in the property
  68060. * @param condition defines the trigger related conditions
  68061. */
  68062. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68063. /** @hidden */
  68064. _prepare(): void;
  68065. /**
  68066. * Execute the action and set the targetted property to the desired value.
  68067. */
  68068. execute(): void;
  68069. /**
  68070. * Serializes the actions and its related information.
  68071. * @param parent defines the object to serialize in
  68072. * @returns the serialized object
  68073. */
  68074. serialize(parent: any): any;
  68075. }
  68076. /**
  68077. * This defines an action responsible to increment the target value
  68078. * to a desired value once triggered.
  68079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68080. */
  68081. export class IncrementValueAction extends Action {
  68082. /**
  68083. * The path of the property to increment in the target.
  68084. */
  68085. propertyPath: string;
  68086. /**
  68087. * The value we should increment the property by.
  68088. */
  68089. value: any;
  68090. private _target;
  68091. private _effectiveTarget;
  68092. private _property;
  68093. /**
  68094. * Instantiate the action
  68095. * @param triggerOptions defines the trigger options
  68096. * @param target defines the object containing the property
  68097. * @param propertyPath defines the path of the property to increment in the target
  68098. * @param value defines the value value we should increment the property by
  68099. * @param condition defines the trigger related conditions
  68100. */
  68101. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68102. /** @hidden */
  68103. _prepare(): void;
  68104. /**
  68105. * Execute the action and increment the target of the value amount.
  68106. */
  68107. execute(): void;
  68108. /**
  68109. * Serializes the actions and its related information.
  68110. * @param parent defines the object to serialize in
  68111. * @returns the serialized object
  68112. */
  68113. serialize(parent: any): any;
  68114. }
  68115. /**
  68116. * This defines an action responsible to start an animation once triggered.
  68117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68118. */
  68119. export class PlayAnimationAction extends Action {
  68120. /**
  68121. * Where the animation should start (animation frame)
  68122. */
  68123. from: number;
  68124. /**
  68125. * Where the animation should stop (animation frame)
  68126. */
  68127. to: number;
  68128. /**
  68129. * Define if the animation should loop or stop after the first play.
  68130. */
  68131. loop?: boolean;
  68132. private _target;
  68133. /**
  68134. * Instantiate the action
  68135. * @param triggerOptions defines the trigger options
  68136. * @param target defines the target animation or animation name
  68137. * @param from defines from where the animation should start (animation frame)
  68138. * @param end defines where the animation should stop (animation frame)
  68139. * @param loop defines if the animation should loop or stop after the first play
  68140. * @param condition defines the trigger related conditions
  68141. */
  68142. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68143. /** @hidden */
  68144. _prepare(): void;
  68145. /**
  68146. * Execute the action and play the animation.
  68147. */
  68148. execute(): void;
  68149. /**
  68150. * Serializes the actions and its related information.
  68151. * @param parent defines the object to serialize in
  68152. * @returns the serialized object
  68153. */
  68154. serialize(parent: any): any;
  68155. }
  68156. /**
  68157. * This defines an action responsible to stop an animation once triggered.
  68158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68159. */
  68160. export class StopAnimationAction extends Action {
  68161. private _target;
  68162. /**
  68163. * Instantiate the action
  68164. * @param triggerOptions defines the trigger options
  68165. * @param target defines the target animation or animation name
  68166. * @param condition defines the trigger related conditions
  68167. */
  68168. constructor(triggerOptions: any, target: any, condition?: Condition);
  68169. /** @hidden */
  68170. _prepare(): void;
  68171. /**
  68172. * Execute the action and stop the animation.
  68173. */
  68174. execute(): void;
  68175. /**
  68176. * Serializes the actions and its related information.
  68177. * @param parent defines the object to serialize in
  68178. * @returns the serialized object
  68179. */
  68180. serialize(parent: any): any;
  68181. }
  68182. /**
  68183. * This defines an action responsible that does nothing once triggered.
  68184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68185. */
  68186. export class DoNothingAction extends Action {
  68187. /**
  68188. * Instantiate the action
  68189. * @param triggerOptions defines the trigger options
  68190. * @param condition defines the trigger related conditions
  68191. */
  68192. constructor(triggerOptions?: any, condition?: Condition);
  68193. /**
  68194. * Execute the action and do nothing.
  68195. */
  68196. execute(): void;
  68197. /**
  68198. * Serializes the actions and its related information.
  68199. * @param parent defines the object to serialize in
  68200. * @returns the serialized object
  68201. */
  68202. serialize(parent: any): any;
  68203. }
  68204. /**
  68205. * This defines an action responsible to trigger several actions once triggered.
  68206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68207. */
  68208. export class CombineAction extends Action {
  68209. /**
  68210. * The list of aggregated animations to run.
  68211. */
  68212. children: Action[];
  68213. /**
  68214. * Instantiate the action
  68215. * @param triggerOptions defines the trigger options
  68216. * @param children defines the list of aggregated animations to run
  68217. * @param condition defines the trigger related conditions
  68218. */
  68219. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68220. /** @hidden */
  68221. _prepare(): void;
  68222. /**
  68223. * Execute the action and executes all the aggregated actions.
  68224. */
  68225. execute(evt: ActionEvent): void;
  68226. /**
  68227. * Serializes the actions and its related information.
  68228. * @param parent defines the object to serialize in
  68229. * @returns the serialized object
  68230. */
  68231. serialize(parent: any): any;
  68232. }
  68233. /**
  68234. * This defines an action responsible to run code (external event) once triggered.
  68235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68236. */
  68237. export class ExecuteCodeAction extends Action {
  68238. /**
  68239. * The callback function to run.
  68240. */
  68241. func: (evt: ActionEvent) => void;
  68242. /**
  68243. * Instantiate the action
  68244. * @param triggerOptions defines the trigger options
  68245. * @param func defines the callback function to run
  68246. * @param condition defines the trigger related conditions
  68247. */
  68248. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68249. /**
  68250. * Execute the action and run the attached code.
  68251. */
  68252. execute(evt: ActionEvent): void;
  68253. }
  68254. /**
  68255. * This defines an action responsible to set the parent property of the target once triggered.
  68256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68257. */
  68258. export class SetParentAction extends Action {
  68259. private _parent;
  68260. private _target;
  68261. /**
  68262. * Instantiate the action
  68263. * @param triggerOptions defines the trigger options
  68264. * @param target defines the target containing the parent property
  68265. * @param parent defines from where the animation should start (animation frame)
  68266. * @param condition defines the trigger related conditions
  68267. */
  68268. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68269. /** @hidden */
  68270. _prepare(): void;
  68271. /**
  68272. * Execute the action and set the parent property.
  68273. */
  68274. execute(): void;
  68275. /**
  68276. * Serializes the actions and its related information.
  68277. * @param parent defines the object to serialize in
  68278. * @returns the serialized object
  68279. */
  68280. serialize(parent: any): any;
  68281. }
  68282. }
  68283. declare module BABYLON {
  68284. /**
  68285. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68286. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68288. */
  68289. export class ActionManager extends AbstractActionManager {
  68290. /**
  68291. * Nothing
  68292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68293. */
  68294. static readonly NothingTrigger: number;
  68295. /**
  68296. * On pick
  68297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68298. */
  68299. static readonly OnPickTrigger: number;
  68300. /**
  68301. * On left pick
  68302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68303. */
  68304. static readonly OnLeftPickTrigger: number;
  68305. /**
  68306. * On right pick
  68307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68308. */
  68309. static readonly OnRightPickTrigger: number;
  68310. /**
  68311. * On center pick
  68312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68313. */
  68314. static readonly OnCenterPickTrigger: number;
  68315. /**
  68316. * On pick down
  68317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68318. */
  68319. static readonly OnPickDownTrigger: number;
  68320. /**
  68321. * On double pick
  68322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68323. */
  68324. static readonly OnDoublePickTrigger: number;
  68325. /**
  68326. * On pick up
  68327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68328. */
  68329. static readonly OnPickUpTrigger: number;
  68330. /**
  68331. * On pick out.
  68332. * This trigger will only be raised if you also declared a OnPickDown
  68333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68334. */
  68335. static readonly OnPickOutTrigger: number;
  68336. /**
  68337. * On long press
  68338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68339. */
  68340. static readonly OnLongPressTrigger: number;
  68341. /**
  68342. * On pointer over
  68343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68344. */
  68345. static readonly OnPointerOverTrigger: number;
  68346. /**
  68347. * On pointer out
  68348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68349. */
  68350. static readonly OnPointerOutTrigger: number;
  68351. /**
  68352. * On every frame
  68353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68354. */
  68355. static readonly OnEveryFrameTrigger: number;
  68356. /**
  68357. * On intersection enter
  68358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68359. */
  68360. static readonly OnIntersectionEnterTrigger: number;
  68361. /**
  68362. * On intersection exit
  68363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68364. */
  68365. static readonly OnIntersectionExitTrigger: number;
  68366. /**
  68367. * On key down
  68368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68369. */
  68370. static readonly OnKeyDownTrigger: number;
  68371. /**
  68372. * On key up
  68373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68374. */
  68375. static readonly OnKeyUpTrigger: number;
  68376. private _scene;
  68377. /**
  68378. * Creates a new action manager
  68379. * @param scene defines the hosting scene
  68380. */
  68381. constructor(scene: Scene);
  68382. /**
  68383. * Releases all associated resources
  68384. */
  68385. dispose(): void;
  68386. /**
  68387. * Gets hosting scene
  68388. * @returns the hosting scene
  68389. */
  68390. getScene(): Scene;
  68391. /**
  68392. * Does this action manager handles actions of any of the given triggers
  68393. * @param triggers defines the triggers to be tested
  68394. * @return a boolean indicating whether one (or more) of the triggers is handled
  68395. */
  68396. hasSpecificTriggers(triggers: number[]): boolean;
  68397. /**
  68398. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68399. * speed.
  68400. * @param triggerA defines the trigger to be tested
  68401. * @param triggerB defines the trigger to be tested
  68402. * @return a boolean indicating whether one (or more) of the triggers is handled
  68403. */
  68404. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68405. /**
  68406. * Does this action manager handles actions of a given trigger
  68407. * @param trigger defines the trigger to be tested
  68408. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68409. * @return whether the trigger is handled
  68410. */
  68411. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68412. /**
  68413. * Does this action manager has pointer triggers
  68414. */
  68415. readonly hasPointerTriggers: boolean;
  68416. /**
  68417. * Does this action manager has pick triggers
  68418. */
  68419. readonly hasPickTriggers: boolean;
  68420. /**
  68421. * Registers an action to this action manager
  68422. * @param action defines the action to be registered
  68423. * @return the action amended (prepared) after registration
  68424. */
  68425. registerAction(action: IAction): Nullable<IAction>;
  68426. /**
  68427. * Unregisters an action to this action manager
  68428. * @param action defines the action to be unregistered
  68429. * @return a boolean indicating whether the action has been unregistered
  68430. */
  68431. unregisterAction(action: IAction): Boolean;
  68432. /**
  68433. * Process a specific trigger
  68434. * @param trigger defines the trigger to process
  68435. * @param evt defines the event details to be processed
  68436. */
  68437. processTrigger(trigger: number, evt?: IActionEvent): void;
  68438. /** @hidden */
  68439. _getEffectiveTarget(target: any, propertyPath: string): any;
  68440. /** @hidden */
  68441. _getProperty(propertyPath: string): string;
  68442. /**
  68443. * Serialize this manager to a JSON object
  68444. * @param name defines the property name to store this manager
  68445. * @returns a JSON representation of this manager
  68446. */
  68447. serialize(name: string): any;
  68448. /**
  68449. * Creates a new ActionManager from a JSON data
  68450. * @param parsedActions defines the JSON data to read from
  68451. * @param object defines the hosting mesh
  68452. * @param scene defines the hosting scene
  68453. */
  68454. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68455. /**
  68456. * Get a trigger name by index
  68457. * @param trigger defines the trigger index
  68458. * @returns a trigger name
  68459. */
  68460. static GetTriggerName(trigger: number): string;
  68461. }
  68462. }
  68463. declare module BABYLON {
  68464. /**
  68465. * Class representing a ray with position and direction
  68466. */
  68467. export class Ray {
  68468. /** origin point */
  68469. origin: Vector3;
  68470. /** direction */
  68471. direction: Vector3;
  68472. /** length of the ray */
  68473. length: number;
  68474. private static readonly TmpVector3;
  68475. private _tmpRay;
  68476. /**
  68477. * Creates a new ray
  68478. * @param origin origin point
  68479. * @param direction direction
  68480. * @param length length of the ray
  68481. */
  68482. constructor(
  68483. /** origin point */
  68484. origin: Vector3,
  68485. /** direction */
  68486. direction: Vector3,
  68487. /** length of the ray */
  68488. length?: number);
  68489. /**
  68490. * Checks if the ray intersects a box
  68491. * @param minimum bound of the box
  68492. * @param maximum bound of the box
  68493. * @param intersectionTreshold extra extend to be added to the box in all direction
  68494. * @returns if the box was hit
  68495. */
  68496. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68497. /**
  68498. * Checks if the ray intersects a box
  68499. * @param box the bounding box to check
  68500. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68501. * @returns if the box was hit
  68502. */
  68503. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68504. /**
  68505. * If the ray hits a sphere
  68506. * @param sphere the bounding sphere to check
  68507. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68508. * @returns true if it hits the sphere
  68509. */
  68510. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68511. /**
  68512. * If the ray hits a triange
  68513. * @param vertex0 triangle vertex
  68514. * @param vertex1 triangle vertex
  68515. * @param vertex2 triangle vertex
  68516. * @returns intersection information if hit
  68517. */
  68518. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68519. /**
  68520. * Checks if ray intersects a plane
  68521. * @param plane the plane to check
  68522. * @returns the distance away it was hit
  68523. */
  68524. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68525. /**
  68526. * Checks if ray intersects a mesh
  68527. * @param mesh the mesh to check
  68528. * @param fastCheck if only the bounding box should checked
  68529. * @returns picking info of the intersecton
  68530. */
  68531. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68532. /**
  68533. * Checks if ray intersects a mesh
  68534. * @param meshes the meshes to check
  68535. * @param fastCheck if only the bounding box should checked
  68536. * @param results array to store result in
  68537. * @returns Array of picking infos
  68538. */
  68539. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68540. private _comparePickingInfo;
  68541. private static smallnum;
  68542. private static rayl;
  68543. /**
  68544. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68545. * @param sega the first point of the segment to test the intersection against
  68546. * @param segb the second point of the segment to test the intersection against
  68547. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68548. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68549. */
  68550. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68551. /**
  68552. * Update the ray from viewport position
  68553. * @param x position
  68554. * @param y y position
  68555. * @param viewportWidth viewport width
  68556. * @param viewportHeight viewport height
  68557. * @param world world matrix
  68558. * @param view view matrix
  68559. * @param projection projection matrix
  68560. * @returns this ray updated
  68561. */
  68562. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68563. /**
  68564. * Creates a ray with origin and direction of 0,0,0
  68565. * @returns the new ray
  68566. */
  68567. static Zero(): Ray;
  68568. /**
  68569. * Creates a new ray from screen space and viewport
  68570. * @param x position
  68571. * @param y y position
  68572. * @param viewportWidth viewport width
  68573. * @param viewportHeight viewport height
  68574. * @param world world matrix
  68575. * @param view view matrix
  68576. * @param projection projection matrix
  68577. * @returns new ray
  68578. */
  68579. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68580. /**
  68581. * 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
  68582. * transformed to the given world matrix.
  68583. * @param origin The origin point
  68584. * @param end The end point
  68585. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68586. * @returns the new ray
  68587. */
  68588. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68589. /**
  68590. * Transforms a ray by a matrix
  68591. * @param ray ray to transform
  68592. * @param matrix matrix to apply
  68593. * @returns the resulting new ray
  68594. */
  68595. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68596. /**
  68597. * Transforms a ray by a matrix
  68598. * @param ray ray to transform
  68599. * @param matrix matrix to apply
  68600. * @param result ray to store result in
  68601. */
  68602. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68603. /**
  68604. * Unproject a ray from screen space to object space
  68605. * @param sourceX defines the screen space x coordinate to use
  68606. * @param sourceY defines the screen space y coordinate to use
  68607. * @param viewportWidth defines the current width of the viewport
  68608. * @param viewportHeight defines the current height of the viewport
  68609. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68610. * @param view defines the view matrix to use
  68611. * @param projection defines the projection matrix to use
  68612. */
  68613. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68614. }
  68615. /**
  68616. * Type used to define predicate used to select faces when a mesh intersection is detected
  68617. */
  68618. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68619. interface Scene {
  68620. /** @hidden */
  68621. _tempPickingRay: Nullable<Ray>;
  68622. /** @hidden */
  68623. _cachedRayForTransform: Ray;
  68624. /** @hidden */
  68625. _pickWithRayInverseMatrix: Matrix;
  68626. /** @hidden */
  68627. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68628. /** @hidden */
  68629. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68630. }
  68631. }
  68632. declare module BABYLON {
  68633. /**
  68634. * Groups all the scene component constants in one place to ease maintenance.
  68635. * @hidden
  68636. */
  68637. export class SceneComponentConstants {
  68638. static readonly NAME_EFFECTLAYER: string;
  68639. static readonly NAME_LAYER: string;
  68640. static readonly NAME_LENSFLARESYSTEM: string;
  68641. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68642. static readonly NAME_PARTICLESYSTEM: string;
  68643. static readonly NAME_GAMEPAD: string;
  68644. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68645. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68646. static readonly NAME_DEPTHRENDERER: string;
  68647. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68648. static readonly NAME_SPRITE: string;
  68649. static readonly NAME_OUTLINERENDERER: string;
  68650. static readonly NAME_PROCEDURALTEXTURE: string;
  68651. static readonly NAME_SHADOWGENERATOR: string;
  68652. static readonly NAME_OCTREE: string;
  68653. static readonly NAME_PHYSICSENGINE: string;
  68654. static readonly NAME_AUDIO: string;
  68655. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68656. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68657. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68658. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68659. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68660. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68661. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68662. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68663. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68664. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68665. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68666. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68667. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68668. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68669. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68670. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68671. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68672. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68673. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68674. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68675. static readonly STEP_AFTERRENDER_AUDIO: number;
  68676. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68677. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68678. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68679. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68680. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68681. static readonly STEP_POINTERMOVE_SPRITE: number;
  68682. static readonly STEP_POINTERDOWN_SPRITE: number;
  68683. static readonly STEP_POINTERUP_SPRITE: number;
  68684. }
  68685. /**
  68686. * This represents a scene component.
  68687. *
  68688. * This is used to decouple the dependency the scene is having on the different workloads like
  68689. * layers, post processes...
  68690. */
  68691. export interface ISceneComponent {
  68692. /**
  68693. * The name of the component. Each component must have a unique name.
  68694. */
  68695. name: string;
  68696. /**
  68697. * The scene the component belongs to.
  68698. */
  68699. scene: Scene;
  68700. /**
  68701. * Register the component to one instance of a scene.
  68702. */
  68703. register(): void;
  68704. /**
  68705. * Rebuilds the elements related to this component in case of
  68706. * context lost for instance.
  68707. */
  68708. rebuild(): void;
  68709. /**
  68710. * Disposes the component and the associated ressources.
  68711. */
  68712. dispose(): void;
  68713. }
  68714. /**
  68715. * This represents a SERIALIZABLE scene component.
  68716. *
  68717. * This extends Scene Component to add Serialization methods on top.
  68718. */
  68719. export interface ISceneSerializableComponent extends ISceneComponent {
  68720. /**
  68721. * Adds all the element from the container to the scene
  68722. * @param container the container holding the elements
  68723. */
  68724. addFromContainer(container: AbstractScene): void;
  68725. /**
  68726. * Removes all the elements in the container from the scene
  68727. * @param container contains the elements to remove
  68728. */
  68729. removeFromContainer(container: AbstractScene): void;
  68730. /**
  68731. * Serializes the component data to the specified json object
  68732. * @param serializationObject The object to serialize to
  68733. */
  68734. serialize(serializationObject: any): void;
  68735. }
  68736. /**
  68737. * Strong typing of a Mesh related stage step action
  68738. */
  68739. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68740. /**
  68741. * Strong typing of a Evaluate Sub Mesh related stage step action
  68742. */
  68743. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68744. /**
  68745. * Strong typing of a Active Mesh related stage step action
  68746. */
  68747. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68748. /**
  68749. * Strong typing of a Camera related stage step action
  68750. */
  68751. export type CameraStageAction = (camera: Camera) => void;
  68752. /**
  68753. * Strong typing of a Render Target related stage step action
  68754. */
  68755. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68756. /**
  68757. * Strong typing of a RenderingGroup related stage step action
  68758. */
  68759. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68760. /**
  68761. * Strong typing of a Mesh Render related stage step action
  68762. */
  68763. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68764. /**
  68765. * Strong typing of a simple stage step action
  68766. */
  68767. export type SimpleStageAction = () => void;
  68768. /**
  68769. * Strong typing of a render target action.
  68770. */
  68771. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68772. /**
  68773. * Strong typing of a pointer move action.
  68774. */
  68775. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68776. /**
  68777. * Strong typing of a pointer up/down action.
  68778. */
  68779. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68780. /**
  68781. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68782. * @hidden
  68783. */
  68784. export class Stage<T extends Function> extends Array<{
  68785. index: number;
  68786. component: ISceneComponent;
  68787. action: T;
  68788. }> {
  68789. /**
  68790. * Hide ctor from the rest of the world.
  68791. * @param items The items to add.
  68792. */
  68793. private constructor();
  68794. /**
  68795. * Creates a new Stage.
  68796. * @returns A new instance of a Stage
  68797. */
  68798. static Create<T extends Function>(): Stage<T>;
  68799. /**
  68800. * Registers a step in an ordered way in the targeted stage.
  68801. * @param index Defines the position to register the step in
  68802. * @param component Defines the component attached to the step
  68803. * @param action Defines the action to launch during the step
  68804. */
  68805. registerStep(index: number, component: ISceneComponent, action: T): void;
  68806. /**
  68807. * Clears all the steps from the stage.
  68808. */
  68809. clear(): void;
  68810. }
  68811. }
  68812. declare module BABYLON {
  68813. interface Scene {
  68814. /** @hidden */
  68815. _pointerOverSprite: Nullable<Sprite>;
  68816. /** @hidden */
  68817. _pickedDownSprite: Nullable<Sprite>;
  68818. /** @hidden */
  68819. _tempSpritePickingRay: Nullable<Ray>;
  68820. /**
  68821. * All of the sprite managers added to this scene
  68822. * @see http://doc.babylonjs.com/babylon101/sprites
  68823. */
  68824. spriteManagers: Array<ISpriteManager>;
  68825. /**
  68826. * An event triggered when sprites rendering is about to start
  68827. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68828. */
  68829. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68830. /**
  68831. * An event triggered when sprites rendering is done
  68832. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68833. */
  68834. onAfterSpritesRenderingObservable: Observable<Scene>;
  68835. /** @hidden */
  68836. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68837. /** Launch a ray to try to pick a sprite in the scene
  68838. * @param x position on screen
  68839. * @param y position on screen
  68840. * @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
  68841. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68842. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68843. * @returns a PickingInfo
  68844. */
  68845. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68846. /** Use the given ray to pick a sprite in the scene
  68847. * @param ray The ray (in world space) to use to pick meshes
  68848. * @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
  68849. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68850. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68851. * @returns a PickingInfo
  68852. */
  68853. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68854. /**
  68855. * Force the sprite under the pointer
  68856. * @param sprite defines the sprite to use
  68857. */
  68858. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68859. /**
  68860. * Gets the sprite under the pointer
  68861. * @returns a Sprite or null if no sprite is under the pointer
  68862. */
  68863. getPointerOverSprite(): Nullable<Sprite>;
  68864. }
  68865. /**
  68866. * Defines the sprite scene component responsible to manage sprites
  68867. * in a given scene.
  68868. */
  68869. export class SpriteSceneComponent implements ISceneComponent {
  68870. /**
  68871. * The component name helpfull to identify the component in the list of scene components.
  68872. */
  68873. readonly name: string;
  68874. /**
  68875. * The scene the component belongs to.
  68876. */
  68877. scene: Scene;
  68878. /** @hidden */
  68879. private _spritePredicate;
  68880. /**
  68881. * Creates a new instance of the component for the given scene
  68882. * @param scene Defines the scene to register the component in
  68883. */
  68884. constructor(scene: Scene);
  68885. /**
  68886. * Registers the component in a given scene
  68887. */
  68888. register(): void;
  68889. /**
  68890. * Rebuilds the elements related to this component in case of
  68891. * context lost for instance.
  68892. */
  68893. rebuild(): void;
  68894. /**
  68895. * Disposes the component and the associated ressources.
  68896. */
  68897. dispose(): void;
  68898. private _pickSpriteButKeepRay;
  68899. private _pointerMove;
  68900. private _pointerDown;
  68901. private _pointerUp;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /** @hidden */
  68906. export var fogFragmentDeclaration: {
  68907. name: string;
  68908. shader: string;
  68909. };
  68910. }
  68911. declare module BABYLON {
  68912. /** @hidden */
  68913. export var fogFragment: {
  68914. name: string;
  68915. shader: string;
  68916. };
  68917. }
  68918. declare module BABYLON {
  68919. /** @hidden */
  68920. export var spritesPixelShader: {
  68921. name: string;
  68922. shader: string;
  68923. };
  68924. }
  68925. declare module BABYLON {
  68926. /** @hidden */
  68927. export var fogVertexDeclaration: {
  68928. name: string;
  68929. shader: string;
  68930. };
  68931. }
  68932. declare module BABYLON {
  68933. /** @hidden */
  68934. export var spritesVertexShader: {
  68935. name: string;
  68936. shader: string;
  68937. };
  68938. }
  68939. declare module BABYLON {
  68940. /**
  68941. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68942. */
  68943. export interface ISpriteManager extends IDisposable {
  68944. /**
  68945. * Restricts the camera to viewing objects with the same layerMask.
  68946. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68947. */
  68948. layerMask: number;
  68949. /**
  68950. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68951. */
  68952. isPickable: boolean;
  68953. /**
  68954. * Specifies the rendering group id for this mesh (0 by default)
  68955. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68956. */
  68957. renderingGroupId: number;
  68958. /**
  68959. * Defines the list of sprites managed by the manager.
  68960. */
  68961. sprites: Array<Sprite>;
  68962. /**
  68963. * Tests the intersection of a sprite with a specific ray.
  68964. * @param ray The ray we are sending to test the collision
  68965. * @param camera The camera space we are sending rays in
  68966. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68967. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68968. * @returns picking info or null.
  68969. */
  68970. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68971. /**
  68972. * Renders the list of sprites on screen.
  68973. */
  68974. render(): void;
  68975. }
  68976. /**
  68977. * Class used to manage multiple sprites on the same spritesheet
  68978. * @see http://doc.babylonjs.com/babylon101/sprites
  68979. */
  68980. export class SpriteManager implements ISpriteManager {
  68981. /** defines the manager's name */
  68982. name: string;
  68983. /** Gets the list of sprites */
  68984. sprites: Sprite[];
  68985. /** Gets or sets the rendering group id (0 by default) */
  68986. renderingGroupId: number;
  68987. /** Gets or sets camera layer mask */
  68988. layerMask: number;
  68989. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68990. fogEnabled: boolean;
  68991. /** Gets or sets a boolean indicating if the sprites are pickable */
  68992. isPickable: boolean;
  68993. /** Defines the default width of a cell in the spritesheet */
  68994. cellWidth: number;
  68995. /** Defines the default height of a cell in the spritesheet */
  68996. cellHeight: number;
  68997. /**
  68998. * An event triggered when the manager is disposed.
  68999. */
  69000. onDisposeObservable: Observable<SpriteManager>;
  69001. private _onDisposeObserver;
  69002. /**
  69003. * Callback called when the manager is disposed
  69004. */
  69005. onDispose: () => void;
  69006. private _capacity;
  69007. private _spriteTexture;
  69008. private _epsilon;
  69009. private _scene;
  69010. private _vertexData;
  69011. private _buffer;
  69012. private _vertexBuffers;
  69013. private _indexBuffer;
  69014. private _effectBase;
  69015. private _effectFog;
  69016. /**
  69017. * Gets or sets the spritesheet texture
  69018. */
  69019. texture: Texture;
  69020. /**
  69021. * Creates a new sprite manager
  69022. * @param name defines the manager's name
  69023. * @param imgUrl defines the sprite sheet url
  69024. * @param capacity defines the maximum allowed number of sprites
  69025. * @param cellSize defines the size of a sprite cell
  69026. * @param scene defines the hosting scene
  69027. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69028. * @param samplingMode defines the smapling mode to use with spritesheet
  69029. */
  69030. constructor(
  69031. /** defines the manager's name */
  69032. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69033. private _appendSpriteVertex;
  69034. /**
  69035. * Intersects the sprites with a ray
  69036. * @param ray defines the ray to intersect with
  69037. * @param camera defines the current active camera
  69038. * @param predicate defines a predicate used to select candidate sprites
  69039. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69040. * @returns null if no hit or a PickingInfo
  69041. */
  69042. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69043. /**
  69044. * Render all child sprites
  69045. */
  69046. render(): void;
  69047. /**
  69048. * Release associated resources
  69049. */
  69050. dispose(): void;
  69051. }
  69052. }
  69053. declare module BABYLON {
  69054. /**
  69055. * Class used to represent a sprite
  69056. * @see http://doc.babylonjs.com/babylon101/sprites
  69057. */
  69058. export class Sprite {
  69059. /** defines the name */
  69060. name: string;
  69061. /** Gets or sets the current world position */
  69062. position: Vector3;
  69063. /** Gets or sets the main color */
  69064. color: Color4;
  69065. /** Gets or sets the width */
  69066. width: number;
  69067. /** Gets or sets the height */
  69068. height: number;
  69069. /** Gets or sets rotation angle */
  69070. angle: number;
  69071. /** Gets or sets the cell index in the sprite sheet */
  69072. cellIndex: number;
  69073. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69074. invertU: number;
  69075. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69076. invertV: number;
  69077. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69078. disposeWhenFinishedAnimating: boolean;
  69079. /** Gets the list of attached animations */
  69080. animations: Animation[];
  69081. /** Gets or sets a boolean indicating if the sprite can be picked */
  69082. isPickable: boolean;
  69083. /**
  69084. * Gets or sets the associated action manager
  69085. */
  69086. actionManager: Nullable<ActionManager>;
  69087. private _animationStarted;
  69088. private _loopAnimation;
  69089. private _fromIndex;
  69090. private _toIndex;
  69091. private _delay;
  69092. private _direction;
  69093. private _manager;
  69094. private _time;
  69095. private _onAnimationEnd;
  69096. /**
  69097. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69098. */
  69099. isVisible: boolean;
  69100. /**
  69101. * Gets or sets the sprite size
  69102. */
  69103. size: number;
  69104. /**
  69105. * Creates a new Sprite
  69106. * @param name defines the name
  69107. * @param manager defines the manager
  69108. */
  69109. constructor(
  69110. /** defines the name */
  69111. name: string, manager: ISpriteManager);
  69112. /**
  69113. * Starts an animation
  69114. * @param from defines the initial key
  69115. * @param to defines the end key
  69116. * @param loop defines if the animation must loop
  69117. * @param delay defines the start delay (in ms)
  69118. * @param onAnimationEnd defines a callback to call when animation ends
  69119. */
  69120. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69121. /** Stops current animation (if any) */
  69122. stopAnimation(): void;
  69123. /** @hidden */
  69124. _animate(deltaTime: number): void;
  69125. /** Release associated resources */
  69126. dispose(): void;
  69127. }
  69128. }
  69129. declare module BABYLON {
  69130. /**
  69131. * Information about the result of picking within a scene
  69132. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69133. */
  69134. export class PickingInfo {
  69135. /** @hidden */
  69136. _pickingUnavailable: boolean;
  69137. /**
  69138. * If the pick collided with an object
  69139. */
  69140. hit: boolean;
  69141. /**
  69142. * Distance away where the pick collided
  69143. */
  69144. distance: number;
  69145. /**
  69146. * The location of pick collision
  69147. */
  69148. pickedPoint: Nullable<Vector3>;
  69149. /**
  69150. * The mesh corresponding the the pick collision
  69151. */
  69152. pickedMesh: Nullable<AbstractMesh>;
  69153. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69154. bu: number;
  69155. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69156. bv: number;
  69157. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69158. faceId: number;
  69159. /** Id of the the submesh that was picked */
  69160. subMeshId: number;
  69161. /** If a sprite was picked, this will be the sprite the pick collided with */
  69162. pickedSprite: Nullable<Sprite>;
  69163. /**
  69164. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69165. */
  69166. originMesh: Nullable<AbstractMesh>;
  69167. /**
  69168. * The ray that was used to perform the picking.
  69169. */
  69170. ray: Nullable<Ray>;
  69171. /**
  69172. * Gets the normal correspodning to the face the pick collided with
  69173. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69174. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69175. * @returns The normal correspodning to the face the pick collided with
  69176. */
  69177. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69178. /**
  69179. * Gets the texture coordinates of where the pick occured
  69180. * @returns the vector containing the coordnates of the texture
  69181. */
  69182. getTextureCoordinates(): Nullable<Vector2>;
  69183. }
  69184. }
  69185. declare module BABYLON {
  69186. /**
  69187. * Gather the list of pointer event types as constants.
  69188. */
  69189. export class PointerEventTypes {
  69190. /**
  69191. * 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.
  69192. */
  69193. static readonly POINTERDOWN: number;
  69194. /**
  69195. * The pointerup event is fired when a pointer is no longer active.
  69196. */
  69197. static readonly POINTERUP: number;
  69198. /**
  69199. * The pointermove event is fired when a pointer changes coordinates.
  69200. */
  69201. static readonly POINTERMOVE: number;
  69202. /**
  69203. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69204. */
  69205. static readonly POINTERWHEEL: number;
  69206. /**
  69207. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69208. */
  69209. static readonly POINTERPICK: number;
  69210. /**
  69211. * The pointertap event is fired when a the object has been touched and released without drag.
  69212. */
  69213. static readonly POINTERTAP: number;
  69214. /**
  69215. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69216. */
  69217. static readonly POINTERDOUBLETAP: number;
  69218. }
  69219. /**
  69220. * Base class of pointer info types.
  69221. */
  69222. export class PointerInfoBase {
  69223. /**
  69224. * Defines the type of event (PointerEventTypes)
  69225. */
  69226. type: number;
  69227. /**
  69228. * Defines the related dom event
  69229. */
  69230. event: PointerEvent | MouseWheelEvent;
  69231. /**
  69232. * Instantiates the base class of pointers info.
  69233. * @param type Defines the type of event (PointerEventTypes)
  69234. * @param event Defines the related dom event
  69235. */
  69236. constructor(
  69237. /**
  69238. * Defines the type of event (PointerEventTypes)
  69239. */
  69240. type: number,
  69241. /**
  69242. * Defines the related dom event
  69243. */
  69244. event: PointerEvent | MouseWheelEvent);
  69245. }
  69246. /**
  69247. * This class is used to store pointer related info for the onPrePointerObservable event.
  69248. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69249. */
  69250. export class PointerInfoPre extends PointerInfoBase {
  69251. /**
  69252. * Ray from a pointer if availible (eg. 6dof controller)
  69253. */
  69254. ray: Nullable<Ray>;
  69255. /**
  69256. * Defines the local position of the pointer on the canvas.
  69257. */
  69258. localPosition: Vector2;
  69259. /**
  69260. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69261. */
  69262. skipOnPointerObservable: boolean;
  69263. /**
  69264. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69265. * @param type Defines the type of event (PointerEventTypes)
  69266. * @param event Defines the related dom event
  69267. * @param localX Defines the local x coordinates of the pointer when the event occured
  69268. * @param localY Defines the local y coordinates of the pointer when the event occured
  69269. */
  69270. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69271. }
  69272. /**
  69273. * This type contains all the data related to a pointer event in Babylon.js.
  69274. * 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.
  69275. */
  69276. export class PointerInfo extends PointerInfoBase {
  69277. /**
  69278. * Defines the picking info associated to the info (if any)\
  69279. */
  69280. pickInfo: Nullable<PickingInfo>;
  69281. /**
  69282. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69283. * @param type Defines the type of event (PointerEventTypes)
  69284. * @param event Defines the related dom event
  69285. * @param pickInfo Defines the picking info associated to the info (if any)\
  69286. */
  69287. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69288. /**
  69289. * Defines the picking info associated to the info (if any)\
  69290. */
  69291. pickInfo: Nullable<PickingInfo>);
  69292. }
  69293. /**
  69294. * Data relating to a touch event on the screen.
  69295. */
  69296. export interface PointerTouch {
  69297. /**
  69298. * X coordinate of touch.
  69299. */
  69300. x: number;
  69301. /**
  69302. * Y coordinate of touch.
  69303. */
  69304. y: number;
  69305. /**
  69306. * Id of touch. Unique for each finger.
  69307. */
  69308. pointerId: number;
  69309. /**
  69310. * Event type passed from DOM.
  69311. */
  69312. type: any;
  69313. }
  69314. }
  69315. declare module BABYLON {
  69316. /**
  69317. * Manage the mouse inputs to control the movement of a free camera.
  69318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69319. */
  69320. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69321. /**
  69322. * Define if touch is enabled in the mouse input
  69323. */
  69324. touchEnabled: boolean;
  69325. /**
  69326. * Defines the camera the input is attached to.
  69327. */
  69328. camera: FreeCamera;
  69329. /**
  69330. * Defines the buttons associated with the input to handle camera move.
  69331. */
  69332. buttons: number[];
  69333. /**
  69334. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69335. */
  69336. angularSensibility: number;
  69337. private _pointerInput;
  69338. private _onMouseMove;
  69339. private _observer;
  69340. private previousPosition;
  69341. /**
  69342. * Manage the mouse inputs to control the movement of a free camera.
  69343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69344. * @param touchEnabled Defines if touch is enabled or not
  69345. */
  69346. constructor(
  69347. /**
  69348. * Define if touch is enabled in the mouse input
  69349. */
  69350. touchEnabled?: boolean);
  69351. /**
  69352. * Attach the input controls to a specific dom element to get the input from.
  69353. * @param element Defines the element the controls should be listened from
  69354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69355. */
  69356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69357. /**
  69358. * Detach the current controls from the specified dom element.
  69359. * @param element Defines the element to stop listening the inputs from
  69360. */
  69361. detachControl(element: Nullable<HTMLElement>): void;
  69362. /**
  69363. * Gets the class name of the current intput.
  69364. * @returns the class name
  69365. */
  69366. getClassName(): string;
  69367. /**
  69368. * Get the friendly name associated with the input class.
  69369. * @returns the input friendly name
  69370. */
  69371. getSimpleName(): string;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /**
  69376. * Manage the touch inputs to control the movement of a free camera.
  69377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69378. */
  69379. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69380. /**
  69381. * Defines the camera the input is attached to.
  69382. */
  69383. camera: FreeCamera;
  69384. /**
  69385. * Defines the touch sensibility for rotation.
  69386. * The higher the faster.
  69387. */
  69388. touchAngularSensibility: number;
  69389. /**
  69390. * Defines the touch sensibility for move.
  69391. * The higher the faster.
  69392. */
  69393. touchMoveSensibility: number;
  69394. private _offsetX;
  69395. private _offsetY;
  69396. private _pointerPressed;
  69397. private _pointerInput;
  69398. private _observer;
  69399. private _onLostFocus;
  69400. /**
  69401. * Attach the input controls to a specific dom element to get the input from.
  69402. * @param element Defines the element the controls should be listened from
  69403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69404. */
  69405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69406. /**
  69407. * Detach the current controls from the specified dom element.
  69408. * @param element Defines the element to stop listening the inputs from
  69409. */
  69410. detachControl(element: Nullable<HTMLElement>): void;
  69411. /**
  69412. * Update the current camera state depending on the inputs that have been used this frame.
  69413. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69414. */
  69415. checkInputs(): void;
  69416. /**
  69417. * Gets the class name of the current intput.
  69418. * @returns the class name
  69419. */
  69420. getClassName(): string;
  69421. /**
  69422. * Get the friendly name associated with the input class.
  69423. * @returns the input friendly name
  69424. */
  69425. getSimpleName(): string;
  69426. }
  69427. }
  69428. declare module BABYLON {
  69429. /**
  69430. * Default Inputs manager for the FreeCamera.
  69431. * It groups all the default supported inputs for ease of use.
  69432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69433. */
  69434. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69435. /**
  69436. * Instantiates a new FreeCameraInputsManager.
  69437. * @param camera Defines the camera the inputs belong to
  69438. */
  69439. constructor(camera: FreeCamera);
  69440. /**
  69441. * Add keyboard input support to the input manager.
  69442. * @returns the current input manager
  69443. */
  69444. addKeyboard(): FreeCameraInputsManager;
  69445. /**
  69446. * Add mouse input support to the input manager.
  69447. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69448. * @returns the current input manager
  69449. */
  69450. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69451. /**
  69452. * Add touch input support to the input manager.
  69453. * @returns the current input manager
  69454. */
  69455. addTouch(): FreeCameraInputsManager;
  69456. }
  69457. }
  69458. declare module BABYLON {
  69459. /**
  69460. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69461. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69462. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69463. */
  69464. export class FreeCamera extends TargetCamera {
  69465. /**
  69466. * Define the collision ellipsoid of the camera.
  69467. * This is helpful to simulate a camera body like the player body around the camera
  69468. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69469. */
  69470. ellipsoid: Vector3;
  69471. /**
  69472. * Define an offset for the position of the ellipsoid around the camera.
  69473. * This can be helpful to determine the center of the body near the gravity center of the body
  69474. * instead of its head.
  69475. */
  69476. ellipsoidOffset: Vector3;
  69477. /**
  69478. * Enable or disable collisions of the camera with the rest of the scene objects.
  69479. */
  69480. checkCollisions: boolean;
  69481. /**
  69482. * Enable or disable gravity on the camera.
  69483. */
  69484. applyGravity: boolean;
  69485. /**
  69486. * Define the input manager associated to the camera.
  69487. */
  69488. inputs: FreeCameraInputsManager;
  69489. /**
  69490. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69491. * Higher values reduce sensitivity.
  69492. */
  69493. /**
  69494. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69495. * Higher values reduce sensitivity.
  69496. */
  69497. angularSensibility: number;
  69498. /**
  69499. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69500. */
  69501. keysUp: number[];
  69502. /**
  69503. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69504. */
  69505. keysDown: number[];
  69506. /**
  69507. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69508. */
  69509. keysLeft: number[];
  69510. /**
  69511. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69512. */
  69513. keysRight: number[];
  69514. /**
  69515. * Event raised when the camera collide with a mesh in the scene.
  69516. */
  69517. onCollide: (collidedMesh: AbstractMesh) => void;
  69518. private _collider;
  69519. private _needMoveForGravity;
  69520. private _oldPosition;
  69521. private _diffPosition;
  69522. private _newPosition;
  69523. /** @hidden */
  69524. _localDirection: Vector3;
  69525. /** @hidden */
  69526. _transformedDirection: Vector3;
  69527. /**
  69528. * Instantiates a Free Camera.
  69529. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69530. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69531. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69532. * @param name Define the name of the camera in the scene
  69533. * @param position Define the start position of the camera in the scene
  69534. * @param scene Define the scene the camera belongs to
  69535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69536. */
  69537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69538. /**
  69539. * Attached controls to the current camera.
  69540. * @param element Defines the element the controls should be listened from
  69541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69542. */
  69543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69544. /**
  69545. * Detach the current controls from the camera.
  69546. * The camera will stop reacting to inputs.
  69547. * @param element Defines the element to stop listening the inputs from
  69548. */
  69549. detachControl(element: HTMLElement): void;
  69550. private _collisionMask;
  69551. /**
  69552. * Define a collision mask to limit the list of object the camera can collide with
  69553. */
  69554. collisionMask: number;
  69555. /** @hidden */
  69556. _collideWithWorld(displacement: Vector3): void;
  69557. private _onCollisionPositionChange;
  69558. /** @hidden */
  69559. _checkInputs(): void;
  69560. /** @hidden */
  69561. _decideIfNeedsToMove(): boolean;
  69562. /** @hidden */
  69563. _updatePosition(): void;
  69564. /**
  69565. * Destroy the camera and release the current resources hold by it.
  69566. */
  69567. dispose(): void;
  69568. /**
  69569. * Gets the current object class name.
  69570. * @return the class name
  69571. */
  69572. getClassName(): string;
  69573. }
  69574. }
  69575. declare module BABYLON {
  69576. /**
  69577. * Represents a gamepad control stick position
  69578. */
  69579. export class StickValues {
  69580. /**
  69581. * The x component of the control stick
  69582. */
  69583. x: number;
  69584. /**
  69585. * The y component of the control stick
  69586. */
  69587. y: number;
  69588. /**
  69589. * Initializes the gamepad x and y control stick values
  69590. * @param x The x component of the gamepad control stick value
  69591. * @param y The y component of the gamepad control stick value
  69592. */
  69593. constructor(
  69594. /**
  69595. * The x component of the control stick
  69596. */
  69597. x: number,
  69598. /**
  69599. * The y component of the control stick
  69600. */
  69601. y: number);
  69602. }
  69603. /**
  69604. * An interface which manages callbacks for gamepad button changes
  69605. */
  69606. export interface GamepadButtonChanges {
  69607. /**
  69608. * Called when a gamepad has been changed
  69609. */
  69610. changed: boolean;
  69611. /**
  69612. * Called when a gamepad press event has been triggered
  69613. */
  69614. pressChanged: boolean;
  69615. /**
  69616. * Called when a touch event has been triggered
  69617. */
  69618. touchChanged: boolean;
  69619. /**
  69620. * Called when a value has changed
  69621. */
  69622. valueChanged: boolean;
  69623. }
  69624. /**
  69625. * Represents a gamepad
  69626. */
  69627. export class Gamepad {
  69628. /**
  69629. * The id of the gamepad
  69630. */
  69631. id: string;
  69632. /**
  69633. * The index of the gamepad
  69634. */
  69635. index: number;
  69636. /**
  69637. * The browser gamepad
  69638. */
  69639. browserGamepad: any;
  69640. /**
  69641. * Specifies what type of gamepad this represents
  69642. */
  69643. type: number;
  69644. private _leftStick;
  69645. private _rightStick;
  69646. /** @hidden */
  69647. _isConnected: boolean;
  69648. private _leftStickAxisX;
  69649. private _leftStickAxisY;
  69650. private _rightStickAxisX;
  69651. private _rightStickAxisY;
  69652. /**
  69653. * Triggered when the left control stick has been changed
  69654. */
  69655. private _onleftstickchanged;
  69656. /**
  69657. * Triggered when the right control stick has been changed
  69658. */
  69659. private _onrightstickchanged;
  69660. /**
  69661. * Represents a gamepad controller
  69662. */
  69663. static GAMEPAD: number;
  69664. /**
  69665. * Represents a generic controller
  69666. */
  69667. static GENERIC: number;
  69668. /**
  69669. * Represents an XBox controller
  69670. */
  69671. static XBOX: number;
  69672. /**
  69673. * Represents a pose-enabled controller
  69674. */
  69675. static POSE_ENABLED: number;
  69676. /**
  69677. * Specifies whether the left control stick should be Y-inverted
  69678. */
  69679. protected _invertLeftStickY: boolean;
  69680. /**
  69681. * Specifies if the gamepad has been connected
  69682. */
  69683. readonly isConnected: boolean;
  69684. /**
  69685. * Initializes the gamepad
  69686. * @param id The id of the gamepad
  69687. * @param index The index of the gamepad
  69688. * @param browserGamepad The browser gamepad
  69689. * @param leftStickX The x component of the left joystick
  69690. * @param leftStickY The y component of the left joystick
  69691. * @param rightStickX The x component of the right joystick
  69692. * @param rightStickY The y component of the right joystick
  69693. */
  69694. constructor(
  69695. /**
  69696. * The id of the gamepad
  69697. */
  69698. id: string,
  69699. /**
  69700. * The index of the gamepad
  69701. */
  69702. index: number,
  69703. /**
  69704. * The browser gamepad
  69705. */
  69706. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69707. /**
  69708. * Callback triggered when the left joystick has changed
  69709. * @param callback
  69710. */
  69711. onleftstickchanged(callback: (values: StickValues) => void): void;
  69712. /**
  69713. * Callback triggered when the right joystick has changed
  69714. * @param callback
  69715. */
  69716. onrightstickchanged(callback: (values: StickValues) => void): void;
  69717. /**
  69718. * Gets the left joystick
  69719. */
  69720. /**
  69721. * Sets the left joystick values
  69722. */
  69723. leftStick: StickValues;
  69724. /**
  69725. * Gets the right joystick
  69726. */
  69727. /**
  69728. * Sets the right joystick value
  69729. */
  69730. rightStick: StickValues;
  69731. /**
  69732. * Updates the gamepad joystick positions
  69733. */
  69734. update(): void;
  69735. /**
  69736. * Disposes the gamepad
  69737. */
  69738. dispose(): void;
  69739. }
  69740. /**
  69741. * Represents a generic gamepad
  69742. */
  69743. export class GenericPad extends Gamepad {
  69744. private _buttons;
  69745. private _onbuttondown;
  69746. private _onbuttonup;
  69747. /**
  69748. * Observable triggered when a button has been pressed
  69749. */
  69750. onButtonDownObservable: Observable<number>;
  69751. /**
  69752. * Observable triggered when a button has been released
  69753. */
  69754. onButtonUpObservable: Observable<number>;
  69755. /**
  69756. * Callback triggered when a button has been pressed
  69757. * @param callback Called when a button has been pressed
  69758. */
  69759. onbuttondown(callback: (buttonPressed: number) => void): void;
  69760. /**
  69761. * Callback triggered when a button has been released
  69762. * @param callback Called when a button has been released
  69763. */
  69764. onbuttonup(callback: (buttonReleased: number) => void): void;
  69765. /**
  69766. * Initializes the generic gamepad
  69767. * @param id The id of the generic gamepad
  69768. * @param index The index of the generic gamepad
  69769. * @param browserGamepad The browser gamepad
  69770. */
  69771. constructor(id: string, index: number, browserGamepad: any);
  69772. private _setButtonValue;
  69773. /**
  69774. * Updates the generic gamepad
  69775. */
  69776. update(): void;
  69777. /**
  69778. * Disposes the generic gamepad
  69779. */
  69780. dispose(): void;
  69781. }
  69782. }
  69783. declare module BABYLON {
  69784. /**
  69785. * Defines the types of pose enabled controllers that are supported
  69786. */
  69787. export enum PoseEnabledControllerType {
  69788. /**
  69789. * HTC Vive
  69790. */
  69791. VIVE = 0,
  69792. /**
  69793. * Oculus Rift
  69794. */
  69795. OCULUS = 1,
  69796. /**
  69797. * Windows mixed reality
  69798. */
  69799. WINDOWS = 2,
  69800. /**
  69801. * Samsung gear VR
  69802. */
  69803. GEAR_VR = 3,
  69804. /**
  69805. * Google Daydream
  69806. */
  69807. DAYDREAM = 4,
  69808. /**
  69809. * Generic
  69810. */
  69811. GENERIC = 5
  69812. }
  69813. /**
  69814. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69815. */
  69816. export interface MutableGamepadButton {
  69817. /**
  69818. * Value of the button/trigger
  69819. */
  69820. value: number;
  69821. /**
  69822. * If the button/trigger is currently touched
  69823. */
  69824. touched: boolean;
  69825. /**
  69826. * If the button/trigger is currently pressed
  69827. */
  69828. pressed: boolean;
  69829. }
  69830. /**
  69831. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69832. * @hidden
  69833. */
  69834. export interface ExtendedGamepadButton extends GamepadButton {
  69835. /**
  69836. * If the button/trigger is currently pressed
  69837. */
  69838. readonly pressed: boolean;
  69839. /**
  69840. * If the button/trigger is currently touched
  69841. */
  69842. readonly touched: boolean;
  69843. /**
  69844. * Value of the button/trigger
  69845. */
  69846. readonly value: number;
  69847. }
  69848. /** @hidden */
  69849. export interface _GamePadFactory {
  69850. /**
  69851. * Returns wether or not the current gamepad can be created for this type of controller.
  69852. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69853. * @returns true if it can be created, otherwise false
  69854. */
  69855. canCreate(gamepadInfo: any): boolean;
  69856. /**
  69857. * Creates a new instance of the Gamepad.
  69858. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69859. * @returns the new gamepad instance
  69860. */
  69861. create(gamepadInfo: any): Gamepad;
  69862. }
  69863. /**
  69864. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69865. */
  69866. export class PoseEnabledControllerHelper {
  69867. /** @hidden */
  69868. static _ControllerFactories: _GamePadFactory[];
  69869. /** @hidden */
  69870. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69871. /**
  69872. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69873. * @param vrGamepad the gamepad to initialized
  69874. * @returns a vr controller of the type the gamepad identified as
  69875. */
  69876. static InitiateController(vrGamepad: any): Gamepad;
  69877. }
  69878. /**
  69879. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69880. */
  69881. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69882. private _deviceRoomPosition;
  69883. private _deviceRoomRotationQuaternion;
  69884. /**
  69885. * The device position in babylon space
  69886. */
  69887. devicePosition: Vector3;
  69888. /**
  69889. * The device rotation in babylon space
  69890. */
  69891. deviceRotationQuaternion: Quaternion;
  69892. /**
  69893. * The scale factor of the device in babylon space
  69894. */
  69895. deviceScaleFactor: number;
  69896. /**
  69897. * (Likely devicePosition should be used instead) The device position in its room space
  69898. */
  69899. position: Vector3;
  69900. /**
  69901. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69902. */
  69903. rotationQuaternion: Quaternion;
  69904. /**
  69905. * The type of controller (Eg. Windows mixed reality)
  69906. */
  69907. controllerType: PoseEnabledControllerType;
  69908. protected _calculatedPosition: Vector3;
  69909. private _calculatedRotation;
  69910. /**
  69911. * The raw pose from the device
  69912. */
  69913. rawPose: DevicePose;
  69914. private _trackPosition;
  69915. private _maxRotationDistFromHeadset;
  69916. private _draggedRoomRotation;
  69917. /**
  69918. * @hidden
  69919. */
  69920. _disableTrackPosition(fixedPosition: Vector3): void;
  69921. /**
  69922. * Internal, the mesh attached to the controller
  69923. * @hidden
  69924. */
  69925. _mesh: Nullable<AbstractMesh>;
  69926. private _poseControlledCamera;
  69927. private _leftHandSystemQuaternion;
  69928. /**
  69929. * Internal, matrix used to convert room space to babylon space
  69930. * @hidden
  69931. */
  69932. _deviceToWorld: Matrix;
  69933. /**
  69934. * Node to be used when casting a ray from the controller
  69935. * @hidden
  69936. */
  69937. _pointingPoseNode: Nullable<TransformNode>;
  69938. /**
  69939. * Name of the child mesh that can be used to cast a ray from the controller
  69940. */
  69941. static readonly POINTING_POSE: string;
  69942. /**
  69943. * Creates a new PoseEnabledController from a gamepad
  69944. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69945. */
  69946. constructor(browserGamepad: any);
  69947. private _workingMatrix;
  69948. /**
  69949. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69950. */
  69951. update(): void;
  69952. /**
  69953. * Updates only the pose device and mesh without doing any button event checking
  69954. */
  69955. protected _updatePoseAndMesh(): void;
  69956. /**
  69957. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69958. * @param poseData raw pose fromthe device
  69959. */
  69960. updateFromDevice(poseData: DevicePose): void;
  69961. /**
  69962. * @hidden
  69963. */
  69964. _meshAttachedObservable: Observable<AbstractMesh>;
  69965. /**
  69966. * Attaches a mesh to the controller
  69967. * @param mesh the mesh to be attached
  69968. */
  69969. attachToMesh(mesh: AbstractMesh): void;
  69970. /**
  69971. * Attaches the controllers mesh to a camera
  69972. * @param camera the camera the mesh should be attached to
  69973. */
  69974. attachToPoseControlledCamera(camera: TargetCamera): void;
  69975. /**
  69976. * Disposes of the controller
  69977. */
  69978. dispose(): void;
  69979. /**
  69980. * The mesh that is attached to the controller
  69981. */
  69982. readonly mesh: Nullable<AbstractMesh>;
  69983. /**
  69984. * Gets the ray of the controller in the direction the controller is pointing
  69985. * @param length the length the resulting ray should be
  69986. * @returns a ray in the direction the controller is pointing
  69987. */
  69988. getForwardRay(length?: number): Ray;
  69989. }
  69990. }
  69991. declare module BABYLON {
  69992. /**
  69993. * Defines the WebVRController object that represents controllers tracked in 3D space
  69994. */
  69995. export abstract class WebVRController extends PoseEnabledController {
  69996. /**
  69997. * Internal, the default controller model for the controller
  69998. */
  69999. protected _defaultModel: AbstractMesh;
  70000. /**
  70001. * Fired when the trigger state has changed
  70002. */
  70003. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70004. /**
  70005. * Fired when the main button state has changed
  70006. */
  70007. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70008. /**
  70009. * Fired when the secondary button state has changed
  70010. */
  70011. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70012. /**
  70013. * Fired when the pad state has changed
  70014. */
  70015. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70016. /**
  70017. * Fired when controllers stick values have changed
  70018. */
  70019. onPadValuesChangedObservable: Observable<StickValues>;
  70020. /**
  70021. * Array of button availible on the controller
  70022. */
  70023. protected _buttons: Array<MutableGamepadButton>;
  70024. private _onButtonStateChange;
  70025. /**
  70026. * Fired when a controller button's state has changed
  70027. * @param callback the callback containing the button that was modified
  70028. */
  70029. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70030. /**
  70031. * X and Y axis corrisponding to the controllers joystick
  70032. */
  70033. pad: StickValues;
  70034. /**
  70035. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70036. */
  70037. hand: string;
  70038. /**
  70039. * The default controller model for the controller
  70040. */
  70041. readonly defaultModel: AbstractMesh;
  70042. /**
  70043. * Creates a new WebVRController from a gamepad
  70044. * @param vrGamepad the gamepad that the WebVRController should be created from
  70045. */
  70046. constructor(vrGamepad: any);
  70047. /**
  70048. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70049. */
  70050. update(): void;
  70051. /**
  70052. * Function to be called when a button is modified
  70053. */
  70054. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70055. /**
  70056. * Loads a mesh and attaches it to the controller
  70057. * @param scene the scene the mesh should be added to
  70058. * @param meshLoaded callback for when the mesh has been loaded
  70059. */
  70060. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70061. private _setButtonValue;
  70062. private _changes;
  70063. private _checkChanges;
  70064. /**
  70065. * Disposes of th webVRCOntroller
  70066. */
  70067. dispose(): void;
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /**
  70072. * The HemisphericLight simulates the ambient environment light,
  70073. * so the passed direction is the light reflection direction, not the incoming direction.
  70074. */
  70075. export class HemisphericLight extends Light {
  70076. /**
  70077. * The groundColor is the light in the opposite direction to the one specified during creation.
  70078. * 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.
  70079. */
  70080. groundColor: Color3;
  70081. /**
  70082. * The light reflection direction, not the incoming direction.
  70083. */
  70084. direction: Vector3;
  70085. /**
  70086. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70087. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70088. * The HemisphericLight can't cast shadows.
  70089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70090. * @param name The friendly name of the light
  70091. * @param direction The direction of the light reflection
  70092. * @param scene The scene the light belongs to
  70093. */
  70094. constructor(name: string, direction: Vector3, scene: Scene);
  70095. protected _buildUniformLayout(): void;
  70096. /**
  70097. * Returns the string "HemisphericLight".
  70098. * @return The class name
  70099. */
  70100. getClassName(): string;
  70101. /**
  70102. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70103. * Returns the updated direction.
  70104. * @param target The target the direction should point to
  70105. * @return The computed direction
  70106. */
  70107. setDirectionToTarget(target: Vector3): Vector3;
  70108. /**
  70109. * Returns the shadow generator associated to the light.
  70110. * @returns Always null for hemispheric lights because it does not support shadows.
  70111. */
  70112. getShadowGenerator(): Nullable<IShadowGenerator>;
  70113. /**
  70114. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70115. * @param effect The effect to update
  70116. * @param lightIndex The index of the light in the effect to update
  70117. * @returns The hemispheric light
  70118. */
  70119. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70120. /**
  70121. * Computes the world matrix of the node
  70122. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70123. * @param useWasUpdatedFlag defines a reserved property
  70124. * @returns the world matrix
  70125. */
  70126. computeWorldMatrix(): Matrix;
  70127. /**
  70128. * Returns the integer 3.
  70129. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70130. */
  70131. getTypeID(): number;
  70132. /**
  70133. * Prepares the list of defines specific to the light type.
  70134. * @param defines the list of defines
  70135. * @param lightIndex defines the index of the light for the effect
  70136. */
  70137. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70138. }
  70139. }
  70140. declare module BABYLON {
  70141. /**
  70142. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70143. * IMPORTANT!! The data is right-hand data.
  70144. * @export
  70145. * @interface DevicePose
  70146. */
  70147. export interface DevicePose {
  70148. /**
  70149. * The position of the device, values in array are [x,y,z].
  70150. */
  70151. readonly position: Nullable<Float32Array>;
  70152. /**
  70153. * The linearVelocity of the device, values in array are [x,y,z].
  70154. */
  70155. readonly linearVelocity: Nullable<Float32Array>;
  70156. /**
  70157. * The linearAcceleration of the device, values in array are [x,y,z].
  70158. */
  70159. readonly linearAcceleration: Nullable<Float32Array>;
  70160. /**
  70161. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70162. */
  70163. readonly orientation: Nullable<Float32Array>;
  70164. /**
  70165. * The angularVelocity of the device, values in array are [x,y,z].
  70166. */
  70167. readonly angularVelocity: Nullable<Float32Array>;
  70168. /**
  70169. * The angularAcceleration of the device, values in array are [x,y,z].
  70170. */
  70171. readonly angularAcceleration: Nullable<Float32Array>;
  70172. }
  70173. /**
  70174. * Interface representing a pose controlled object in Babylon.
  70175. * A pose controlled object has both regular pose values as well as pose values
  70176. * from an external device such as a VR head mounted display
  70177. */
  70178. export interface PoseControlled {
  70179. /**
  70180. * The position of the object in babylon space.
  70181. */
  70182. position: Vector3;
  70183. /**
  70184. * The rotation quaternion of the object in babylon space.
  70185. */
  70186. rotationQuaternion: Quaternion;
  70187. /**
  70188. * The position of the device in babylon space.
  70189. */
  70190. devicePosition?: Vector3;
  70191. /**
  70192. * The rotation quaternion of the device in babylon space.
  70193. */
  70194. deviceRotationQuaternion: Quaternion;
  70195. /**
  70196. * The raw pose coming from the device.
  70197. */
  70198. rawPose: Nullable<DevicePose>;
  70199. /**
  70200. * The scale of the device to be used when translating from device space to babylon space.
  70201. */
  70202. deviceScaleFactor: number;
  70203. /**
  70204. * Updates the poseControlled values based on the input device pose.
  70205. * @param poseData the pose data to update the object with
  70206. */
  70207. updateFromDevice(poseData: DevicePose): void;
  70208. }
  70209. /**
  70210. * Set of options to customize the webVRCamera
  70211. */
  70212. export interface WebVROptions {
  70213. /**
  70214. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70215. */
  70216. trackPosition?: boolean;
  70217. /**
  70218. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70219. */
  70220. positionScale?: number;
  70221. /**
  70222. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70223. */
  70224. displayName?: string;
  70225. /**
  70226. * Should the native controller meshes be initialized. (default: true)
  70227. */
  70228. controllerMeshes?: boolean;
  70229. /**
  70230. * Creating a default HemiLight only on controllers. (default: true)
  70231. */
  70232. defaultLightingOnControllers?: boolean;
  70233. /**
  70234. * If you don't want to use the default VR button of the helper. (default: false)
  70235. */
  70236. useCustomVRButton?: boolean;
  70237. /**
  70238. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70239. */
  70240. customVRButton?: HTMLButtonElement;
  70241. /**
  70242. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70243. */
  70244. rayLength?: number;
  70245. /**
  70246. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70247. */
  70248. defaultHeight?: number;
  70249. }
  70250. /**
  70251. * This represents a WebVR camera.
  70252. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70253. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70254. */
  70255. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70256. private webVROptions;
  70257. /**
  70258. * @hidden
  70259. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70260. */
  70261. _vrDevice: any;
  70262. /**
  70263. * The rawPose of the vrDevice.
  70264. */
  70265. rawPose: Nullable<DevicePose>;
  70266. private _onVREnabled;
  70267. private _specsVersion;
  70268. private _attached;
  70269. private _frameData;
  70270. protected _descendants: Array<Node>;
  70271. private _deviceRoomPosition;
  70272. /** @hidden */
  70273. _deviceRoomRotationQuaternion: Quaternion;
  70274. private _standingMatrix;
  70275. /**
  70276. * Represents device position in babylon space.
  70277. */
  70278. devicePosition: Vector3;
  70279. /**
  70280. * Represents device rotation in babylon space.
  70281. */
  70282. deviceRotationQuaternion: Quaternion;
  70283. /**
  70284. * The scale of the device to be used when translating from device space to babylon space.
  70285. */
  70286. deviceScaleFactor: number;
  70287. private _deviceToWorld;
  70288. private _worldToDevice;
  70289. /**
  70290. * References to the webVR controllers for the vrDevice.
  70291. */
  70292. controllers: Array<WebVRController>;
  70293. /**
  70294. * Emits an event when a controller is attached.
  70295. */
  70296. onControllersAttachedObservable: Observable<WebVRController[]>;
  70297. /**
  70298. * Emits an event when a controller's mesh has been loaded;
  70299. */
  70300. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70301. /**
  70302. * Emits an event when the HMD's pose has been updated.
  70303. */
  70304. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70305. private _poseSet;
  70306. /**
  70307. * If the rig cameras be used as parent instead of this camera.
  70308. */
  70309. rigParenting: boolean;
  70310. private _lightOnControllers;
  70311. private _defaultHeight?;
  70312. /**
  70313. * Instantiates a WebVRFreeCamera.
  70314. * @param name The name of the WebVRFreeCamera
  70315. * @param position The starting anchor position for the camera
  70316. * @param scene The scene the camera belongs to
  70317. * @param webVROptions a set of customizable options for the webVRCamera
  70318. */
  70319. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70320. /**
  70321. * Gets the device distance from the ground in meters.
  70322. * @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.
  70323. */
  70324. deviceDistanceToRoomGround(): number;
  70325. /**
  70326. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70327. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70328. */
  70329. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70330. /**
  70331. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70332. * @returns A promise with a boolean set to if the standing matrix is supported.
  70333. */
  70334. useStandingMatrixAsync(): Promise<boolean>;
  70335. /**
  70336. * Disposes the camera
  70337. */
  70338. dispose(): void;
  70339. /**
  70340. * Gets a vrController by name.
  70341. * @param name The name of the controller to retreive
  70342. * @returns the controller matching the name specified or null if not found
  70343. */
  70344. getControllerByName(name: string): Nullable<WebVRController>;
  70345. private _leftController;
  70346. /**
  70347. * The controller corrisponding to the users left hand.
  70348. */
  70349. readonly leftController: Nullable<WebVRController>;
  70350. private _rightController;
  70351. /**
  70352. * The controller corrisponding to the users right hand.
  70353. */
  70354. readonly rightController: Nullable<WebVRController>;
  70355. /**
  70356. * Casts a ray forward from the vrCamera's gaze.
  70357. * @param length Length of the ray (default: 100)
  70358. * @returns the ray corrisponding to the gaze
  70359. */
  70360. getForwardRay(length?: number): Ray;
  70361. /**
  70362. * @hidden
  70363. * Updates the camera based on device's frame data
  70364. */
  70365. _checkInputs(): void;
  70366. /**
  70367. * Updates the poseControlled values based on the input device pose.
  70368. * @param poseData Pose coming from the device
  70369. */
  70370. updateFromDevice(poseData: DevicePose): void;
  70371. private _htmlElementAttached;
  70372. private _detachIfAttached;
  70373. /**
  70374. * WebVR's attach control will start broadcasting frames to the device.
  70375. * Note that in certain browsers (chrome for example) this function must be called
  70376. * within a user-interaction callback. Example:
  70377. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70378. *
  70379. * @param element html element to attach the vrDevice to
  70380. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70381. */
  70382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70383. /**
  70384. * Detaches the camera from the html element and disables VR
  70385. *
  70386. * @param element html element to detach from
  70387. */
  70388. detachControl(element: HTMLElement): void;
  70389. /**
  70390. * @returns the name of this class
  70391. */
  70392. getClassName(): string;
  70393. /**
  70394. * Calls resetPose on the vrDisplay
  70395. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70396. */
  70397. resetToCurrentRotation(): void;
  70398. /**
  70399. * @hidden
  70400. * Updates the rig cameras (left and right eye)
  70401. */
  70402. _updateRigCameras(): void;
  70403. private _workingVector;
  70404. private _oneVector;
  70405. private _workingMatrix;
  70406. private updateCacheCalled;
  70407. private _correctPositionIfNotTrackPosition;
  70408. /**
  70409. * @hidden
  70410. * Updates the cached values of the camera
  70411. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70412. */
  70413. _updateCache(ignoreParentClass?: boolean): void;
  70414. /**
  70415. * @hidden
  70416. * Get current device position in babylon world
  70417. */
  70418. _computeDevicePosition(): void;
  70419. /**
  70420. * Updates the current device position and rotation in the babylon world
  70421. */
  70422. update(): void;
  70423. /**
  70424. * @hidden
  70425. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70426. * @returns an identity matrix
  70427. */
  70428. _getViewMatrix(): Matrix;
  70429. private _tmpMatrix;
  70430. /**
  70431. * This function is called by the two RIG cameras.
  70432. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70433. * @hidden
  70434. */
  70435. _getWebVRViewMatrix(): Matrix;
  70436. /** @hidden */
  70437. _getWebVRProjectionMatrix(): Matrix;
  70438. private _onGamepadConnectedObserver;
  70439. private _onGamepadDisconnectedObserver;
  70440. private _updateCacheWhenTrackingDisabledObserver;
  70441. /**
  70442. * Initializes the controllers and their meshes
  70443. */
  70444. initControllers(): void;
  70445. }
  70446. }
  70447. declare module BABYLON {
  70448. /**
  70449. * Size options for a post process
  70450. */
  70451. export type PostProcessOptions = {
  70452. width: number;
  70453. height: number;
  70454. };
  70455. /**
  70456. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70458. */
  70459. export class PostProcess {
  70460. /** Name of the PostProcess. */
  70461. name: string;
  70462. /**
  70463. * Gets or sets the unique id of the post process
  70464. */
  70465. uniqueId: number;
  70466. /**
  70467. * Width of the texture to apply the post process on
  70468. */
  70469. width: number;
  70470. /**
  70471. * Height of the texture to apply the post process on
  70472. */
  70473. height: number;
  70474. /**
  70475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70476. * @hidden
  70477. */
  70478. _outputTexture: Nullable<InternalTexture>;
  70479. /**
  70480. * Sampling mode used by the shader
  70481. * See https://doc.babylonjs.com/classes/3.1/texture
  70482. */
  70483. renderTargetSamplingMode: number;
  70484. /**
  70485. * Clear color to use when screen clearing
  70486. */
  70487. clearColor: Color4;
  70488. /**
  70489. * If the buffer needs to be cleared before applying the post process. (default: true)
  70490. * Should be set to false if shader will overwrite all previous pixels.
  70491. */
  70492. autoClear: boolean;
  70493. /**
  70494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70495. */
  70496. alphaMode: number;
  70497. /**
  70498. * Sets the setAlphaBlendConstants of the babylon engine
  70499. */
  70500. alphaConstants: Color4;
  70501. /**
  70502. * Animations to be used for the post processing
  70503. */
  70504. animations: Animation[];
  70505. /**
  70506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70508. */
  70509. enablePixelPerfectMode: boolean;
  70510. /**
  70511. * Force the postprocess to be applied without taking in account viewport
  70512. */
  70513. forceFullscreenViewport: boolean;
  70514. /**
  70515. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70516. *
  70517. * | Value | Type | Description |
  70518. * | ----- | ----------------------------------- | ----------- |
  70519. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70520. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70521. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70522. *
  70523. */
  70524. scaleMode: number;
  70525. /**
  70526. * Force textures to be a power of two (default: false)
  70527. */
  70528. alwaysForcePOT: boolean;
  70529. private _samples;
  70530. /**
  70531. * Number of sample textures (default: 1)
  70532. */
  70533. samples: number;
  70534. /**
  70535. * Modify the scale of the post process to be the same as the viewport (default: false)
  70536. */
  70537. adaptScaleToCurrentViewport: boolean;
  70538. private _camera;
  70539. private _scene;
  70540. private _engine;
  70541. private _options;
  70542. private _reusable;
  70543. private _textureType;
  70544. /**
  70545. * Smart array of input and output textures for the post process.
  70546. * @hidden
  70547. */
  70548. _textures: SmartArray<InternalTexture>;
  70549. /**
  70550. * The index in _textures that corresponds to the output texture.
  70551. * @hidden
  70552. */
  70553. _currentRenderTextureInd: number;
  70554. private _effect;
  70555. private _samplers;
  70556. private _fragmentUrl;
  70557. private _vertexUrl;
  70558. private _parameters;
  70559. private _scaleRatio;
  70560. protected _indexParameters: any;
  70561. private _shareOutputWithPostProcess;
  70562. private _texelSize;
  70563. private _forcedOutputTexture;
  70564. /**
  70565. * Returns the fragment url or shader name used in the post process.
  70566. * @returns the fragment url or name in the shader store.
  70567. */
  70568. getEffectName(): string;
  70569. /**
  70570. * An event triggered when the postprocess is activated.
  70571. */
  70572. onActivateObservable: Observable<Camera>;
  70573. private _onActivateObserver;
  70574. /**
  70575. * A function that is added to the onActivateObservable
  70576. */
  70577. onActivate: Nullable<(camera: Camera) => void>;
  70578. /**
  70579. * An event triggered when the postprocess changes its size.
  70580. */
  70581. onSizeChangedObservable: Observable<PostProcess>;
  70582. private _onSizeChangedObserver;
  70583. /**
  70584. * A function that is added to the onSizeChangedObservable
  70585. */
  70586. onSizeChanged: (postProcess: PostProcess) => void;
  70587. /**
  70588. * An event triggered when the postprocess applies its effect.
  70589. */
  70590. onApplyObservable: Observable<Effect>;
  70591. private _onApplyObserver;
  70592. /**
  70593. * A function that is added to the onApplyObservable
  70594. */
  70595. onApply: (effect: Effect) => void;
  70596. /**
  70597. * An event triggered before rendering the postprocess
  70598. */
  70599. onBeforeRenderObservable: Observable<Effect>;
  70600. private _onBeforeRenderObserver;
  70601. /**
  70602. * A function that is added to the onBeforeRenderObservable
  70603. */
  70604. onBeforeRender: (effect: Effect) => void;
  70605. /**
  70606. * An event triggered after rendering the postprocess
  70607. */
  70608. onAfterRenderObservable: Observable<Effect>;
  70609. private _onAfterRenderObserver;
  70610. /**
  70611. * A function that is added to the onAfterRenderObservable
  70612. */
  70613. onAfterRender: (efect: Effect) => void;
  70614. /**
  70615. * 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
  70616. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70617. */
  70618. inputTexture: InternalTexture;
  70619. /**
  70620. * Gets the camera which post process is applied to.
  70621. * @returns The camera the post process is applied to.
  70622. */
  70623. getCamera(): Camera;
  70624. /**
  70625. * Gets the texel size of the postprocess.
  70626. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70627. */
  70628. readonly texelSize: Vector2;
  70629. /**
  70630. * Creates a new instance PostProcess
  70631. * @param name The name of the PostProcess.
  70632. * @param fragmentUrl The url of the fragment shader to be used.
  70633. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70634. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70635. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70636. * @param camera The camera to apply the render pass to.
  70637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70638. * @param engine The engine which the post process will be applied. (default: current engine)
  70639. * @param reusable If the post process can be reused on the same frame. (default: false)
  70640. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70641. * @param textureType Type of textures used when performing the post process. (default: 0)
  70642. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70643. * @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
  70644. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70645. */
  70646. constructor(
  70647. /** Name of the PostProcess. */
  70648. 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);
  70649. /**
  70650. * Gets a string idenfifying the name of the class
  70651. * @returns "PostProcess" string
  70652. */
  70653. getClassName(): string;
  70654. /**
  70655. * Gets the engine which this post process belongs to.
  70656. * @returns The engine the post process was enabled with.
  70657. */
  70658. getEngine(): Engine;
  70659. /**
  70660. * The effect that is created when initializing the post process.
  70661. * @returns The created effect corrisponding the the postprocess.
  70662. */
  70663. getEffect(): Effect;
  70664. /**
  70665. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70666. * @param postProcess The post process to share the output with.
  70667. * @returns This post process.
  70668. */
  70669. shareOutputWith(postProcess: PostProcess): PostProcess;
  70670. /**
  70671. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70672. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70673. */
  70674. useOwnOutput(): void;
  70675. /**
  70676. * Updates the effect with the current post process compile time values and recompiles the shader.
  70677. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70678. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70679. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70680. * @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
  70681. * @param onCompiled Called when the shader has been compiled.
  70682. * @param onError Called if there is an error when compiling a shader.
  70683. */
  70684. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70685. /**
  70686. * The post process is reusable if it can be used multiple times within one frame.
  70687. * @returns If the post process is reusable
  70688. */
  70689. isReusable(): boolean;
  70690. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70691. markTextureDirty(): void;
  70692. /**
  70693. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70694. * 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.
  70695. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70696. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70697. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70698. * @returns The target texture that was bound to be written to.
  70699. */
  70700. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70701. /**
  70702. * If the post process is supported.
  70703. */
  70704. readonly isSupported: boolean;
  70705. /**
  70706. * The aspect ratio of the output texture.
  70707. */
  70708. readonly aspectRatio: number;
  70709. /**
  70710. * Get a value indicating if the post-process is ready to be used
  70711. * @returns true if the post-process is ready (shader is compiled)
  70712. */
  70713. isReady(): boolean;
  70714. /**
  70715. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70716. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70717. */
  70718. apply(): Nullable<Effect>;
  70719. private _disposeTextures;
  70720. /**
  70721. * Disposes the post process.
  70722. * @param camera The camera to dispose the post process on.
  70723. */
  70724. dispose(camera?: Camera): void;
  70725. }
  70726. }
  70727. declare module BABYLON {
  70728. /**
  70729. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70730. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70731. */
  70732. export class PostProcessManager {
  70733. private _scene;
  70734. private _indexBuffer;
  70735. private _vertexBuffers;
  70736. /**
  70737. * Creates a new instance PostProcess
  70738. * @param scene The scene that the post process is associated with.
  70739. */
  70740. constructor(scene: Scene);
  70741. private _prepareBuffers;
  70742. private _buildIndexBuffer;
  70743. /**
  70744. * Rebuilds the vertex buffers of the manager.
  70745. * @hidden
  70746. */
  70747. _rebuild(): void;
  70748. /**
  70749. * Prepares a frame to be run through a post process.
  70750. * @param sourceTexture The input texture to the post procesess. (default: null)
  70751. * @param postProcesses An array of post processes to be run. (default: null)
  70752. * @returns True if the post processes were able to be run.
  70753. * @hidden
  70754. */
  70755. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70756. /**
  70757. * Manually render a set of post processes to a texture.
  70758. * @param postProcesses An array of post processes to be run.
  70759. * @param targetTexture The target texture to render to.
  70760. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70761. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70762. * @param lodLevel defines which lod of the texture to render to
  70763. */
  70764. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70765. /**
  70766. * Finalize the result of the output of the postprocesses.
  70767. * @param doNotPresent If true the result will not be displayed to the screen.
  70768. * @param targetTexture The target texture to render to.
  70769. * @param faceIndex The index of the face to bind the target texture to.
  70770. * @param postProcesses The array of post processes to render.
  70771. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70772. * @hidden
  70773. */
  70774. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70775. /**
  70776. * Disposes of the post process manager.
  70777. */
  70778. dispose(): void;
  70779. }
  70780. }
  70781. declare module BABYLON {
  70782. interface AbstractScene {
  70783. /**
  70784. * The list of layers (background and foreground) of the scene
  70785. */
  70786. layers: Array<Layer>;
  70787. }
  70788. /**
  70789. * Defines the layer scene component responsible to manage any layers
  70790. * in a given scene.
  70791. */
  70792. export class LayerSceneComponent implements ISceneComponent {
  70793. /**
  70794. * The component name helpfull to identify the component in the list of scene components.
  70795. */
  70796. readonly name: string;
  70797. /**
  70798. * The scene the component belongs to.
  70799. */
  70800. scene: Scene;
  70801. private _engine;
  70802. /**
  70803. * Creates a new instance of the component for the given scene
  70804. * @param scene Defines the scene to register the component in
  70805. */
  70806. constructor(scene: Scene);
  70807. /**
  70808. * Registers the component in a given scene
  70809. */
  70810. register(): void;
  70811. /**
  70812. * Rebuilds the elements related to this component in case of
  70813. * context lost for instance.
  70814. */
  70815. rebuild(): void;
  70816. /**
  70817. * Disposes the component and the associated ressources.
  70818. */
  70819. dispose(): void;
  70820. private _draw;
  70821. private _drawCameraPredicate;
  70822. private _drawCameraBackground;
  70823. private _drawCameraForeground;
  70824. private _drawRenderTargetPredicate;
  70825. private _drawRenderTargetBackground;
  70826. private _drawRenderTargetForeground;
  70827. }
  70828. }
  70829. declare module BABYLON {
  70830. /** @hidden */
  70831. export var layerPixelShader: {
  70832. name: string;
  70833. shader: string;
  70834. };
  70835. }
  70836. declare module BABYLON {
  70837. /** @hidden */
  70838. export var layerVertexShader: {
  70839. name: string;
  70840. shader: string;
  70841. };
  70842. }
  70843. declare module BABYLON {
  70844. /**
  70845. * This represents a full screen 2d layer.
  70846. * This can be useful to display a picture in the background of your scene for instance.
  70847. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70848. */
  70849. export class Layer {
  70850. /**
  70851. * Define the name of the layer.
  70852. */
  70853. name: string;
  70854. /**
  70855. * Define the texture the layer should display.
  70856. */
  70857. texture: Nullable<Texture>;
  70858. /**
  70859. * Is the layer in background or foreground.
  70860. */
  70861. isBackground: boolean;
  70862. /**
  70863. * Define the color of the layer (instead of texture).
  70864. */
  70865. color: Color4;
  70866. /**
  70867. * Define the scale of the layer in order to zoom in out of the texture.
  70868. */
  70869. scale: Vector2;
  70870. /**
  70871. * Define an offset for the layer in order to shift the texture.
  70872. */
  70873. offset: Vector2;
  70874. /**
  70875. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70876. */
  70877. alphaBlendingMode: number;
  70878. /**
  70879. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70880. * Alpha test will not mix with the background color in case of transparency.
  70881. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70882. */
  70883. alphaTest: boolean;
  70884. /**
  70885. * Define a mask to restrict the layer to only some of the scene cameras.
  70886. */
  70887. layerMask: number;
  70888. /**
  70889. * Define the list of render target the layer is visible into.
  70890. */
  70891. renderTargetTextures: RenderTargetTexture[];
  70892. /**
  70893. * Define if the layer is only used in renderTarget or if it also
  70894. * renders in the main frame buffer of the canvas.
  70895. */
  70896. renderOnlyInRenderTargetTextures: boolean;
  70897. private _scene;
  70898. private _vertexBuffers;
  70899. private _indexBuffer;
  70900. private _effect;
  70901. private _alphaTestEffect;
  70902. /**
  70903. * An event triggered when the layer is disposed.
  70904. */
  70905. onDisposeObservable: Observable<Layer>;
  70906. private _onDisposeObserver;
  70907. /**
  70908. * Back compatibility with callback before the onDisposeObservable existed.
  70909. * The set callback will be triggered when the layer has been disposed.
  70910. */
  70911. onDispose: () => void;
  70912. /**
  70913. * An event triggered before rendering the scene
  70914. */
  70915. onBeforeRenderObservable: Observable<Layer>;
  70916. private _onBeforeRenderObserver;
  70917. /**
  70918. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70919. * The set callback will be triggered just before rendering the layer.
  70920. */
  70921. onBeforeRender: () => void;
  70922. /**
  70923. * An event triggered after rendering the scene
  70924. */
  70925. onAfterRenderObservable: Observable<Layer>;
  70926. private _onAfterRenderObserver;
  70927. /**
  70928. * Back compatibility with callback before the onAfterRenderObservable existed.
  70929. * The set callback will be triggered just after rendering the layer.
  70930. */
  70931. onAfterRender: () => void;
  70932. /**
  70933. * Instantiates a new layer.
  70934. * This represents a full screen 2d layer.
  70935. * This can be useful to display a picture in the background of your scene for instance.
  70936. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70937. * @param name Define the name of the layer in the scene
  70938. * @param imgUrl Define the url of the texture to display in the layer
  70939. * @param scene Define the scene the layer belongs to
  70940. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70941. * @param color Defines a color for the layer
  70942. */
  70943. constructor(
  70944. /**
  70945. * Define the name of the layer.
  70946. */
  70947. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70948. private _createIndexBuffer;
  70949. /** @hidden */
  70950. _rebuild(): void;
  70951. /**
  70952. * Renders the layer in the scene.
  70953. */
  70954. render(): void;
  70955. /**
  70956. * Disposes and releases the associated ressources.
  70957. */
  70958. dispose(): void;
  70959. }
  70960. }
  70961. declare module BABYLON {
  70962. interface AbstractScene {
  70963. /**
  70964. * The list of procedural textures added to the scene
  70965. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70966. */
  70967. proceduralTextures: Array<ProceduralTexture>;
  70968. }
  70969. /**
  70970. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70971. * in a given scene.
  70972. */
  70973. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70974. /**
  70975. * The component name helpfull to identify the component in the list of scene components.
  70976. */
  70977. readonly name: string;
  70978. /**
  70979. * The scene the component belongs to.
  70980. */
  70981. scene: Scene;
  70982. /**
  70983. * Creates a new instance of the component for the given scene
  70984. * @param scene Defines the scene to register the component in
  70985. */
  70986. constructor(scene: Scene);
  70987. /**
  70988. * Registers the component in a given scene
  70989. */
  70990. register(): void;
  70991. /**
  70992. * Rebuilds the elements related to this component in case of
  70993. * context lost for instance.
  70994. */
  70995. rebuild(): void;
  70996. /**
  70997. * Disposes the component and the associated ressources.
  70998. */
  70999. dispose(): void;
  71000. private _beforeClear;
  71001. }
  71002. }
  71003. declare module BABYLON {
  71004. /** @hidden */
  71005. export var proceduralVertexShader: {
  71006. name: string;
  71007. shader: string;
  71008. };
  71009. }
  71010. declare module BABYLON {
  71011. /**
  71012. * 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.
  71013. * This is the base class of any Procedural texture and contains most of the shareable code.
  71014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71015. */
  71016. export class ProceduralTexture extends Texture {
  71017. isCube: boolean;
  71018. /**
  71019. * Define if the texture is enabled or not (disabled texture will not render)
  71020. */
  71021. isEnabled: boolean;
  71022. /**
  71023. * Define if the texture must be cleared before rendering (default is true)
  71024. */
  71025. autoClear: boolean;
  71026. /**
  71027. * Callback called when the texture is generated
  71028. */
  71029. onGenerated: () => void;
  71030. /**
  71031. * Event raised when the texture is generated
  71032. */
  71033. onGeneratedObservable: Observable<ProceduralTexture>;
  71034. /** @hidden */
  71035. _generateMipMaps: boolean;
  71036. /** @hidden **/
  71037. _effect: Effect;
  71038. /** @hidden */
  71039. _textures: {
  71040. [key: string]: Texture;
  71041. };
  71042. private _size;
  71043. private _currentRefreshId;
  71044. private _refreshRate;
  71045. private _vertexBuffers;
  71046. private _indexBuffer;
  71047. private _uniforms;
  71048. private _samplers;
  71049. private _fragment;
  71050. private _floats;
  71051. private _ints;
  71052. private _floatsArrays;
  71053. private _colors3;
  71054. private _colors4;
  71055. private _vectors2;
  71056. private _vectors3;
  71057. private _matrices;
  71058. private _fallbackTexture;
  71059. private _fallbackTextureUsed;
  71060. private _engine;
  71061. private _cachedDefines;
  71062. private _contentUpdateId;
  71063. private _contentData;
  71064. /**
  71065. * Instantiates a new procedural texture.
  71066. * 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.
  71067. * This is the base class of any Procedural texture and contains most of the shareable code.
  71068. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71069. * @param name Define the name of the texture
  71070. * @param size Define the size of the texture to create
  71071. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71072. * @param scene Define the scene the texture belongs to
  71073. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71074. * @param generateMipMaps Define if the texture should creates mip maps or not
  71075. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71076. */
  71077. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71078. /**
  71079. * The effect that is created when initializing the post process.
  71080. * @returns The created effect corrisponding the the postprocess.
  71081. */
  71082. getEffect(): Effect;
  71083. /**
  71084. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71085. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71086. */
  71087. getContent(): Nullable<ArrayBufferView>;
  71088. private _createIndexBuffer;
  71089. /** @hidden */
  71090. _rebuild(): void;
  71091. /**
  71092. * Resets the texture in order to recreate its associated resources.
  71093. * This can be called in case of context loss
  71094. */
  71095. reset(): void;
  71096. protected _getDefines(): string;
  71097. /**
  71098. * Is the texture ready to be used ? (rendered at least once)
  71099. * @returns true if ready, otherwise, false.
  71100. */
  71101. isReady(): boolean;
  71102. /**
  71103. * Resets the refresh counter of the texture and start bak from scratch.
  71104. * Could be useful to regenerate the texture if it is setup to render only once.
  71105. */
  71106. resetRefreshCounter(): void;
  71107. /**
  71108. * Set the fragment shader to use in order to render the texture.
  71109. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71110. */
  71111. setFragment(fragment: any): void;
  71112. /**
  71113. * Define the refresh rate of the texture or the rendering frequency.
  71114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71115. */
  71116. refreshRate: number;
  71117. /** @hidden */
  71118. _shouldRender(): boolean;
  71119. /**
  71120. * Get the size the texture is rendering at.
  71121. * @returns the size (texture is always squared)
  71122. */
  71123. getRenderSize(): number;
  71124. /**
  71125. * Resize the texture to new value.
  71126. * @param size Define the new size the texture should have
  71127. * @param generateMipMaps Define whether the new texture should create mip maps
  71128. */
  71129. resize(size: number, generateMipMaps: boolean): void;
  71130. private _checkUniform;
  71131. /**
  71132. * Set a texture in the shader program used to render.
  71133. * @param name Define the name of the uniform samplers as defined in the shader
  71134. * @param texture Define the texture to bind to this sampler
  71135. * @return the texture itself allowing "fluent" like uniform updates
  71136. */
  71137. setTexture(name: string, texture: Texture): ProceduralTexture;
  71138. /**
  71139. * Set a float in the shader.
  71140. * @param name Define the name of the uniform as defined in the shader
  71141. * @param value Define the value to give to the uniform
  71142. * @return the texture itself allowing "fluent" like uniform updates
  71143. */
  71144. setFloat(name: string, value: number): ProceduralTexture;
  71145. /**
  71146. * Set a int in the shader.
  71147. * @param name Define the name of the uniform as defined in the shader
  71148. * @param value Define the value to give to the uniform
  71149. * @return the texture itself allowing "fluent" like uniform updates
  71150. */
  71151. setInt(name: string, value: number): ProceduralTexture;
  71152. /**
  71153. * Set an array of floats in the shader.
  71154. * @param name Define the name of the uniform as defined in the shader
  71155. * @param value Define the value to give to the uniform
  71156. * @return the texture itself allowing "fluent" like uniform updates
  71157. */
  71158. setFloats(name: string, value: number[]): ProceduralTexture;
  71159. /**
  71160. * Set a vec3 in the shader from a Color3.
  71161. * @param name Define the name of the uniform as defined in the shader
  71162. * @param value Define the value to give to the uniform
  71163. * @return the texture itself allowing "fluent" like uniform updates
  71164. */
  71165. setColor3(name: string, value: Color3): ProceduralTexture;
  71166. /**
  71167. * Set a vec4 in the shader from a Color4.
  71168. * @param name Define the name of the uniform as defined in the shader
  71169. * @param value Define the value to give to the uniform
  71170. * @return the texture itself allowing "fluent" like uniform updates
  71171. */
  71172. setColor4(name: string, value: Color4): ProceduralTexture;
  71173. /**
  71174. * Set a vec2 in the shader from a Vector2.
  71175. * @param name Define the name of the uniform as defined in the shader
  71176. * @param value Define the value to give to the uniform
  71177. * @return the texture itself allowing "fluent" like uniform updates
  71178. */
  71179. setVector2(name: string, value: Vector2): ProceduralTexture;
  71180. /**
  71181. * Set a vec3 in the shader from a Vector3.
  71182. * @param name Define the name of the uniform as defined in the shader
  71183. * @param value Define the value to give to the uniform
  71184. * @return the texture itself allowing "fluent" like uniform updates
  71185. */
  71186. setVector3(name: string, value: Vector3): ProceduralTexture;
  71187. /**
  71188. * Set a mat4 in the shader from a MAtrix.
  71189. * @param name Define the name of the uniform as defined in the shader
  71190. * @param value Define the value to give to the uniform
  71191. * @return the texture itself allowing "fluent" like uniform updates
  71192. */
  71193. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71194. /**
  71195. * Render the texture to its associated render target.
  71196. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71197. */
  71198. render(useCameraPostProcess?: boolean): void;
  71199. /**
  71200. * Clone the texture.
  71201. * @returns the cloned texture
  71202. */
  71203. clone(): ProceduralTexture;
  71204. /**
  71205. * Dispose the texture and release its asoociated resources.
  71206. */
  71207. dispose(): void;
  71208. }
  71209. }
  71210. declare module BABYLON {
  71211. /**
  71212. * This represents the base class for particle system in Babylon.
  71213. * 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.
  71214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71215. * @example https://doc.babylonjs.com/babylon101/particles
  71216. */
  71217. export class BaseParticleSystem {
  71218. /**
  71219. * Source color is added to the destination color without alpha affecting the result
  71220. */
  71221. static BLENDMODE_ONEONE: number;
  71222. /**
  71223. * Blend current color and particle color using particle’s alpha
  71224. */
  71225. static BLENDMODE_STANDARD: number;
  71226. /**
  71227. * Add current color and particle color multiplied by particle’s alpha
  71228. */
  71229. static BLENDMODE_ADD: number;
  71230. /**
  71231. * Multiply current color with particle color
  71232. */
  71233. static BLENDMODE_MULTIPLY: number;
  71234. /**
  71235. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71236. */
  71237. static BLENDMODE_MULTIPLYADD: number;
  71238. /**
  71239. * List of animations used by the particle system.
  71240. */
  71241. animations: Animation[];
  71242. /**
  71243. * The id of the Particle system.
  71244. */
  71245. id: string;
  71246. /**
  71247. * The friendly name of the Particle system.
  71248. */
  71249. name: string;
  71250. /**
  71251. * The rendering group used by the Particle system to chose when to render.
  71252. */
  71253. renderingGroupId: number;
  71254. /**
  71255. * The emitter represents the Mesh or position we are attaching the particle system to.
  71256. */
  71257. emitter: Nullable<AbstractMesh | Vector3>;
  71258. /**
  71259. * The maximum number of particles to emit per frame
  71260. */
  71261. emitRate: number;
  71262. /**
  71263. * If you want to launch only a few particles at once, that can be done, as well.
  71264. */
  71265. manualEmitCount: number;
  71266. /**
  71267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71268. */
  71269. updateSpeed: number;
  71270. /**
  71271. * The amount of time the particle system is running (depends of the overall update speed).
  71272. */
  71273. targetStopDuration: number;
  71274. /**
  71275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71276. */
  71277. disposeOnStop: boolean;
  71278. /**
  71279. * Minimum power of emitting particles.
  71280. */
  71281. minEmitPower: number;
  71282. /**
  71283. * Maximum power of emitting particles.
  71284. */
  71285. maxEmitPower: number;
  71286. /**
  71287. * Minimum life time of emitting particles.
  71288. */
  71289. minLifeTime: number;
  71290. /**
  71291. * Maximum life time of emitting particles.
  71292. */
  71293. maxLifeTime: number;
  71294. /**
  71295. * Minimum Size of emitting particles.
  71296. */
  71297. minSize: number;
  71298. /**
  71299. * Maximum Size of emitting particles.
  71300. */
  71301. maxSize: number;
  71302. /**
  71303. * Minimum scale of emitting particles on X axis.
  71304. */
  71305. minScaleX: number;
  71306. /**
  71307. * Maximum scale of emitting particles on X axis.
  71308. */
  71309. maxScaleX: number;
  71310. /**
  71311. * Minimum scale of emitting particles on Y axis.
  71312. */
  71313. minScaleY: number;
  71314. /**
  71315. * Maximum scale of emitting particles on Y axis.
  71316. */
  71317. maxScaleY: number;
  71318. /**
  71319. * Gets or sets the minimal initial rotation in radians.
  71320. */
  71321. minInitialRotation: number;
  71322. /**
  71323. * Gets or sets the maximal initial rotation in radians.
  71324. */
  71325. maxInitialRotation: number;
  71326. /**
  71327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71328. */
  71329. minAngularSpeed: number;
  71330. /**
  71331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71332. */
  71333. maxAngularSpeed: number;
  71334. /**
  71335. * The texture used to render each particle. (this can be a spritesheet)
  71336. */
  71337. particleTexture: Nullable<Texture>;
  71338. /**
  71339. * The layer mask we are rendering the particles through.
  71340. */
  71341. layerMask: number;
  71342. /**
  71343. * This can help using your own shader to render the particle system.
  71344. * The according effect will be created
  71345. */
  71346. customShader: any;
  71347. /**
  71348. * By default particle system starts as soon as they are created. This prevents the
  71349. * automatic start to happen and let you decide when to start emitting particles.
  71350. */
  71351. preventAutoStart: boolean;
  71352. private _noiseTexture;
  71353. /**
  71354. * Gets or sets a texture used to add random noise to particle positions
  71355. */
  71356. noiseTexture: Nullable<ProceduralTexture>;
  71357. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71358. noiseStrength: Vector3;
  71359. /**
  71360. * Callback triggered when the particle animation is ending.
  71361. */
  71362. onAnimationEnd: Nullable<() => void>;
  71363. /**
  71364. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71365. */
  71366. blendMode: number;
  71367. /**
  71368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71369. * to override the particles.
  71370. */
  71371. forceDepthWrite: boolean;
  71372. /** 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 */
  71373. preWarmCycles: number;
  71374. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71375. preWarmStepOffset: number;
  71376. /**
  71377. * 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)
  71378. */
  71379. spriteCellChangeSpeed: number;
  71380. /**
  71381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71382. */
  71383. startSpriteCellID: number;
  71384. /**
  71385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71386. */
  71387. endSpriteCellID: number;
  71388. /**
  71389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71390. */
  71391. spriteCellWidth: number;
  71392. /**
  71393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71394. */
  71395. spriteCellHeight: number;
  71396. /**
  71397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71398. */
  71399. spriteRandomStartCell: boolean;
  71400. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71401. translationPivot: Vector2;
  71402. /** @hidden */
  71403. protected _isAnimationSheetEnabled: boolean;
  71404. /**
  71405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71406. */
  71407. beginAnimationOnStart: boolean;
  71408. /**
  71409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71410. */
  71411. beginAnimationFrom: number;
  71412. /**
  71413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71414. */
  71415. beginAnimationTo: number;
  71416. /**
  71417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71418. */
  71419. beginAnimationLoop: boolean;
  71420. /**
  71421. * Gets or sets a world offset applied to all particles
  71422. */
  71423. worldOffset: Vector3;
  71424. /**
  71425. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71426. */
  71427. isAnimationSheetEnabled: boolean;
  71428. /**
  71429. * Get hosting scene
  71430. * @returns the scene
  71431. */
  71432. getScene(): Scene;
  71433. /**
  71434. * You can use gravity if you want to give an orientation to your particles.
  71435. */
  71436. gravity: Vector3;
  71437. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71438. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71439. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71440. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71441. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71442. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71443. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71444. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71445. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71446. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71447. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71448. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71449. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71450. /**
  71451. * Defines the delay in milliseconds before starting the system (0 by default)
  71452. */
  71453. startDelay: number;
  71454. /**
  71455. * Gets the current list of drag gradients.
  71456. * You must use addDragGradient and removeDragGradient to udpate this list
  71457. * @returns the list of drag gradients
  71458. */
  71459. getDragGradients(): Nullable<Array<FactorGradient>>;
  71460. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71461. limitVelocityDamping: number;
  71462. /**
  71463. * Gets the current list of limit velocity gradients.
  71464. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71465. * @returns the list of limit velocity gradients
  71466. */
  71467. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71468. /**
  71469. * Gets the current list of color gradients.
  71470. * You must use addColorGradient and removeColorGradient to udpate this list
  71471. * @returns the list of color gradients
  71472. */
  71473. getColorGradients(): Nullable<Array<ColorGradient>>;
  71474. /**
  71475. * Gets the current list of size gradients.
  71476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71477. * @returns the list of size gradients
  71478. */
  71479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71480. /**
  71481. * Gets the current list of color remap gradients.
  71482. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71483. * @returns the list of color remap gradients
  71484. */
  71485. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71486. /**
  71487. * Gets the current list of alpha remap gradients.
  71488. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71489. * @returns the list of alpha remap gradients
  71490. */
  71491. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71492. /**
  71493. * Gets the current list of life time gradients.
  71494. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71495. * @returns the list of life time gradients
  71496. */
  71497. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71498. /**
  71499. * Gets the current list of angular speed gradients.
  71500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71501. * @returns the list of angular speed gradients
  71502. */
  71503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71504. /**
  71505. * Gets the current list of velocity gradients.
  71506. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71507. * @returns the list of velocity gradients
  71508. */
  71509. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71510. /**
  71511. * Gets the current list of start size gradients.
  71512. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71513. * @returns the list of start size gradients
  71514. */
  71515. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71516. /**
  71517. * Gets the current list of emit rate gradients.
  71518. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71519. * @returns the list of emit rate gradients
  71520. */
  71521. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71522. /**
  71523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71525. */
  71526. direction1: Vector3;
  71527. /**
  71528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71530. */
  71531. direction2: Vector3;
  71532. /**
  71533. * 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.
  71534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71535. */
  71536. minEmitBox: Vector3;
  71537. /**
  71538. * 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.
  71539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71540. */
  71541. maxEmitBox: Vector3;
  71542. /**
  71543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71544. */
  71545. color1: Color4;
  71546. /**
  71547. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71548. */
  71549. color2: Color4;
  71550. /**
  71551. * Color the particle will have at the end of its lifetime
  71552. */
  71553. colorDead: Color4;
  71554. /**
  71555. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71556. */
  71557. textureMask: Color4;
  71558. /**
  71559. * The particle emitter type defines the emitter used by the particle system.
  71560. * It can be for example box, sphere, or cone...
  71561. */
  71562. particleEmitterType: IParticleEmitterType;
  71563. /** @hidden */
  71564. _isSubEmitter: boolean;
  71565. /**
  71566. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71567. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71568. */
  71569. billboardMode: number;
  71570. protected _isBillboardBased: boolean;
  71571. /**
  71572. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71573. */
  71574. isBillboardBased: boolean;
  71575. /**
  71576. * The scene the particle system belongs to.
  71577. */
  71578. protected _scene: Scene;
  71579. /**
  71580. * Local cache of defines for image processing.
  71581. */
  71582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71583. /**
  71584. * Default configuration related to image processing available in the standard Material.
  71585. */
  71586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71587. /**
  71588. * Gets the image processing configuration used either in this material.
  71589. */
  71590. /**
  71591. * Sets the Default image processing configuration used either in the this material.
  71592. *
  71593. * If sets to null, the scene one is in use.
  71594. */
  71595. imageProcessingConfiguration: ImageProcessingConfiguration;
  71596. /**
  71597. * Attaches a new image processing configuration to the Standard Material.
  71598. * @param configuration
  71599. */
  71600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71601. /** @hidden */
  71602. protected _reset(): void;
  71603. /** @hidden */
  71604. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71605. /**
  71606. * Instantiates a particle system.
  71607. * 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.
  71608. * @param name The name of the particle system
  71609. */
  71610. constructor(name: string);
  71611. /**
  71612. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71615. * @returns the emitter
  71616. */
  71617. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71618. /**
  71619. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71620. * @param radius The radius of the hemisphere to emit from
  71621. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71622. * @returns the emitter
  71623. */
  71624. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71625. /**
  71626. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71627. * @param radius The radius of the sphere to emit from
  71628. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71629. * @returns the emitter
  71630. */
  71631. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71632. /**
  71633. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71634. * @param radius The radius of the sphere to emit from
  71635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71637. * @returns the emitter
  71638. */
  71639. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71640. /**
  71641. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71642. * @param radius The radius of the emission cylinder
  71643. * @param height The height of the emission cylinder
  71644. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71645. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71646. * @returns the emitter
  71647. */
  71648. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71649. /**
  71650. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71651. * @param radius The radius of the cylinder to emit from
  71652. * @param height The height of the emission cylinder
  71653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71656. * @returns the emitter
  71657. */
  71658. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71659. /**
  71660. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71661. * @param radius The radius of the cone to emit from
  71662. * @param angle The base angle of the cone
  71663. * @returns the emitter
  71664. */
  71665. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71666. /**
  71667. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71670. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71671. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71672. * @returns the emitter
  71673. */
  71674. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71675. }
  71676. }
  71677. declare module BABYLON {
  71678. /**
  71679. * Type of sub emitter
  71680. */
  71681. export enum SubEmitterType {
  71682. /**
  71683. * Attached to the particle over it's lifetime
  71684. */
  71685. ATTACHED = 0,
  71686. /**
  71687. * Created when the particle dies
  71688. */
  71689. END = 1
  71690. }
  71691. /**
  71692. * Sub emitter class used to emit particles from an existing particle
  71693. */
  71694. export class SubEmitter {
  71695. /**
  71696. * the particle system to be used by the sub emitter
  71697. */
  71698. particleSystem: ParticleSystem;
  71699. /**
  71700. * Type of the submitter (Default: END)
  71701. */
  71702. type: SubEmitterType;
  71703. /**
  71704. * 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)
  71705. * Note: This only is supported when using an emitter of type Mesh
  71706. */
  71707. inheritDirection: boolean;
  71708. /**
  71709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71710. */
  71711. inheritedVelocityAmount: number;
  71712. /**
  71713. * Creates a sub emitter
  71714. * @param particleSystem the particle system to be used by the sub emitter
  71715. */
  71716. constructor(
  71717. /**
  71718. * the particle system to be used by the sub emitter
  71719. */
  71720. particleSystem: ParticleSystem);
  71721. /**
  71722. * Clones the sub emitter
  71723. * @returns the cloned sub emitter
  71724. */
  71725. clone(): SubEmitter;
  71726. /**
  71727. * Serialize current object to a JSON object
  71728. * @returns the serialized object
  71729. */
  71730. serialize(): any;
  71731. /** @hidden */
  71732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71733. /**
  71734. * Creates a new SubEmitter from a serialized JSON version
  71735. * @param serializationObject defines the JSON object to read from
  71736. * @param scene defines the hosting scene
  71737. * @param rootUrl defines the rootUrl for data loading
  71738. * @returns a new SubEmitter
  71739. */
  71740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71741. /** Release associated resources */
  71742. dispose(): void;
  71743. }
  71744. }
  71745. declare module BABYLON {
  71746. /** @hidden */
  71747. export var clipPlaneFragmentDeclaration: {
  71748. name: string;
  71749. shader: string;
  71750. };
  71751. }
  71752. declare module BABYLON {
  71753. /** @hidden */
  71754. export var imageProcessingDeclaration: {
  71755. name: string;
  71756. shader: string;
  71757. };
  71758. }
  71759. declare module BABYLON {
  71760. /** @hidden */
  71761. export var imageProcessingFunctions: {
  71762. name: string;
  71763. shader: string;
  71764. };
  71765. }
  71766. declare module BABYLON {
  71767. /** @hidden */
  71768. export var clipPlaneFragment: {
  71769. name: string;
  71770. shader: string;
  71771. };
  71772. }
  71773. declare module BABYLON {
  71774. /** @hidden */
  71775. export var particlesPixelShader: {
  71776. name: string;
  71777. shader: string;
  71778. };
  71779. }
  71780. declare module BABYLON {
  71781. /** @hidden */
  71782. export var clipPlaneVertexDeclaration: {
  71783. name: string;
  71784. shader: string;
  71785. };
  71786. }
  71787. declare module BABYLON {
  71788. /** @hidden */
  71789. export var clipPlaneVertex: {
  71790. name: string;
  71791. shader: string;
  71792. };
  71793. }
  71794. declare module BABYLON {
  71795. /** @hidden */
  71796. export var particlesVertexShader: {
  71797. name: string;
  71798. shader: string;
  71799. };
  71800. }
  71801. declare module BABYLON {
  71802. /**
  71803. * This represents a particle system in Babylon.
  71804. * 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.
  71805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71806. * @example https://doc.babylonjs.com/babylon101/particles
  71807. */
  71808. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71809. /**
  71810. * Billboard mode will only apply to Y axis
  71811. */
  71812. static readonly BILLBOARDMODE_Y: number;
  71813. /**
  71814. * Billboard mode will apply to all axes
  71815. */
  71816. static readonly BILLBOARDMODE_ALL: number;
  71817. /**
  71818. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71819. */
  71820. static readonly BILLBOARDMODE_STRETCHED: number;
  71821. /**
  71822. * This function can be defined to provide custom update for active particles.
  71823. * This function will be called instead of regular update (age, position, color, etc.).
  71824. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71825. */
  71826. updateFunction: (particles: Particle[]) => void;
  71827. private _emitterWorldMatrix;
  71828. /**
  71829. * This function can be defined to specify initial direction for every new particle.
  71830. * It by default use the emitterType defined function
  71831. */
  71832. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71833. /**
  71834. * This function can be defined to specify initial position for every new particle.
  71835. * It by default use the emitterType defined function
  71836. */
  71837. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71838. /**
  71839. * @hidden
  71840. */
  71841. _inheritedVelocityOffset: Vector3;
  71842. /**
  71843. * An event triggered when the system is disposed
  71844. */
  71845. onDisposeObservable: Observable<ParticleSystem>;
  71846. private _onDisposeObserver;
  71847. /**
  71848. * Sets a callback that will be triggered when the system is disposed
  71849. */
  71850. onDispose: () => void;
  71851. private _particles;
  71852. private _epsilon;
  71853. private _capacity;
  71854. private _stockParticles;
  71855. private _newPartsExcess;
  71856. private _vertexData;
  71857. private _vertexBuffer;
  71858. private _vertexBuffers;
  71859. private _spriteBuffer;
  71860. private _indexBuffer;
  71861. private _effect;
  71862. private _customEffect;
  71863. private _cachedDefines;
  71864. private _scaledColorStep;
  71865. private _colorDiff;
  71866. private _scaledDirection;
  71867. private _scaledGravity;
  71868. private _currentRenderId;
  71869. private _alive;
  71870. private _useInstancing;
  71871. private _started;
  71872. private _stopped;
  71873. private _actualFrame;
  71874. private _scaledUpdateSpeed;
  71875. private _vertexBufferSize;
  71876. /** @hidden */
  71877. _currentEmitRateGradient: Nullable<FactorGradient>;
  71878. /** @hidden */
  71879. _currentEmitRate1: number;
  71880. /** @hidden */
  71881. _currentEmitRate2: number;
  71882. /** @hidden */
  71883. _currentStartSizeGradient: Nullable<FactorGradient>;
  71884. /** @hidden */
  71885. _currentStartSize1: number;
  71886. /** @hidden */
  71887. _currentStartSize2: number;
  71888. private readonly _rawTextureWidth;
  71889. private _rampGradientsTexture;
  71890. private _useRampGradients;
  71891. /** Gets or sets a boolean indicating that ramp gradients must be used
  71892. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71893. */
  71894. useRampGradients: boolean;
  71895. /**
  71896. * 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.
  71897. * 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: [])
  71898. */
  71899. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71900. private _subEmitters;
  71901. /**
  71902. * @hidden
  71903. * If the particle systems emitter should be disposed when the particle system is disposed
  71904. */
  71905. _disposeEmitterOnDispose: boolean;
  71906. /**
  71907. * The current active Sub-systems, this property is used by the root particle system only.
  71908. */
  71909. activeSubSystems: Array<ParticleSystem>;
  71910. private _rootParticleSystem;
  71911. /**
  71912. * Gets the current list of active particles
  71913. */
  71914. readonly particles: Particle[];
  71915. /**
  71916. * Returns the string "ParticleSystem"
  71917. * @returns a string containing the class name
  71918. */
  71919. getClassName(): string;
  71920. /**
  71921. * Instantiates a particle system.
  71922. * 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.
  71923. * @param name The name of the particle system
  71924. * @param capacity The max number of particles alive at the same time
  71925. * @param scene The scene the particle system belongs to
  71926. * @param customEffect a custom effect used to change the way particles are rendered by default
  71927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71928. * @param epsilon Offset used to render the particles
  71929. */
  71930. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71931. private _addFactorGradient;
  71932. private _removeFactorGradient;
  71933. /**
  71934. * Adds a new life time gradient
  71935. * @param gradient defines the gradient to use (between 0 and 1)
  71936. * @param factor defines the life time factor to affect to the specified gradient
  71937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71938. * @returns the current particle system
  71939. */
  71940. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71941. /**
  71942. * Remove a specific life time gradient
  71943. * @param gradient defines the gradient to remove
  71944. * @returns the current particle system
  71945. */
  71946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71947. /**
  71948. * Adds a new size gradient
  71949. * @param gradient defines the gradient to use (between 0 and 1)
  71950. * @param factor defines the size factor to affect to the specified gradient
  71951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71952. * @returns the current particle system
  71953. */
  71954. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71955. /**
  71956. * Remove a specific size gradient
  71957. * @param gradient defines the gradient to remove
  71958. * @returns the current particle system
  71959. */
  71960. removeSizeGradient(gradient: number): IParticleSystem;
  71961. /**
  71962. * Adds a new color remap gradient
  71963. * @param gradient defines the gradient to use (between 0 and 1)
  71964. * @param min defines the color remap minimal range
  71965. * @param max defines the color remap maximal range
  71966. * @returns the current particle system
  71967. */
  71968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71969. /**
  71970. * Remove a specific color remap gradient
  71971. * @param gradient defines the gradient to remove
  71972. * @returns the current particle system
  71973. */
  71974. removeColorRemapGradient(gradient: number): IParticleSystem;
  71975. /**
  71976. * Adds a new alpha remap gradient
  71977. * @param gradient defines the gradient to use (between 0 and 1)
  71978. * @param min defines the alpha remap minimal range
  71979. * @param max defines the alpha remap maximal range
  71980. * @returns the current particle system
  71981. */
  71982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71983. /**
  71984. * Remove a specific alpha remap gradient
  71985. * @param gradient defines the gradient to remove
  71986. * @returns the current particle system
  71987. */
  71988. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71989. /**
  71990. * Adds a new angular speed gradient
  71991. * @param gradient defines the gradient to use (between 0 and 1)
  71992. * @param factor defines the angular speed to affect to the specified gradient
  71993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71994. * @returns the current particle system
  71995. */
  71996. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71997. /**
  71998. * Remove a specific angular speed gradient
  71999. * @param gradient defines the gradient to remove
  72000. * @returns the current particle system
  72001. */
  72002. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72003. /**
  72004. * Adds a new velocity gradient
  72005. * @param gradient defines the gradient to use (between 0 and 1)
  72006. * @param factor defines the velocity to affect to the specified gradient
  72007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72008. * @returns the current particle system
  72009. */
  72010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72011. /**
  72012. * Remove a specific velocity gradient
  72013. * @param gradient defines the gradient to remove
  72014. * @returns the current particle system
  72015. */
  72016. removeVelocityGradient(gradient: number): IParticleSystem;
  72017. /**
  72018. * Adds a new limit velocity gradient
  72019. * @param gradient defines the gradient to use (between 0 and 1)
  72020. * @param factor defines the limit velocity value to affect to the specified gradient
  72021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72022. * @returns the current particle system
  72023. */
  72024. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72025. /**
  72026. * Remove a specific limit velocity gradient
  72027. * @param gradient defines the gradient to remove
  72028. * @returns the current particle system
  72029. */
  72030. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72031. /**
  72032. * Adds a new drag gradient
  72033. * @param gradient defines the gradient to use (between 0 and 1)
  72034. * @param factor defines the drag value to affect to the specified gradient
  72035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72036. * @returns the current particle system
  72037. */
  72038. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72039. /**
  72040. * Remove a specific drag gradient
  72041. * @param gradient defines the gradient to remove
  72042. * @returns the current particle system
  72043. */
  72044. removeDragGradient(gradient: number): IParticleSystem;
  72045. /**
  72046. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72047. * @param gradient defines the gradient to use (between 0 and 1)
  72048. * @param factor defines the emit rate value to affect to the specified gradient
  72049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72050. * @returns the current particle system
  72051. */
  72052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72053. /**
  72054. * Remove a specific emit rate gradient
  72055. * @param gradient defines the gradient to remove
  72056. * @returns the current particle system
  72057. */
  72058. removeEmitRateGradient(gradient: number): IParticleSystem;
  72059. /**
  72060. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72061. * @param gradient defines the gradient to use (between 0 and 1)
  72062. * @param factor defines the start size value to affect to the specified gradient
  72063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72064. * @returns the current particle system
  72065. */
  72066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72067. /**
  72068. * Remove a specific start size gradient
  72069. * @param gradient defines the gradient to remove
  72070. * @returns the current particle system
  72071. */
  72072. removeStartSizeGradient(gradient: number): IParticleSystem;
  72073. private _createRampGradientTexture;
  72074. /**
  72075. * Gets the current list of ramp gradients.
  72076. * You must use addRampGradient and removeRampGradient to udpate this list
  72077. * @returns the list of ramp gradients
  72078. */
  72079. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72080. /**
  72081. * Adds a new ramp gradient used to remap particle colors
  72082. * @param gradient defines the gradient to use (between 0 and 1)
  72083. * @param color defines the color to affect to the specified gradient
  72084. * @returns the current particle system
  72085. */
  72086. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72087. /**
  72088. * Remove a specific ramp gradient
  72089. * @param gradient defines the gradient to remove
  72090. * @returns the current particle system
  72091. */
  72092. removeRampGradient(gradient: number): ParticleSystem;
  72093. /**
  72094. * Adds a new color gradient
  72095. * @param gradient defines the gradient to use (between 0 and 1)
  72096. * @param color1 defines the color to affect to the specified gradient
  72097. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72098. * @returns this particle system
  72099. */
  72100. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72101. /**
  72102. * Remove a specific color gradient
  72103. * @param gradient defines the gradient to remove
  72104. * @returns this particle system
  72105. */
  72106. removeColorGradient(gradient: number): IParticleSystem;
  72107. private _fetchR;
  72108. protected _reset(): void;
  72109. private _resetEffect;
  72110. private _createVertexBuffers;
  72111. private _createIndexBuffer;
  72112. /**
  72113. * Gets the maximum number of particles active at the same time.
  72114. * @returns The max number of active particles.
  72115. */
  72116. getCapacity(): number;
  72117. /**
  72118. * Gets whether there are still active particles in the system.
  72119. * @returns True if it is alive, otherwise false.
  72120. */
  72121. isAlive(): boolean;
  72122. /**
  72123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72124. * @returns True if it has been started, otherwise false.
  72125. */
  72126. isStarted(): boolean;
  72127. private _prepareSubEmitterInternalArray;
  72128. /**
  72129. * Starts the particle system and begins to emit
  72130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72131. */
  72132. start(delay?: number): void;
  72133. /**
  72134. * Stops the particle system.
  72135. * @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.
  72136. */
  72137. stop(stopSubEmitters?: boolean): void;
  72138. /**
  72139. * Remove all active particles
  72140. */
  72141. reset(): void;
  72142. /**
  72143. * @hidden (for internal use only)
  72144. */
  72145. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72146. /**
  72147. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72148. * Its lifetime will start back at 0.
  72149. */
  72150. recycleParticle: (particle: Particle) => void;
  72151. private _stopSubEmitters;
  72152. private _createParticle;
  72153. private _removeFromRoot;
  72154. private _emitFromParticle;
  72155. private _update;
  72156. /** @hidden */
  72157. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72158. /** @hidden */
  72159. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72160. /** @hidden */
  72161. private _getEffect;
  72162. /**
  72163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72164. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72165. */
  72166. animate(preWarmOnly?: boolean): void;
  72167. private _appendParticleVertices;
  72168. /**
  72169. * Rebuilds the particle system.
  72170. */
  72171. rebuild(): void;
  72172. /**
  72173. * Is this system ready to be used/rendered
  72174. * @return true if the system is ready
  72175. */
  72176. isReady(): boolean;
  72177. private _render;
  72178. /**
  72179. * Renders the particle system in its current state.
  72180. * @returns the current number of particles
  72181. */
  72182. render(): number;
  72183. /**
  72184. * Disposes the particle system and free the associated resources
  72185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72186. */
  72187. dispose(disposeTexture?: boolean): void;
  72188. /**
  72189. * Clones the particle system.
  72190. * @param name The name of the cloned object
  72191. * @param newEmitter The new emitter to use
  72192. * @returns the cloned particle system
  72193. */
  72194. clone(name: string, newEmitter: any): ParticleSystem;
  72195. /**
  72196. * Serializes the particle system to a JSON object.
  72197. * @returns the JSON object
  72198. */
  72199. serialize(): any;
  72200. /** @hidden */
  72201. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72202. /** @hidden */
  72203. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72204. /**
  72205. * Parses a JSON object to create a particle system.
  72206. * @param parsedParticleSystem The JSON object to parse
  72207. * @param scene The scene to create the particle system in
  72208. * @param rootUrl The root url to use to load external dependencies like texture
  72209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72210. * @returns the Parsed particle system
  72211. */
  72212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72213. }
  72214. }
  72215. declare module BABYLON {
  72216. /**
  72217. * A particle represents one of the element emitted by a particle system.
  72218. * This is mainly define by its coordinates, direction, velocity and age.
  72219. */
  72220. export class Particle {
  72221. /**
  72222. * The particle system the particle belongs to.
  72223. */
  72224. particleSystem: ParticleSystem;
  72225. private static _Count;
  72226. /**
  72227. * Unique ID of the particle
  72228. */
  72229. id: number;
  72230. /**
  72231. * The world position of the particle in the scene.
  72232. */
  72233. position: Vector3;
  72234. /**
  72235. * The world direction of the particle in the scene.
  72236. */
  72237. direction: Vector3;
  72238. /**
  72239. * The color of the particle.
  72240. */
  72241. color: Color4;
  72242. /**
  72243. * The color change of the particle per step.
  72244. */
  72245. colorStep: Color4;
  72246. /**
  72247. * Defines how long will the life of the particle be.
  72248. */
  72249. lifeTime: number;
  72250. /**
  72251. * The current age of the particle.
  72252. */
  72253. age: number;
  72254. /**
  72255. * The current size of the particle.
  72256. */
  72257. size: number;
  72258. /**
  72259. * The current scale of the particle.
  72260. */
  72261. scale: Vector2;
  72262. /**
  72263. * The current angle of the particle.
  72264. */
  72265. angle: number;
  72266. /**
  72267. * Defines how fast is the angle changing.
  72268. */
  72269. angularSpeed: number;
  72270. /**
  72271. * Defines the cell index used by the particle to be rendered from a sprite.
  72272. */
  72273. cellIndex: number;
  72274. /**
  72275. * The information required to support color remapping
  72276. */
  72277. remapData: Vector4;
  72278. /** @hidden */
  72279. _randomCellOffset?: number;
  72280. /** @hidden */
  72281. _initialDirection: Nullable<Vector3>;
  72282. /** @hidden */
  72283. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72284. /** @hidden */
  72285. _initialStartSpriteCellID: number;
  72286. /** @hidden */
  72287. _initialEndSpriteCellID: number;
  72288. /** @hidden */
  72289. _currentColorGradient: Nullable<ColorGradient>;
  72290. /** @hidden */
  72291. _currentColor1: Color4;
  72292. /** @hidden */
  72293. _currentColor2: Color4;
  72294. /** @hidden */
  72295. _currentSizeGradient: Nullable<FactorGradient>;
  72296. /** @hidden */
  72297. _currentSize1: number;
  72298. /** @hidden */
  72299. _currentSize2: number;
  72300. /** @hidden */
  72301. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72302. /** @hidden */
  72303. _currentAngularSpeed1: number;
  72304. /** @hidden */
  72305. _currentAngularSpeed2: number;
  72306. /** @hidden */
  72307. _currentVelocityGradient: Nullable<FactorGradient>;
  72308. /** @hidden */
  72309. _currentVelocity1: number;
  72310. /** @hidden */
  72311. _currentVelocity2: number;
  72312. /** @hidden */
  72313. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72314. /** @hidden */
  72315. _currentLimitVelocity1: number;
  72316. /** @hidden */
  72317. _currentLimitVelocity2: number;
  72318. /** @hidden */
  72319. _currentDragGradient: Nullable<FactorGradient>;
  72320. /** @hidden */
  72321. _currentDrag1: number;
  72322. /** @hidden */
  72323. _currentDrag2: number;
  72324. /** @hidden */
  72325. _randomNoiseCoordinates1: Vector3;
  72326. /** @hidden */
  72327. _randomNoiseCoordinates2: Vector3;
  72328. /**
  72329. * Creates a new instance Particle
  72330. * @param particleSystem the particle system the particle belongs to
  72331. */
  72332. constructor(
  72333. /**
  72334. * The particle system the particle belongs to.
  72335. */
  72336. particleSystem: ParticleSystem);
  72337. private updateCellInfoFromSystem;
  72338. /**
  72339. * Defines how the sprite cell index is updated for the particle
  72340. */
  72341. updateCellIndex(): void;
  72342. /** @hidden */
  72343. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72344. /** @hidden */
  72345. _inheritParticleInfoToSubEmitters(): void;
  72346. /** @hidden */
  72347. _reset(): void;
  72348. /**
  72349. * Copy the properties of particle to another one.
  72350. * @param other the particle to copy the information to.
  72351. */
  72352. copyTo(other: Particle): void;
  72353. }
  72354. }
  72355. declare module BABYLON {
  72356. /**
  72357. * Particle emitter represents a volume emitting particles.
  72358. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72359. */
  72360. export interface IParticleEmitterType {
  72361. /**
  72362. * Called by the particle System when the direction is computed for the created particle.
  72363. * @param worldMatrix is the world matrix of the particle system
  72364. * @param directionToUpdate is the direction vector to update with the result
  72365. * @param particle is the particle we are computed the direction for
  72366. */
  72367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72368. /**
  72369. * Called by the particle System when the position is computed for the created particle.
  72370. * @param worldMatrix is the world matrix of the particle system
  72371. * @param positionToUpdate is the position vector to update with the result
  72372. * @param particle is the particle we are computed the position for
  72373. */
  72374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72375. /**
  72376. * Clones the current emitter and returns a copy of it
  72377. * @returns the new emitter
  72378. */
  72379. clone(): IParticleEmitterType;
  72380. /**
  72381. * Called by the GPUParticleSystem to setup the update shader
  72382. * @param effect defines the update shader
  72383. */
  72384. applyToShader(effect: Effect): void;
  72385. /**
  72386. * Returns a string to use to update the GPU particles update shader
  72387. * @returns the effect defines string
  72388. */
  72389. getEffectDefines(): string;
  72390. /**
  72391. * Returns a string representing the class name
  72392. * @returns a string containing the class name
  72393. */
  72394. getClassName(): string;
  72395. /**
  72396. * Serializes the particle system to a JSON object.
  72397. * @returns the JSON object
  72398. */
  72399. serialize(): any;
  72400. /**
  72401. * Parse properties from a JSON object
  72402. * @param serializationObject defines the JSON object
  72403. */
  72404. parse(serializationObject: any): void;
  72405. }
  72406. }
  72407. declare module BABYLON {
  72408. /**
  72409. * Particle emitter emitting particles from the inside of a box.
  72410. * It emits the particles randomly between 2 given directions.
  72411. */
  72412. export class BoxParticleEmitter implements IParticleEmitterType {
  72413. /**
  72414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72415. */
  72416. direction1: Vector3;
  72417. /**
  72418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72419. */
  72420. direction2: Vector3;
  72421. /**
  72422. * 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.
  72423. */
  72424. minEmitBox: Vector3;
  72425. /**
  72426. * 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.
  72427. */
  72428. maxEmitBox: Vector3;
  72429. /**
  72430. * Creates a new instance BoxParticleEmitter
  72431. */
  72432. constructor();
  72433. /**
  72434. * Called by the particle System when the direction is computed for the created particle.
  72435. * @param worldMatrix is the world matrix of the particle system
  72436. * @param directionToUpdate is the direction vector to update with the result
  72437. * @param particle is the particle we are computed the direction for
  72438. */
  72439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72440. /**
  72441. * Called by the particle System when the position is computed for the created particle.
  72442. * @param worldMatrix is the world matrix of the particle system
  72443. * @param positionToUpdate is the position vector to update with the result
  72444. * @param particle is the particle we are computed the position for
  72445. */
  72446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72447. /**
  72448. * Clones the current emitter and returns a copy of it
  72449. * @returns the new emitter
  72450. */
  72451. clone(): BoxParticleEmitter;
  72452. /**
  72453. * Called by the GPUParticleSystem to setup the update shader
  72454. * @param effect defines the update shader
  72455. */
  72456. applyToShader(effect: Effect): void;
  72457. /**
  72458. * Returns a string to use to update the GPU particles update shader
  72459. * @returns a string containng the defines string
  72460. */
  72461. getEffectDefines(): string;
  72462. /**
  72463. * Returns the string "BoxParticleEmitter"
  72464. * @returns a string containing the class name
  72465. */
  72466. getClassName(): string;
  72467. /**
  72468. * Serializes the particle system to a JSON object.
  72469. * @returns the JSON object
  72470. */
  72471. serialize(): any;
  72472. /**
  72473. * Parse properties from a JSON object
  72474. * @param serializationObject defines the JSON object
  72475. */
  72476. parse(serializationObject: any): void;
  72477. }
  72478. }
  72479. declare module BABYLON {
  72480. /**
  72481. * Particle emitter emitting particles from the inside of a cone.
  72482. * It emits the particles alongside the cone volume from the base to the particle.
  72483. * The emission direction might be randomized.
  72484. */
  72485. export class ConeParticleEmitter implements IParticleEmitterType {
  72486. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72487. directionRandomizer: number;
  72488. private _radius;
  72489. private _angle;
  72490. private _height;
  72491. /**
  72492. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72493. */
  72494. radiusRange: number;
  72495. /**
  72496. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72497. */
  72498. heightRange: number;
  72499. /**
  72500. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72501. */
  72502. emitFromSpawnPointOnly: boolean;
  72503. /**
  72504. * Gets or sets the radius of the emission cone
  72505. */
  72506. radius: number;
  72507. /**
  72508. * Gets or sets the angle of the emission cone
  72509. */
  72510. angle: number;
  72511. private _buildHeight;
  72512. /**
  72513. * Creates a new instance ConeParticleEmitter
  72514. * @param radius the radius of the emission cone (1 by default)
  72515. * @param angle the cone base angle (PI by default)
  72516. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72517. */
  72518. constructor(radius?: number, angle?: number,
  72519. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72520. directionRandomizer?: number);
  72521. /**
  72522. * Called by the particle System when the direction is computed for the created particle.
  72523. * @param worldMatrix is the world matrix of the particle system
  72524. * @param directionToUpdate is the direction vector to update with the result
  72525. * @param particle is the particle we are computed the direction for
  72526. */
  72527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72528. /**
  72529. * Called by the particle System when the position is computed for the created particle.
  72530. * @param worldMatrix is the world matrix of the particle system
  72531. * @param positionToUpdate is the position vector to update with the result
  72532. * @param particle is the particle we are computed the position for
  72533. */
  72534. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72535. /**
  72536. * Clones the current emitter and returns a copy of it
  72537. * @returns the new emitter
  72538. */
  72539. clone(): ConeParticleEmitter;
  72540. /**
  72541. * Called by the GPUParticleSystem to setup the update shader
  72542. * @param effect defines the update shader
  72543. */
  72544. applyToShader(effect: Effect): void;
  72545. /**
  72546. * Returns a string to use to update the GPU particles update shader
  72547. * @returns a string containng the defines string
  72548. */
  72549. getEffectDefines(): string;
  72550. /**
  72551. * Returns the string "ConeParticleEmitter"
  72552. * @returns a string containing the class name
  72553. */
  72554. getClassName(): string;
  72555. /**
  72556. * Serializes the particle system to a JSON object.
  72557. * @returns the JSON object
  72558. */
  72559. serialize(): any;
  72560. /**
  72561. * Parse properties from a JSON object
  72562. * @param serializationObject defines the JSON object
  72563. */
  72564. parse(serializationObject: any): void;
  72565. }
  72566. }
  72567. declare module BABYLON {
  72568. /**
  72569. * Particle emitter emitting particles from the inside of a cylinder.
  72570. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72571. */
  72572. export class CylinderParticleEmitter implements IParticleEmitterType {
  72573. /**
  72574. * The radius of the emission cylinder.
  72575. */
  72576. radius: number;
  72577. /**
  72578. * The height of the emission cylinder.
  72579. */
  72580. height: number;
  72581. /**
  72582. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72583. */
  72584. radiusRange: number;
  72585. /**
  72586. * How much to randomize the particle direction [0-1].
  72587. */
  72588. directionRandomizer: number;
  72589. /**
  72590. * Creates a new instance CylinderParticleEmitter
  72591. * @param radius the radius of the emission cylinder (1 by default)
  72592. * @param height the height of the emission cylinder (1 by default)
  72593. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72594. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72595. */
  72596. constructor(
  72597. /**
  72598. * The radius of the emission cylinder.
  72599. */
  72600. radius?: number,
  72601. /**
  72602. * The height of the emission cylinder.
  72603. */
  72604. height?: number,
  72605. /**
  72606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72607. */
  72608. radiusRange?: number,
  72609. /**
  72610. * How much to randomize the particle direction [0-1].
  72611. */
  72612. directionRandomizer?: number);
  72613. /**
  72614. * Called by the particle System when the direction is computed for the created particle.
  72615. * @param worldMatrix is the world matrix of the particle system
  72616. * @param directionToUpdate is the direction vector to update with the result
  72617. * @param particle is the particle we are computed the direction for
  72618. */
  72619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72620. /**
  72621. * Called by the particle System when the position is computed for the created particle.
  72622. * @param worldMatrix is the world matrix of the particle system
  72623. * @param positionToUpdate is the position vector to update with the result
  72624. * @param particle is the particle we are computed the position for
  72625. */
  72626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72627. /**
  72628. * Clones the current emitter and returns a copy of it
  72629. * @returns the new emitter
  72630. */
  72631. clone(): CylinderParticleEmitter;
  72632. /**
  72633. * Called by the GPUParticleSystem to setup the update shader
  72634. * @param effect defines the update shader
  72635. */
  72636. applyToShader(effect: Effect): void;
  72637. /**
  72638. * Returns a string to use to update the GPU particles update shader
  72639. * @returns a string containng the defines string
  72640. */
  72641. getEffectDefines(): string;
  72642. /**
  72643. * Returns the string "CylinderParticleEmitter"
  72644. * @returns a string containing the class name
  72645. */
  72646. getClassName(): string;
  72647. /**
  72648. * Serializes the particle system to a JSON object.
  72649. * @returns the JSON object
  72650. */
  72651. serialize(): any;
  72652. /**
  72653. * Parse properties from a JSON object
  72654. * @param serializationObject defines the JSON object
  72655. */
  72656. parse(serializationObject: any): void;
  72657. }
  72658. /**
  72659. * Particle emitter emitting particles from the inside of a cylinder.
  72660. * It emits the particles randomly between two vectors.
  72661. */
  72662. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72663. /**
  72664. * The min limit of the emission direction.
  72665. */
  72666. direction1: Vector3;
  72667. /**
  72668. * The max limit of the emission direction.
  72669. */
  72670. direction2: Vector3;
  72671. /**
  72672. * Creates a new instance CylinderDirectedParticleEmitter
  72673. * @param radius the radius of the emission cylinder (1 by default)
  72674. * @param height the height of the emission cylinder (1 by default)
  72675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72676. * @param direction1 the min limit of the emission direction (up vector by default)
  72677. * @param direction2 the max limit of the emission direction (up vector by default)
  72678. */
  72679. constructor(radius?: number, height?: number, radiusRange?: number,
  72680. /**
  72681. * The min limit of the emission direction.
  72682. */
  72683. direction1?: Vector3,
  72684. /**
  72685. * The max limit of the emission direction.
  72686. */
  72687. direction2?: Vector3);
  72688. /**
  72689. * Called by the particle System when the direction is computed for the created particle.
  72690. * @param worldMatrix is the world matrix of the particle system
  72691. * @param directionToUpdate is the direction vector to update with the result
  72692. * @param particle is the particle we are computed the direction for
  72693. */
  72694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72695. /**
  72696. * Clones the current emitter and returns a copy of it
  72697. * @returns the new emitter
  72698. */
  72699. clone(): CylinderDirectedParticleEmitter;
  72700. /**
  72701. * Called by the GPUParticleSystem to setup the update shader
  72702. * @param effect defines the update shader
  72703. */
  72704. applyToShader(effect: Effect): void;
  72705. /**
  72706. * Returns a string to use to update the GPU particles update shader
  72707. * @returns a string containng the defines string
  72708. */
  72709. getEffectDefines(): string;
  72710. /**
  72711. * Returns the string "CylinderDirectedParticleEmitter"
  72712. * @returns a string containing the class name
  72713. */
  72714. getClassName(): string;
  72715. /**
  72716. * Serializes the particle system to a JSON object.
  72717. * @returns the JSON object
  72718. */
  72719. serialize(): any;
  72720. /**
  72721. * Parse properties from a JSON object
  72722. * @param serializationObject defines the JSON object
  72723. */
  72724. parse(serializationObject: any): void;
  72725. }
  72726. }
  72727. declare module BABYLON {
  72728. /**
  72729. * Particle emitter emitting particles from the inside of a hemisphere.
  72730. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72731. */
  72732. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72733. /**
  72734. * The radius of the emission hemisphere.
  72735. */
  72736. radius: number;
  72737. /**
  72738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72739. */
  72740. radiusRange: number;
  72741. /**
  72742. * How much to randomize the particle direction [0-1].
  72743. */
  72744. directionRandomizer: number;
  72745. /**
  72746. * Creates a new instance HemisphericParticleEmitter
  72747. * @param radius the radius of the emission hemisphere (1 by default)
  72748. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72749. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72750. */
  72751. constructor(
  72752. /**
  72753. * The radius of the emission hemisphere.
  72754. */
  72755. radius?: number,
  72756. /**
  72757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72758. */
  72759. radiusRange?: number,
  72760. /**
  72761. * How much to randomize the particle direction [0-1].
  72762. */
  72763. directionRandomizer?: number);
  72764. /**
  72765. * Called by the particle System when the direction is computed for the created particle.
  72766. * @param worldMatrix is the world matrix of the particle system
  72767. * @param directionToUpdate is the direction vector to update with the result
  72768. * @param particle is the particle we are computed the direction for
  72769. */
  72770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72771. /**
  72772. * Called by the particle System when the position is computed for the created particle.
  72773. * @param worldMatrix is the world matrix of the particle system
  72774. * @param positionToUpdate is the position vector to update with the result
  72775. * @param particle is the particle we are computed the position for
  72776. */
  72777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72778. /**
  72779. * Clones the current emitter and returns a copy of it
  72780. * @returns the new emitter
  72781. */
  72782. clone(): HemisphericParticleEmitter;
  72783. /**
  72784. * Called by the GPUParticleSystem to setup the update shader
  72785. * @param effect defines the update shader
  72786. */
  72787. applyToShader(effect: Effect): void;
  72788. /**
  72789. * Returns a string to use to update the GPU particles update shader
  72790. * @returns a string containng the defines string
  72791. */
  72792. getEffectDefines(): string;
  72793. /**
  72794. * Returns the string "HemisphericParticleEmitter"
  72795. * @returns a string containing the class name
  72796. */
  72797. getClassName(): string;
  72798. /**
  72799. * Serializes the particle system to a JSON object.
  72800. * @returns the JSON object
  72801. */
  72802. serialize(): any;
  72803. /**
  72804. * Parse properties from a JSON object
  72805. * @param serializationObject defines the JSON object
  72806. */
  72807. parse(serializationObject: any): void;
  72808. }
  72809. }
  72810. declare module BABYLON {
  72811. /**
  72812. * Particle emitter emitting particles from a point.
  72813. * It emits the particles randomly between 2 given directions.
  72814. */
  72815. export class PointParticleEmitter implements IParticleEmitterType {
  72816. /**
  72817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72818. */
  72819. direction1: Vector3;
  72820. /**
  72821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72822. */
  72823. direction2: Vector3;
  72824. /**
  72825. * Creates a new instance PointParticleEmitter
  72826. */
  72827. constructor();
  72828. /**
  72829. * Called by the particle System when the direction is computed for the created particle.
  72830. * @param worldMatrix is the world matrix of the particle system
  72831. * @param directionToUpdate is the direction vector to update with the result
  72832. * @param particle is the particle we are computed the direction for
  72833. */
  72834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72835. /**
  72836. * Called by the particle System when the position is computed for the created particle.
  72837. * @param worldMatrix is the world matrix of the particle system
  72838. * @param positionToUpdate is the position vector to update with the result
  72839. * @param particle is the particle we are computed the position for
  72840. */
  72841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72842. /**
  72843. * Clones the current emitter and returns a copy of it
  72844. * @returns the new emitter
  72845. */
  72846. clone(): PointParticleEmitter;
  72847. /**
  72848. * Called by the GPUParticleSystem to setup the update shader
  72849. * @param effect defines the update shader
  72850. */
  72851. applyToShader(effect: Effect): void;
  72852. /**
  72853. * Returns a string to use to update the GPU particles update shader
  72854. * @returns a string containng the defines string
  72855. */
  72856. getEffectDefines(): string;
  72857. /**
  72858. * Returns the string "PointParticleEmitter"
  72859. * @returns a string containing the class name
  72860. */
  72861. getClassName(): string;
  72862. /**
  72863. * Serializes the particle system to a JSON object.
  72864. * @returns the JSON object
  72865. */
  72866. serialize(): any;
  72867. /**
  72868. * Parse properties from a JSON object
  72869. * @param serializationObject defines the JSON object
  72870. */
  72871. parse(serializationObject: any): void;
  72872. }
  72873. }
  72874. declare module BABYLON {
  72875. /**
  72876. * Particle emitter emitting particles from the inside of a sphere.
  72877. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72878. */
  72879. export class SphereParticleEmitter implements IParticleEmitterType {
  72880. /**
  72881. * The radius of the emission sphere.
  72882. */
  72883. radius: number;
  72884. /**
  72885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72886. */
  72887. radiusRange: number;
  72888. /**
  72889. * How much to randomize the particle direction [0-1].
  72890. */
  72891. directionRandomizer: number;
  72892. /**
  72893. * Creates a new instance SphereParticleEmitter
  72894. * @param radius the radius of the emission sphere (1 by default)
  72895. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72897. */
  72898. constructor(
  72899. /**
  72900. * The radius of the emission sphere.
  72901. */
  72902. radius?: number,
  72903. /**
  72904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72905. */
  72906. radiusRange?: number,
  72907. /**
  72908. * How much to randomize the particle direction [0-1].
  72909. */
  72910. directionRandomizer?: number);
  72911. /**
  72912. * Called by the particle System when the direction is computed for the created particle.
  72913. * @param worldMatrix is the world matrix of the particle system
  72914. * @param directionToUpdate is the direction vector to update with the result
  72915. * @param particle is the particle we are computed the direction for
  72916. */
  72917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72918. /**
  72919. * Called by the particle System when the position is computed for the created particle.
  72920. * @param worldMatrix is the world matrix of the particle system
  72921. * @param positionToUpdate is the position vector to update with the result
  72922. * @param particle is the particle we are computed the position for
  72923. */
  72924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72925. /**
  72926. * Clones the current emitter and returns a copy of it
  72927. * @returns the new emitter
  72928. */
  72929. clone(): SphereParticleEmitter;
  72930. /**
  72931. * Called by the GPUParticleSystem to setup the update shader
  72932. * @param effect defines the update shader
  72933. */
  72934. applyToShader(effect: Effect): void;
  72935. /**
  72936. * Returns a string to use to update the GPU particles update shader
  72937. * @returns a string containng the defines string
  72938. */
  72939. getEffectDefines(): string;
  72940. /**
  72941. * Returns the string "SphereParticleEmitter"
  72942. * @returns a string containing the class name
  72943. */
  72944. getClassName(): string;
  72945. /**
  72946. * Serializes the particle system to a JSON object.
  72947. * @returns the JSON object
  72948. */
  72949. serialize(): any;
  72950. /**
  72951. * Parse properties from a JSON object
  72952. * @param serializationObject defines the JSON object
  72953. */
  72954. parse(serializationObject: any): void;
  72955. }
  72956. /**
  72957. * Particle emitter emitting particles from the inside of a sphere.
  72958. * It emits the particles randomly between two vectors.
  72959. */
  72960. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72961. /**
  72962. * The min limit of the emission direction.
  72963. */
  72964. direction1: Vector3;
  72965. /**
  72966. * The max limit of the emission direction.
  72967. */
  72968. direction2: Vector3;
  72969. /**
  72970. * Creates a new instance SphereDirectedParticleEmitter
  72971. * @param radius the radius of the emission sphere (1 by default)
  72972. * @param direction1 the min limit of the emission direction (up vector by default)
  72973. * @param direction2 the max limit of the emission direction (up vector by default)
  72974. */
  72975. constructor(radius?: number,
  72976. /**
  72977. * The min limit of the emission direction.
  72978. */
  72979. direction1?: Vector3,
  72980. /**
  72981. * The max limit of the emission direction.
  72982. */
  72983. direction2?: Vector3);
  72984. /**
  72985. * Called by the particle System when the direction is computed for the created particle.
  72986. * @param worldMatrix is the world matrix of the particle system
  72987. * @param directionToUpdate is the direction vector to update with the result
  72988. * @param particle is the particle we are computed the direction for
  72989. */
  72990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72991. /**
  72992. * Clones the current emitter and returns a copy of it
  72993. * @returns the new emitter
  72994. */
  72995. clone(): SphereDirectedParticleEmitter;
  72996. /**
  72997. * Called by the GPUParticleSystem to setup the update shader
  72998. * @param effect defines the update shader
  72999. */
  73000. applyToShader(effect: Effect): void;
  73001. /**
  73002. * Returns a string to use to update the GPU particles update shader
  73003. * @returns a string containng the defines string
  73004. */
  73005. getEffectDefines(): string;
  73006. /**
  73007. * Returns the string "SphereDirectedParticleEmitter"
  73008. * @returns a string containing the class name
  73009. */
  73010. getClassName(): string;
  73011. /**
  73012. * Serializes the particle system to a JSON object.
  73013. * @returns the JSON object
  73014. */
  73015. serialize(): any;
  73016. /**
  73017. * Parse properties from a JSON object
  73018. * @param serializationObject defines the JSON object
  73019. */
  73020. parse(serializationObject: any): void;
  73021. }
  73022. }
  73023. declare module BABYLON {
  73024. /**
  73025. * Interface representing a particle system in Babylon.js.
  73026. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73027. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73028. */
  73029. export interface IParticleSystem {
  73030. /**
  73031. * List of animations used by the particle system.
  73032. */
  73033. animations: Animation[];
  73034. /**
  73035. * The id of the Particle system.
  73036. */
  73037. id: string;
  73038. /**
  73039. * The name of the Particle system.
  73040. */
  73041. name: string;
  73042. /**
  73043. * The emitter represents the Mesh or position we are attaching the particle system to.
  73044. */
  73045. emitter: Nullable<AbstractMesh | Vector3>;
  73046. /**
  73047. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73048. */
  73049. isBillboardBased: boolean;
  73050. /**
  73051. * The rendering group used by the Particle system to chose when to render.
  73052. */
  73053. renderingGroupId: number;
  73054. /**
  73055. * The layer mask we are rendering the particles through.
  73056. */
  73057. layerMask: number;
  73058. /**
  73059. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73060. */
  73061. updateSpeed: number;
  73062. /**
  73063. * The amount of time the particle system is running (depends of the overall update speed).
  73064. */
  73065. targetStopDuration: number;
  73066. /**
  73067. * The texture used to render each particle. (this can be a spritesheet)
  73068. */
  73069. particleTexture: Nullable<Texture>;
  73070. /**
  73071. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73072. */
  73073. blendMode: number;
  73074. /**
  73075. * Minimum life time of emitting particles.
  73076. */
  73077. minLifeTime: number;
  73078. /**
  73079. * Maximum life time of emitting particles.
  73080. */
  73081. maxLifeTime: number;
  73082. /**
  73083. * Minimum Size of emitting particles.
  73084. */
  73085. minSize: number;
  73086. /**
  73087. * Maximum Size of emitting particles.
  73088. */
  73089. maxSize: number;
  73090. /**
  73091. * Minimum scale of emitting particles on X axis.
  73092. */
  73093. minScaleX: number;
  73094. /**
  73095. * Maximum scale of emitting particles on X axis.
  73096. */
  73097. maxScaleX: number;
  73098. /**
  73099. * Minimum scale of emitting particles on Y axis.
  73100. */
  73101. minScaleY: number;
  73102. /**
  73103. * Maximum scale of emitting particles on Y axis.
  73104. */
  73105. maxScaleY: number;
  73106. /**
  73107. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73108. */
  73109. color1: Color4;
  73110. /**
  73111. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73112. */
  73113. color2: Color4;
  73114. /**
  73115. * Color the particle will have at the end of its lifetime.
  73116. */
  73117. colorDead: Color4;
  73118. /**
  73119. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73120. */
  73121. emitRate: number;
  73122. /**
  73123. * You can use gravity if you want to give an orientation to your particles.
  73124. */
  73125. gravity: Vector3;
  73126. /**
  73127. * Minimum power of emitting particles.
  73128. */
  73129. minEmitPower: number;
  73130. /**
  73131. * Maximum power of emitting particles.
  73132. */
  73133. maxEmitPower: number;
  73134. /**
  73135. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73136. */
  73137. minAngularSpeed: number;
  73138. /**
  73139. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73140. */
  73141. maxAngularSpeed: number;
  73142. /**
  73143. * Gets or sets the minimal initial rotation in radians.
  73144. */
  73145. minInitialRotation: number;
  73146. /**
  73147. * Gets or sets the maximal initial rotation in radians.
  73148. */
  73149. maxInitialRotation: number;
  73150. /**
  73151. * The particle emitter type defines the emitter used by the particle system.
  73152. * It can be for example box, sphere, or cone...
  73153. */
  73154. particleEmitterType: Nullable<IParticleEmitterType>;
  73155. /**
  73156. * Defines the delay in milliseconds before starting the system (0 by default)
  73157. */
  73158. startDelay: number;
  73159. /**
  73160. * 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
  73161. */
  73162. preWarmCycles: number;
  73163. /**
  73164. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73165. */
  73166. preWarmStepOffset: number;
  73167. /**
  73168. * 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)
  73169. */
  73170. spriteCellChangeSpeed: number;
  73171. /**
  73172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73173. */
  73174. startSpriteCellID: number;
  73175. /**
  73176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73177. */
  73178. endSpriteCellID: number;
  73179. /**
  73180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73181. */
  73182. spriteCellWidth: number;
  73183. /**
  73184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73185. */
  73186. spriteCellHeight: number;
  73187. /**
  73188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73189. */
  73190. spriteRandomStartCell: boolean;
  73191. /**
  73192. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73193. */
  73194. isAnimationSheetEnabled: boolean;
  73195. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73196. translationPivot: Vector2;
  73197. /**
  73198. * Gets or sets a texture used to add random noise to particle positions
  73199. */
  73200. noiseTexture: Nullable<BaseTexture>;
  73201. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73202. noiseStrength: Vector3;
  73203. /**
  73204. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73205. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73206. */
  73207. billboardMode: number;
  73208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73209. limitVelocityDamping: number;
  73210. /**
  73211. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73212. */
  73213. beginAnimationOnStart: boolean;
  73214. /**
  73215. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73216. */
  73217. beginAnimationFrom: number;
  73218. /**
  73219. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73220. */
  73221. beginAnimationTo: number;
  73222. /**
  73223. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73224. */
  73225. beginAnimationLoop: boolean;
  73226. /**
  73227. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73228. */
  73229. disposeOnStop: boolean;
  73230. /**
  73231. * Gets the maximum number of particles active at the same time.
  73232. * @returns The max number of active particles.
  73233. */
  73234. getCapacity(): number;
  73235. /**
  73236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73237. * @returns True if it has been started, otherwise false.
  73238. */
  73239. isStarted(): boolean;
  73240. /**
  73241. * Animates the particle system for this frame.
  73242. */
  73243. animate(): void;
  73244. /**
  73245. * Renders the particle system in its current state.
  73246. * @returns the current number of particles
  73247. */
  73248. render(): number;
  73249. /**
  73250. * Dispose the particle system and frees its associated resources.
  73251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73252. */
  73253. dispose(disposeTexture?: boolean): void;
  73254. /**
  73255. * Clones the particle system.
  73256. * @param name The name of the cloned object
  73257. * @param newEmitter The new emitter to use
  73258. * @returns the cloned particle system
  73259. */
  73260. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73261. /**
  73262. * Serializes the particle system to a JSON object.
  73263. * @returns the JSON object
  73264. */
  73265. serialize(): any;
  73266. /**
  73267. * Rebuild the particle system
  73268. */
  73269. rebuild(): void;
  73270. /**
  73271. * Starts the particle system and begins to emit
  73272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73273. */
  73274. start(delay?: number): void;
  73275. /**
  73276. * Stops the particle system.
  73277. */
  73278. stop(): void;
  73279. /**
  73280. * Remove all active particles
  73281. */
  73282. reset(): void;
  73283. /**
  73284. * Is this system ready to be used/rendered
  73285. * @return true if the system is ready
  73286. */
  73287. isReady(): boolean;
  73288. /**
  73289. * Adds a new color gradient
  73290. * @param gradient defines the gradient to use (between 0 and 1)
  73291. * @param color1 defines the color to affect to the specified gradient
  73292. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73293. * @returns the current particle system
  73294. */
  73295. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73296. /**
  73297. * Remove a specific color gradient
  73298. * @param gradient defines the gradient to remove
  73299. * @returns the current particle system
  73300. */
  73301. removeColorGradient(gradient: number): IParticleSystem;
  73302. /**
  73303. * Adds a new size gradient
  73304. * @param gradient defines the gradient to use (between 0 and 1)
  73305. * @param factor defines the size factor to affect to the specified gradient
  73306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73307. * @returns the current particle system
  73308. */
  73309. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73310. /**
  73311. * Remove a specific size gradient
  73312. * @param gradient defines the gradient to remove
  73313. * @returns the current particle system
  73314. */
  73315. removeSizeGradient(gradient: number): IParticleSystem;
  73316. /**
  73317. * Gets the current list of color gradients.
  73318. * You must use addColorGradient and removeColorGradient to udpate this list
  73319. * @returns the list of color gradients
  73320. */
  73321. getColorGradients(): Nullable<Array<ColorGradient>>;
  73322. /**
  73323. * Gets the current list of size gradients.
  73324. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73325. * @returns the list of size gradients
  73326. */
  73327. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73328. /**
  73329. * Gets the current list of angular speed gradients.
  73330. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73331. * @returns the list of angular speed gradients
  73332. */
  73333. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73334. /**
  73335. * Adds a new angular speed gradient
  73336. * @param gradient defines the gradient to use (between 0 and 1)
  73337. * @param factor defines the angular speed to affect to the specified gradient
  73338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73339. * @returns the current particle system
  73340. */
  73341. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73342. /**
  73343. * Remove a specific angular speed gradient
  73344. * @param gradient defines the gradient to remove
  73345. * @returns the current particle system
  73346. */
  73347. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73348. /**
  73349. * Gets the current list of velocity gradients.
  73350. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73351. * @returns the list of velocity gradients
  73352. */
  73353. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73354. /**
  73355. * Adds a new velocity gradient
  73356. * @param gradient defines the gradient to use (between 0 and 1)
  73357. * @param factor defines the velocity to affect to the specified gradient
  73358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73359. * @returns the current particle system
  73360. */
  73361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73362. /**
  73363. * Remove a specific velocity gradient
  73364. * @param gradient defines the gradient to remove
  73365. * @returns the current particle system
  73366. */
  73367. removeVelocityGradient(gradient: number): IParticleSystem;
  73368. /**
  73369. * Gets the current list of limit velocity gradients.
  73370. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73371. * @returns the list of limit velocity gradients
  73372. */
  73373. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73374. /**
  73375. * Adds a new limit velocity gradient
  73376. * @param gradient defines the gradient to use (between 0 and 1)
  73377. * @param factor defines the limit velocity to affect to the specified gradient
  73378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73379. * @returns the current particle system
  73380. */
  73381. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73382. /**
  73383. * Remove a specific limit velocity gradient
  73384. * @param gradient defines the gradient to remove
  73385. * @returns the current particle system
  73386. */
  73387. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73388. /**
  73389. * Adds a new drag gradient
  73390. * @param gradient defines the gradient to use (between 0 and 1)
  73391. * @param factor defines the drag to affect to the specified gradient
  73392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73393. * @returns the current particle system
  73394. */
  73395. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73396. /**
  73397. * Remove a specific drag gradient
  73398. * @param gradient defines the gradient to remove
  73399. * @returns the current particle system
  73400. */
  73401. removeDragGradient(gradient: number): IParticleSystem;
  73402. /**
  73403. * Gets the current list of drag gradients.
  73404. * You must use addDragGradient and removeDragGradient to udpate this list
  73405. * @returns the list of drag gradients
  73406. */
  73407. getDragGradients(): Nullable<Array<FactorGradient>>;
  73408. /**
  73409. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73410. * @param gradient defines the gradient to use (between 0 and 1)
  73411. * @param factor defines the emit rate to affect to the specified gradient
  73412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73413. * @returns the current particle system
  73414. */
  73415. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73416. /**
  73417. * Remove a specific emit rate gradient
  73418. * @param gradient defines the gradient to remove
  73419. * @returns the current particle system
  73420. */
  73421. removeEmitRateGradient(gradient: number): IParticleSystem;
  73422. /**
  73423. * Gets the current list of emit rate gradients.
  73424. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73425. * @returns the list of emit rate gradients
  73426. */
  73427. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73428. /**
  73429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73430. * @param gradient defines the gradient to use (between 0 and 1)
  73431. * @param factor defines the start size to affect to the specified gradient
  73432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73433. * @returns the current particle system
  73434. */
  73435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73436. /**
  73437. * Remove a specific start size gradient
  73438. * @param gradient defines the gradient to remove
  73439. * @returns the current particle system
  73440. */
  73441. removeStartSizeGradient(gradient: number): IParticleSystem;
  73442. /**
  73443. * Gets the current list of start size gradients.
  73444. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73445. * @returns the list of start size gradients
  73446. */
  73447. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73448. /**
  73449. * Adds a new life time gradient
  73450. * @param gradient defines the gradient to use (between 0 and 1)
  73451. * @param factor defines the life time factor to affect to the specified gradient
  73452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73453. * @returns the current particle system
  73454. */
  73455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73456. /**
  73457. * Remove a specific life time gradient
  73458. * @param gradient defines the gradient to remove
  73459. * @returns the current particle system
  73460. */
  73461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73462. /**
  73463. * Gets the current list of life time gradients.
  73464. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73465. * @returns the list of life time gradients
  73466. */
  73467. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73468. /**
  73469. * Gets the current list of color gradients.
  73470. * You must use addColorGradient and removeColorGradient to udpate this list
  73471. * @returns the list of color gradients
  73472. */
  73473. getColorGradients(): Nullable<Array<ColorGradient>>;
  73474. /**
  73475. * Adds a new ramp gradient used to remap particle colors
  73476. * @param gradient defines the gradient to use (between 0 and 1)
  73477. * @param color defines the color to affect to the specified gradient
  73478. * @returns the current particle system
  73479. */
  73480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73481. /**
  73482. * Gets the current list of ramp gradients.
  73483. * You must use addRampGradient and removeRampGradient to udpate this list
  73484. * @returns the list of ramp gradients
  73485. */
  73486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73487. /** Gets or sets a boolean indicating that ramp gradients must be used
  73488. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73489. */
  73490. useRampGradients: boolean;
  73491. /**
  73492. * Adds a new color remap gradient
  73493. * @param gradient defines the gradient to use (between 0 and 1)
  73494. * @param min defines the color remap minimal range
  73495. * @param max defines the color remap maximal range
  73496. * @returns the current particle system
  73497. */
  73498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73499. /**
  73500. * Gets the current list of color remap gradients.
  73501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73502. * @returns the list of color remap gradients
  73503. */
  73504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73505. /**
  73506. * Adds a new alpha remap gradient
  73507. * @param gradient defines the gradient to use (between 0 and 1)
  73508. * @param min defines the alpha remap minimal range
  73509. * @param max defines the alpha remap maximal range
  73510. * @returns the current particle system
  73511. */
  73512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73513. /**
  73514. * Gets the current list of alpha remap gradients.
  73515. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73516. * @returns the list of alpha remap gradients
  73517. */
  73518. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73519. /**
  73520. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73523. * @returns the emitter
  73524. */
  73525. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73526. /**
  73527. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73528. * @param radius The radius of the hemisphere to emit from
  73529. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73530. * @returns the emitter
  73531. */
  73532. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73533. /**
  73534. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73535. * @param radius The radius of the sphere to emit from
  73536. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73537. * @returns the emitter
  73538. */
  73539. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73540. /**
  73541. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73542. * @param radius The radius of the sphere to emit from
  73543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73545. * @returns the emitter
  73546. */
  73547. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73548. /**
  73549. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73550. * @param radius The radius of the emission cylinder
  73551. * @param height The height of the emission cylinder
  73552. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73553. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73554. * @returns the emitter
  73555. */
  73556. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73557. /**
  73558. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73559. * @param radius The radius of the cylinder to emit from
  73560. * @param height The height of the emission cylinder
  73561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73564. * @returns the emitter
  73565. */
  73566. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73567. /**
  73568. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73569. * @param radius The radius of the cone to emit from
  73570. * @param angle The base angle of the cone
  73571. * @returns the emitter
  73572. */
  73573. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73574. /**
  73575. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73578. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73579. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73580. * @returns the emitter
  73581. */
  73582. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73583. /**
  73584. * Get hosting scene
  73585. * @returns the scene
  73586. */
  73587. getScene(): Scene;
  73588. }
  73589. }
  73590. declare module BABYLON {
  73591. /**
  73592. * Creates an instance based on a source mesh.
  73593. */
  73594. export class InstancedMesh extends AbstractMesh {
  73595. private _sourceMesh;
  73596. private _currentLOD;
  73597. /** @hidden */
  73598. _indexInSourceMeshInstanceArray: number;
  73599. constructor(name: string, source: Mesh);
  73600. /**
  73601. * Returns the string "InstancedMesh".
  73602. */
  73603. getClassName(): string;
  73604. /**
  73605. * If the source mesh receives shadows
  73606. */
  73607. readonly receiveShadows: boolean;
  73608. /**
  73609. * The material of the source mesh
  73610. */
  73611. readonly material: Nullable<Material>;
  73612. /**
  73613. * Visibility of the source mesh
  73614. */
  73615. readonly visibility: number;
  73616. /**
  73617. * Skeleton of the source mesh
  73618. */
  73619. readonly skeleton: Nullable<Skeleton>;
  73620. /**
  73621. * Rendering ground id of the source mesh
  73622. */
  73623. renderingGroupId: number;
  73624. /**
  73625. * Returns the total number of vertices (integer).
  73626. */
  73627. getTotalVertices(): number;
  73628. /**
  73629. * Returns a positive integer : the total number of indices in this mesh geometry.
  73630. * @returns the numner of indices or zero if the mesh has no geometry.
  73631. */
  73632. getTotalIndices(): number;
  73633. /**
  73634. * The source mesh of the instance
  73635. */
  73636. readonly sourceMesh: Mesh;
  73637. /**
  73638. * Is this node ready to be used/rendered
  73639. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73640. * @return {boolean} is it ready
  73641. */
  73642. isReady(completeCheck?: boolean): boolean;
  73643. /**
  73644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73645. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73646. * @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.
  73647. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73648. */
  73649. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73650. /**
  73651. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73652. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73653. * The `data` are either a numeric array either a Float32Array.
  73654. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73655. * 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).
  73656. * Note that a new underlying VertexBuffer object is created each call.
  73657. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73658. *
  73659. * Possible `kind` values :
  73660. * - VertexBuffer.PositionKind
  73661. * - VertexBuffer.UVKind
  73662. * - VertexBuffer.UV2Kind
  73663. * - VertexBuffer.UV3Kind
  73664. * - VertexBuffer.UV4Kind
  73665. * - VertexBuffer.UV5Kind
  73666. * - VertexBuffer.UV6Kind
  73667. * - VertexBuffer.ColorKind
  73668. * - VertexBuffer.MatricesIndicesKind
  73669. * - VertexBuffer.MatricesIndicesExtraKind
  73670. * - VertexBuffer.MatricesWeightsKind
  73671. * - VertexBuffer.MatricesWeightsExtraKind
  73672. *
  73673. * Returns the Mesh.
  73674. */
  73675. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73676. /**
  73677. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73678. * If the mesh has no geometry, it is simply returned as it is.
  73679. * The `data` are either a numeric array either a Float32Array.
  73680. * No new underlying VertexBuffer object is created.
  73681. * 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.
  73682. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73683. *
  73684. * Possible `kind` values :
  73685. * - VertexBuffer.PositionKind
  73686. * - VertexBuffer.UVKind
  73687. * - VertexBuffer.UV2Kind
  73688. * - VertexBuffer.UV3Kind
  73689. * - VertexBuffer.UV4Kind
  73690. * - VertexBuffer.UV5Kind
  73691. * - VertexBuffer.UV6Kind
  73692. * - VertexBuffer.ColorKind
  73693. * - VertexBuffer.MatricesIndicesKind
  73694. * - VertexBuffer.MatricesIndicesExtraKind
  73695. * - VertexBuffer.MatricesWeightsKind
  73696. * - VertexBuffer.MatricesWeightsExtraKind
  73697. *
  73698. * Returns the Mesh.
  73699. */
  73700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73701. /**
  73702. * Sets the mesh indices.
  73703. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73704. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73705. * This method creates a new index buffer each call.
  73706. * Returns the Mesh.
  73707. */
  73708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73709. /**
  73710. * Boolean : True if the mesh owns the requested kind of data.
  73711. */
  73712. isVerticesDataPresent(kind: string): boolean;
  73713. /**
  73714. * Returns an array of indices (IndicesArray).
  73715. */
  73716. getIndices(): Nullable<IndicesArray>;
  73717. readonly _positions: Nullable<Vector3[]>;
  73718. /**
  73719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73720. * This means the mesh underlying bounding box and sphere are recomputed.
  73721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73722. * @returns the current mesh
  73723. */
  73724. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73725. /** @hidden */
  73726. _preActivate(): InstancedMesh;
  73727. /** @hidden */
  73728. _activate(renderId: number): InstancedMesh;
  73729. /**
  73730. * Returns the current associated LOD AbstractMesh.
  73731. */
  73732. getLOD(camera: Camera): AbstractMesh;
  73733. /** @hidden */
  73734. _syncSubMeshes(): InstancedMesh;
  73735. /** @hidden */
  73736. _generatePointsArray(): boolean;
  73737. /**
  73738. * Creates a new InstancedMesh from the current mesh.
  73739. * - name (string) : the cloned mesh name
  73740. * - newParent (optional Node) : the optional Node to parent the clone to.
  73741. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73742. *
  73743. * Returns the clone.
  73744. */
  73745. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73746. /**
  73747. * Disposes the InstancedMesh.
  73748. * Returns nothing.
  73749. */
  73750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73751. }
  73752. }
  73753. declare module BABYLON {
  73754. /**
  73755. * Defines the options associated with the creation of a shader material.
  73756. */
  73757. export interface IShaderMaterialOptions {
  73758. /**
  73759. * Does the material work in alpha blend mode
  73760. */
  73761. needAlphaBlending: boolean;
  73762. /**
  73763. * Does the material work in alpha test mode
  73764. */
  73765. needAlphaTesting: boolean;
  73766. /**
  73767. * The list of attribute names used in the shader
  73768. */
  73769. attributes: string[];
  73770. /**
  73771. * The list of unifrom names used in the shader
  73772. */
  73773. uniforms: string[];
  73774. /**
  73775. * The list of UBO names used in the shader
  73776. */
  73777. uniformBuffers: string[];
  73778. /**
  73779. * The list of sampler names used in the shader
  73780. */
  73781. samplers: string[];
  73782. /**
  73783. * The list of defines used in the shader
  73784. */
  73785. defines: string[];
  73786. }
  73787. /**
  73788. * 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.
  73789. *
  73790. * This returned material effects how the mesh will look based on the code in the shaders.
  73791. *
  73792. * @see http://doc.babylonjs.com/how_to/shader_material
  73793. */
  73794. export class ShaderMaterial extends Material {
  73795. private _shaderPath;
  73796. private _options;
  73797. private _textures;
  73798. private _textureArrays;
  73799. private _floats;
  73800. private _ints;
  73801. private _floatsArrays;
  73802. private _colors3;
  73803. private _colors3Arrays;
  73804. private _colors4;
  73805. private _vectors2;
  73806. private _vectors3;
  73807. private _vectors4;
  73808. private _matrices;
  73809. private _matrices3x3;
  73810. private _matrices2x2;
  73811. private _vectors2Arrays;
  73812. private _vectors3Arrays;
  73813. private _cachedWorldViewMatrix;
  73814. private _renderId;
  73815. /**
  73816. * Instantiate a new shader material.
  73817. * 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.
  73818. * This returned material effects how the mesh will look based on the code in the shaders.
  73819. * @see http://doc.babylonjs.com/how_to/shader_material
  73820. * @param name Define the name of the material in the scene
  73821. * @param scene Define the scene the material belongs to
  73822. * @param shaderPath Defines the route to the shader code in one of three ways:
  73823. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73824. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73825. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73826. * @param options Define the options used to create the shader
  73827. */
  73828. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73829. /**
  73830. * Gets the current class name of the material e.g. "ShaderMaterial"
  73831. * Mainly use in serialization.
  73832. * @returns the class name
  73833. */
  73834. getClassName(): string;
  73835. /**
  73836. * Specifies if the material will require alpha blending
  73837. * @returns a boolean specifying if alpha blending is needed
  73838. */
  73839. needAlphaBlending(): boolean;
  73840. /**
  73841. * Specifies if this material should be rendered in alpha test mode
  73842. * @returns a boolean specifying if an alpha test is needed.
  73843. */
  73844. needAlphaTesting(): boolean;
  73845. private _checkUniform;
  73846. /**
  73847. * Set a texture in the shader.
  73848. * @param name Define the name of the uniform samplers as defined in the shader
  73849. * @param texture Define the texture to bind to this sampler
  73850. * @return the material itself allowing "fluent" like uniform updates
  73851. */
  73852. setTexture(name: string, texture: Texture): ShaderMaterial;
  73853. /**
  73854. * Set a texture array in the shader.
  73855. * @param name Define the name of the uniform sampler array as defined in the shader
  73856. * @param textures Define the list of textures to bind to this sampler
  73857. * @return the material itself allowing "fluent" like uniform updates
  73858. */
  73859. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73860. /**
  73861. * Set a float in the shader.
  73862. * @param name Define the name of the uniform as defined in the shader
  73863. * @param value Define the value to give to the uniform
  73864. * @return the material itself allowing "fluent" like uniform updates
  73865. */
  73866. setFloat(name: string, value: number): ShaderMaterial;
  73867. /**
  73868. * Set a int in the shader.
  73869. * @param name Define the name of the uniform as defined in the shader
  73870. * @param value Define the value to give to the uniform
  73871. * @return the material itself allowing "fluent" like uniform updates
  73872. */
  73873. setInt(name: string, value: number): ShaderMaterial;
  73874. /**
  73875. * Set an array of floats in the shader.
  73876. * @param name Define the name of the uniform as defined in the shader
  73877. * @param value Define the value to give to the uniform
  73878. * @return the material itself allowing "fluent" like uniform updates
  73879. */
  73880. setFloats(name: string, value: number[]): ShaderMaterial;
  73881. /**
  73882. * Set a vec3 in the shader from a Color3.
  73883. * @param name Define the name of the uniform as defined in the shader
  73884. * @param value Define the value to give to the uniform
  73885. * @return the material itself allowing "fluent" like uniform updates
  73886. */
  73887. setColor3(name: string, value: Color3): ShaderMaterial;
  73888. /**
  73889. * Set a vec3 array in the shader from a Color3 array.
  73890. * @param name Define the name of the uniform as defined in the shader
  73891. * @param value Define the value to give to the uniform
  73892. * @return the material itself allowing "fluent" like uniform updates
  73893. */
  73894. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73895. /**
  73896. * Set a vec4 in the shader from a Color4.
  73897. * @param name Define the name of the uniform as defined in the shader
  73898. * @param value Define the value to give to the uniform
  73899. * @return the material itself allowing "fluent" like uniform updates
  73900. */
  73901. setColor4(name: string, value: Color4): ShaderMaterial;
  73902. /**
  73903. * Set a vec2 in the shader from a Vector2.
  73904. * @param name Define the name of the uniform as defined in the shader
  73905. * @param value Define the value to give to the uniform
  73906. * @return the material itself allowing "fluent" like uniform updates
  73907. */
  73908. setVector2(name: string, value: Vector2): ShaderMaterial;
  73909. /**
  73910. * Set a vec3 in the shader from a Vector3.
  73911. * @param name Define the name of the uniform as defined in the shader
  73912. * @param value Define the value to give to the uniform
  73913. * @return the material itself allowing "fluent" like uniform updates
  73914. */
  73915. setVector3(name: string, value: Vector3): ShaderMaterial;
  73916. /**
  73917. * Set a vec4 in the shader from a Vector4.
  73918. * @param name Define the name of the uniform as defined in the shader
  73919. * @param value Define the value to give to the uniform
  73920. * @return the material itself allowing "fluent" like uniform updates
  73921. */
  73922. setVector4(name: string, value: Vector4): ShaderMaterial;
  73923. /**
  73924. * Set a mat4 in the shader from a Matrix.
  73925. * @param name Define the name of the uniform as defined in the shader
  73926. * @param value Define the value to give to the uniform
  73927. * @return the material itself allowing "fluent" like uniform updates
  73928. */
  73929. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73930. /**
  73931. * Set a mat3 in the shader from a Float32Array.
  73932. * @param name Define the name of the uniform as defined in the shader
  73933. * @param value Define the value to give to the uniform
  73934. * @return the material itself allowing "fluent" like uniform updates
  73935. */
  73936. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73937. /**
  73938. * Set a mat2 in the shader from a Float32Array.
  73939. * @param name Define the name of the uniform as defined in the shader
  73940. * @param value Define the value to give to the uniform
  73941. * @return the material itself allowing "fluent" like uniform updates
  73942. */
  73943. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73944. /**
  73945. * Set a vec2 array in the shader from a number array.
  73946. * @param name Define the name of the uniform as defined in the shader
  73947. * @param value Define the value to give to the uniform
  73948. * @return the material itself allowing "fluent" like uniform updates
  73949. */
  73950. setArray2(name: string, value: number[]): ShaderMaterial;
  73951. /**
  73952. * Set a vec3 array in the shader from a number array.
  73953. * @param name Define the name of the uniform as defined in the shader
  73954. * @param value Define the value to give to the uniform
  73955. * @return the material itself allowing "fluent" like uniform updates
  73956. */
  73957. setArray3(name: string, value: number[]): ShaderMaterial;
  73958. private _checkCache;
  73959. /**
  73960. * Checks if the material is ready to render the requested mesh
  73961. * @param mesh Define the mesh to render
  73962. * @param useInstances Define whether or not the material is used with instances
  73963. * @returns true if ready, otherwise false
  73964. */
  73965. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73966. /**
  73967. * Binds the world matrix to the material
  73968. * @param world defines the world transformation matrix
  73969. */
  73970. bindOnlyWorldMatrix(world: Matrix): void;
  73971. /**
  73972. * Binds the material to the mesh
  73973. * @param world defines the world transformation matrix
  73974. * @param mesh defines the mesh to bind the material to
  73975. */
  73976. bind(world: Matrix, mesh?: Mesh): void;
  73977. /**
  73978. * Gets the active textures from the material
  73979. * @returns an array of textures
  73980. */
  73981. getActiveTextures(): BaseTexture[];
  73982. /**
  73983. * Specifies if the material uses a texture
  73984. * @param texture defines the texture to check against the material
  73985. * @returns a boolean specifying if the material uses the texture
  73986. */
  73987. hasTexture(texture: BaseTexture): boolean;
  73988. /**
  73989. * Makes a duplicate of the material, and gives it a new name
  73990. * @param name defines the new name for the duplicated material
  73991. * @returns the cloned material
  73992. */
  73993. clone(name: string): ShaderMaterial;
  73994. /**
  73995. * Disposes the material
  73996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73999. */
  74000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74001. /**
  74002. * Serializes this material in a JSON representation
  74003. * @returns the serialized material object
  74004. */
  74005. serialize(): any;
  74006. /**
  74007. * Creates a shader material from parsed shader material data
  74008. * @param source defines the JSON represnetation of the material
  74009. * @param scene defines the hosting scene
  74010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74011. * @returns a new material
  74012. */
  74013. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74014. }
  74015. }
  74016. declare module BABYLON {
  74017. /** @hidden */
  74018. export var colorPixelShader: {
  74019. name: string;
  74020. shader: string;
  74021. };
  74022. }
  74023. declare module BABYLON {
  74024. /** @hidden */
  74025. export var colorVertexShader: {
  74026. name: string;
  74027. shader: string;
  74028. };
  74029. }
  74030. declare module BABYLON {
  74031. /**
  74032. * Line mesh
  74033. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74034. */
  74035. export class LinesMesh extends Mesh {
  74036. /**
  74037. * If vertex color should be applied to the mesh
  74038. */
  74039. useVertexColor?: boolean | undefined;
  74040. /**
  74041. * If vertex alpha should be applied to the mesh
  74042. */
  74043. useVertexAlpha?: boolean | undefined;
  74044. /**
  74045. * Color of the line (Default: White)
  74046. */
  74047. color: Color3;
  74048. /**
  74049. * Alpha of the line (Default: 1)
  74050. */
  74051. alpha: number;
  74052. /**
  74053. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74054. * This margin is expressed in world space coordinates, so its value may vary.
  74055. * Default value is 0.1
  74056. */
  74057. intersectionThreshold: number;
  74058. private _colorShader;
  74059. /**
  74060. * Creates a new LinesMesh
  74061. * @param name defines the name
  74062. * @param scene defines the hosting scene
  74063. * @param parent defines the parent mesh if any
  74064. * @param source defines the optional source LinesMesh used to clone data from
  74065. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74066. * When false, achieved by calling a clone(), also passing False.
  74067. * This will make creation of children, recursive.
  74068. * @param useVertexColor defines if this LinesMesh supports vertex color
  74069. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74070. */
  74071. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74072. /**
  74073. * If vertex color should be applied to the mesh
  74074. */
  74075. useVertexColor?: boolean | undefined,
  74076. /**
  74077. * If vertex alpha should be applied to the mesh
  74078. */
  74079. useVertexAlpha?: boolean | undefined);
  74080. /**
  74081. * Returns the string "LineMesh"
  74082. */
  74083. getClassName(): string;
  74084. /**
  74085. * @hidden
  74086. */
  74087. /**
  74088. * @hidden
  74089. */
  74090. material: Material;
  74091. /**
  74092. * @hidden
  74093. */
  74094. readonly checkCollisions: boolean;
  74095. /** @hidden */
  74096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74097. /** @hidden */
  74098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74099. /**
  74100. * Disposes of the line mesh
  74101. * @param doNotRecurse If children should be disposed
  74102. */
  74103. dispose(doNotRecurse?: boolean): void;
  74104. /**
  74105. * Returns a new LineMesh object cloned from the current one.
  74106. */
  74107. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74108. /**
  74109. * Creates a new InstancedLinesMesh object from the mesh model.
  74110. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74111. * @param name defines the name of the new instance
  74112. * @returns a new InstancedLinesMesh
  74113. */
  74114. createInstance(name: string): InstancedLinesMesh;
  74115. }
  74116. /**
  74117. * Creates an instance based on a source LinesMesh
  74118. */
  74119. export class InstancedLinesMesh extends InstancedMesh {
  74120. /**
  74121. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74122. * This margin is expressed in world space coordinates, so its value may vary.
  74123. * Initilized with the intersectionThreshold value of the source LinesMesh
  74124. */
  74125. intersectionThreshold: number;
  74126. constructor(name: string, source: LinesMesh);
  74127. /**
  74128. * Returns the string "InstancedLinesMesh".
  74129. */
  74130. getClassName(): string;
  74131. }
  74132. }
  74133. declare module BABYLON {
  74134. /** @hidden */
  74135. export var linePixelShader: {
  74136. name: string;
  74137. shader: string;
  74138. };
  74139. }
  74140. declare module BABYLON {
  74141. /** @hidden */
  74142. export var lineVertexShader: {
  74143. name: string;
  74144. shader: string;
  74145. };
  74146. }
  74147. declare module BABYLON {
  74148. interface AbstractMesh {
  74149. /**
  74150. * Disables the mesh edge rendering mode
  74151. * @returns the currentAbstractMesh
  74152. */
  74153. disableEdgesRendering(): AbstractMesh;
  74154. /**
  74155. * Enables the edge rendering mode on the mesh.
  74156. * This mode makes the mesh edges visible
  74157. * @param epsilon defines the maximal distance between two angles to detect a face
  74158. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74159. * @returns the currentAbstractMesh
  74160. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74161. */
  74162. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74163. /**
  74164. * Gets the edgesRenderer associated with the mesh
  74165. */
  74166. edgesRenderer: Nullable<EdgesRenderer>;
  74167. }
  74168. interface LinesMesh {
  74169. /**
  74170. * Enables the edge rendering mode on the mesh.
  74171. * This mode makes the mesh edges visible
  74172. * @param epsilon defines the maximal distance between two angles to detect a face
  74173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74174. * @returns the currentAbstractMesh
  74175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74176. */
  74177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74178. }
  74179. interface InstancedLinesMesh {
  74180. /**
  74181. * Enables the edge rendering mode on the mesh.
  74182. * This mode makes the mesh edges visible
  74183. * @param epsilon defines the maximal distance between two angles to detect a face
  74184. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74185. * @returns the current InstancedLinesMesh
  74186. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74187. */
  74188. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74189. }
  74190. /**
  74191. * Defines the minimum contract an Edges renderer should follow.
  74192. */
  74193. export interface IEdgesRenderer extends IDisposable {
  74194. /**
  74195. * Gets or sets a boolean indicating if the edgesRenderer is active
  74196. */
  74197. isEnabled: boolean;
  74198. /**
  74199. * Renders the edges of the attached mesh,
  74200. */
  74201. render(): void;
  74202. /**
  74203. * Checks wether or not the edges renderer is ready to render.
  74204. * @return true if ready, otherwise false.
  74205. */
  74206. isReady(): boolean;
  74207. }
  74208. /**
  74209. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74210. */
  74211. export class EdgesRenderer implements IEdgesRenderer {
  74212. /**
  74213. * Define the size of the edges with an orthographic camera
  74214. */
  74215. edgesWidthScalerForOrthographic: number;
  74216. /**
  74217. * Define the size of the edges with a perspective camera
  74218. */
  74219. edgesWidthScalerForPerspective: number;
  74220. protected _source: AbstractMesh;
  74221. protected _linesPositions: number[];
  74222. protected _linesNormals: number[];
  74223. protected _linesIndices: number[];
  74224. protected _epsilon: number;
  74225. protected _indicesCount: number;
  74226. protected _lineShader: ShaderMaterial;
  74227. protected _ib: WebGLBuffer;
  74228. protected _buffers: {
  74229. [key: string]: Nullable<VertexBuffer>;
  74230. };
  74231. protected _checkVerticesInsteadOfIndices: boolean;
  74232. private _meshRebuildObserver;
  74233. private _meshDisposeObserver;
  74234. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74235. isEnabled: boolean;
  74236. /**
  74237. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74238. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74239. * @param source Mesh used to create edges
  74240. * @param epsilon sum of angles in adjacency to check for edge
  74241. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74242. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74243. */
  74244. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74245. protected _prepareRessources(): void;
  74246. /** @hidden */
  74247. _rebuild(): void;
  74248. /**
  74249. * Releases the required resources for the edges renderer
  74250. */
  74251. dispose(): void;
  74252. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74253. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74254. /**
  74255. * Checks if the pair of p0 and p1 is en edge
  74256. * @param faceIndex
  74257. * @param edge
  74258. * @param faceNormals
  74259. * @param p0
  74260. * @param p1
  74261. * @private
  74262. */
  74263. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74264. /**
  74265. * push line into the position, normal and index buffer
  74266. * @protected
  74267. */
  74268. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74269. /**
  74270. * Generates lines edges from adjacencjes
  74271. * @private
  74272. */
  74273. _generateEdgesLines(): void;
  74274. /**
  74275. * Checks wether or not the edges renderer is ready to render.
  74276. * @return true if ready, otherwise false.
  74277. */
  74278. isReady(): boolean;
  74279. /**
  74280. * Renders the edges of the attached mesh,
  74281. */
  74282. render(): void;
  74283. }
  74284. /**
  74285. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74286. */
  74287. export class LineEdgesRenderer extends EdgesRenderer {
  74288. /**
  74289. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74290. * @param source LineMesh used to generate edges
  74291. * @param epsilon not important (specified angle for edge detection)
  74292. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74293. */
  74294. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74295. /**
  74296. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74297. */
  74298. _generateEdgesLines(): void;
  74299. }
  74300. }
  74301. declare module BABYLON {
  74302. /**
  74303. * This represents the object necessary to create a rendering group.
  74304. * This is exclusively used and created by the rendering manager.
  74305. * To modify the behavior, you use the available helpers in your scene or meshes.
  74306. * @hidden
  74307. */
  74308. export class RenderingGroup {
  74309. index: number;
  74310. private _scene;
  74311. private _opaqueSubMeshes;
  74312. private _transparentSubMeshes;
  74313. private _alphaTestSubMeshes;
  74314. private _depthOnlySubMeshes;
  74315. private _particleSystems;
  74316. private _spriteManagers;
  74317. private _opaqueSortCompareFn;
  74318. private _alphaTestSortCompareFn;
  74319. private _transparentSortCompareFn;
  74320. private _renderOpaque;
  74321. private _renderAlphaTest;
  74322. private _renderTransparent;
  74323. private _edgesRenderers;
  74324. onBeforeTransparentRendering: () => void;
  74325. /**
  74326. * Set the opaque sort comparison function.
  74327. * If null the sub meshes will be render in the order they were created
  74328. */
  74329. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74330. /**
  74331. * Set the alpha test sort comparison function.
  74332. * If null the sub meshes will be render in the order they were created
  74333. */
  74334. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74335. /**
  74336. * Set the transparent sort comparison function.
  74337. * If null the sub meshes will be render in the order they were created
  74338. */
  74339. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74340. /**
  74341. * Creates a new rendering group.
  74342. * @param index The rendering group index
  74343. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74344. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74345. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74346. */
  74347. 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>);
  74348. /**
  74349. * Render all the sub meshes contained in the group.
  74350. * @param customRenderFunction Used to override the default render behaviour of the group.
  74351. * @returns true if rendered some submeshes.
  74352. */
  74353. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74354. /**
  74355. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74356. * @param subMeshes The submeshes to render
  74357. */
  74358. private renderOpaqueSorted;
  74359. /**
  74360. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74361. * @param subMeshes The submeshes to render
  74362. */
  74363. private renderAlphaTestSorted;
  74364. /**
  74365. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74366. * @param subMeshes The submeshes to render
  74367. */
  74368. private renderTransparentSorted;
  74369. /**
  74370. * Renders the submeshes in a specified order.
  74371. * @param subMeshes The submeshes to sort before render
  74372. * @param sortCompareFn The comparison function use to sort
  74373. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74374. * @param transparent Specifies to activate blending if true
  74375. */
  74376. private static renderSorted;
  74377. /**
  74378. * Renders the submeshes in the order they were dispatched (no sort applied).
  74379. * @param subMeshes The submeshes to render
  74380. */
  74381. private static renderUnsorted;
  74382. /**
  74383. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74384. * are rendered back to front if in the same alpha index.
  74385. *
  74386. * @param a The first submesh
  74387. * @param b The second submesh
  74388. * @returns The result of the comparison
  74389. */
  74390. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74391. /**
  74392. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74393. * are rendered back to front.
  74394. *
  74395. * @param a The first submesh
  74396. * @param b The second submesh
  74397. * @returns The result of the comparison
  74398. */
  74399. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74400. /**
  74401. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74402. * are rendered front to back (prevent overdraw).
  74403. *
  74404. * @param a The first submesh
  74405. * @param b The second submesh
  74406. * @returns The result of the comparison
  74407. */
  74408. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74409. /**
  74410. * Resets the different lists of submeshes to prepare a new frame.
  74411. */
  74412. prepare(): void;
  74413. dispose(): void;
  74414. /**
  74415. * Inserts the submesh in its correct queue depending on its material.
  74416. * @param subMesh The submesh to dispatch
  74417. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74418. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74419. */
  74420. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74421. dispatchSprites(spriteManager: ISpriteManager): void;
  74422. dispatchParticles(particleSystem: IParticleSystem): void;
  74423. private _renderParticles;
  74424. private _renderSprites;
  74425. }
  74426. }
  74427. declare module BABYLON {
  74428. /**
  74429. * Interface describing the different options available in the rendering manager
  74430. * regarding Auto Clear between groups.
  74431. */
  74432. export interface IRenderingManagerAutoClearSetup {
  74433. /**
  74434. * Defines whether or not autoclear is enable.
  74435. */
  74436. autoClear: boolean;
  74437. /**
  74438. * Defines whether or not to autoclear the depth buffer.
  74439. */
  74440. depth: boolean;
  74441. /**
  74442. * Defines whether or not to autoclear the stencil buffer.
  74443. */
  74444. stencil: boolean;
  74445. }
  74446. /**
  74447. * This class is used by the onRenderingGroupObservable
  74448. */
  74449. export class RenderingGroupInfo {
  74450. /**
  74451. * The Scene that being rendered
  74452. */
  74453. scene: Scene;
  74454. /**
  74455. * The camera currently used for the rendering pass
  74456. */
  74457. camera: Nullable<Camera>;
  74458. /**
  74459. * The ID of the renderingGroup being processed
  74460. */
  74461. renderingGroupId: number;
  74462. }
  74463. /**
  74464. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74465. * It is enable to manage the different groups as well as the different necessary sort functions.
  74466. * This should not be used directly aside of the few static configurations
  74467. */
  74468. export class RenderingManager {
  74469. /**
  74470. * The max id used for rendering groups (not included)
  74471. */
  74472. static MAX_RENDERINGGROUPS: number;
  74473. /**
  74474. * The min id used for rendering groups (included)
  74475. */
  74476. static MIN_RENDERINGGROUPS: number;
  74477. /**
  74478. * Used to globally prevent autoclearing scenes.
  74479. */
  74480. static AUTOCLEAR: boolean;
  74481. /**
  74482. * @hidden
  74483. */
  74484. _useSceneAutoClearSetup: boolean;
  74485. private _scene;
  74486. private _renderingGroups;
  74487. private _depthStencilBufferAlreadyCleaned;
  74488. private _autoClearDepthStencil;
  74489. private _customOpaqueSortCompareFn;
  74490. private _customAlphaTestSortCompareFn;
  74491. private _customTransparentSortCompareFn;
  74492. private _renderingGroupInfo;
  74493. /**
  74494. * Instantiates a new rendering group for a particular scene
  74495. * @param scene Defines the scene the groups belongs to
  74496. */
  74497. constructor(scene: Scene);
  74498. private _clearDepthStencilBuffer;
  74499. /**
  74500. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74501. * @hidden
  74502. */
  74503. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74504. /**
  74505. * Resets the different information of the group to prepare a new frame
  74506. * @hidden
  74507. */
  74508. reset(): void;
  74509. /**
  74510. * Dispose and release the group and its associated resources.
  74511. * @hidden
  74512. */
  74513. dispose(): void;
  74514. /**
  74515. * Clear the info related to rendering groups preventing retention points during dispose.
  74516. */
  74517. freeRenderingGroups(): void;
  74518. private _prepareRenderingGroup;
  74519. /**
  74520. * Add a sprite manager to the rendering manager in order to render it this frame.
  74521. * @param spriteManager Define the sprite manager to render
  74522. */
  74523. dispatchSprites(spriteManager: ISpriteManager): void;
  74524. /**
  74525. * Add a particle system to the rendering manager in order to render it this frame.
  74526. * @param particleSystem Define the particle system to render
  74527. */
  74528. dispatchParticles(particleSystem: IParticleSystem): void;
  74529. /**
  74530. * Add a submesh to the manager in order to render it this frame
  74531. * @param subMesh The submesh to dispatch
  74532. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74533. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74534. */
  74535. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74536. /**
  74537. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74538. * This allowed control for front to back rendering or reversly depending of the special needs.
  74539. *
  74540. * @param renderingGroupId The rendering group id corresponding to its index
  74541. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74542. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74543. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74544. */
  74545. 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;
  74546. /**
  74547. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74548. *
  74549. * @param renderingGroupId The rendering group id corresponding to its index
  74550. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74551. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74552. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74553. */
  74554. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74555. /**
  74556. * Gets the current auto clear configuration for one rendering group of the rendering
  74557. * manager.
  74558. * @param index the rendering group index to get the information for
  74559. * @returns The auto clear setup for the requested rendering group
  74560. */
  74561. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74562. }
  74563. }
  74564. declare module BABYLON {
  74565. /**
  74566. * This Helps creating a texture that will be created from a camera in your scene.
  74567. * It is basically a dynamic texture that could be used to create special effects for instance.
  74568. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74569. */
  74570. export class RenderTargetTexture extends Texture {
  74571. isCube: boolean;
  74572. /**
  74573. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74574. */
  74575. static readonly REFRESHRATE_RENDER_ONCE: number;
  74576. /**
  74577. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74578. */
  74579. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74580. /**
  74581. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74582. * the central point of your effect and can save a lot of performances.
  74583. */
  74584. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74585. /**
  74586. * Use this predicate to dynamically define the list of mesh you want to render.
  74587. * If set, the renderList property will be overwritten.
  74588. */
  74589. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74590. private _renderList;
  74591. /**
  74592. * Use this list to define the list of mesh you want to render.
  74593. */
  74594. renderList: Nullable<Array<AbstractMesh>>;
  74595. private _hookArray;
  74596. /**
  74597. * Define if particles should be rendered in your texture.
  74598. */
  74599. renderParticles: boolean;
  74600. /**
  74601. * Define if sprites should be rendered in your texture.
  74602. */
  74603. renderSprites: boolean;
  74604. /**
  74605. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74606. */
  74607. coordinatesMode: number;
  74608. /**
  74609. * Define the camera used to render the texture.
  74610. */
  74611. activeCamera: Nullable<Camera>;
  74612. /**
  74613. * Override the render function of the texture with your own one.
  74614. */
  74615. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74616. /**
  74617. * Define if camera post processes should be use while rendering the texture.
  74618. */
  74619. useCameraPostProcesses: boolean;
  74620. /**
  74621. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74622. */
  74623. ignoreCameraViewport: boolean;
  74624. private _postProcessManager;
  74625. private _postProcesses;
  74626. private _resizeObserver;
  74627. /**
  74628. * An event triggered when the texture is unbind.
  74629. */
  74630. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74631. /**
  74632. * An event triggered when the texture is unbind.
  74633. */
  74634. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74635. private _onAfterUnbindObserver;
  74636. /**
  74637. * Set a after unbind callback in the texture.
  74638. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74639. */
  74640. onAfterUnbind: () => void;
  74641. /**
  74642. * An event triggered before rendering the texture
  74643. */
  74644. onBeforeRenderObservable: Observable<number>;
  74645. private _onBeforeRenderObserver;
  74646. /**
  74647. * Set a before render callback in the texture.
  74648. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74649. */
  74650. onBeforeRender: (faceIndex: number) => void;
  74651. /**
  74652. * An event triggered after rendering the texture
  74653. */
  74654. onAfterRenderObservable: Observable<number>;
  74655. private _onAfterRenderObserver;
  74656. /**
  74657. * Set a after render callback in the texture.
  74658. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74659. */
  74660. onAfterRender: (faceIndex: number) => void;
  74661. /**
  74662. * An event triggered after the texture clear
  74663. */
  74664. onClearObservable: Observable<Engine>;
  74665. private _onClearObserver;
  74666. /**
  74667. * Set a clear callback in the texture.
  74668. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74669. */
  74670. onClear: (Engine: Engine) => void;
  74671. /**
  74672. * Define the clear color of the Render Target if it should be different from the scene.
  74673. */
  74674. clearColor: Color4;
  74675. protected _size: number | {
  74676. width: number;
  74677. height: number;
  74678. };
  74679. protected _initialSizeParameter: number | {
  74680. width: number;
  74681. height: number;
  74682. } | {
  74683. ratio: number;
  74684. };
  74685. protected _sizeRatio: Nullable<number>;
  74686. /** @hidden */
  74687. _generateMipMaps: boolean;
  74688. protected _renderingManager: RenderingManager;
  74689. /** @hidden */
  74690. _waitingRenderList: string[];
  74691. protected _doNotChangeAspectRatio: boolean;
  74692. protected _currentRefreshId: number;
  74693. protected _refreshRate: number;
  74694. protected _textureMatrix: Matrix;
  74695. protected _samples: number;
  74696. protected _renderTargetOptions: RenderTargetCreationOptions;
  74697. /**
  74698. * Gets render target creation options that were used.
  74699. */
  74700. readonly renderTargetOptions: RenderTargetCreationOptions;
  74701. protected _engine: Engine;
  74702. protected _onRatioRescale(): void;
  74703. /**
  74704. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74705. * It must define where the camera used to render the texture is set
  74706. */
  74707. boundingBoxPosition: Vector3;
  74708. private _boundingBoxSize;
  74709. /**
  74710. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74711. * When defined, the cubemap will switch to local mode
  74712. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74713. * @example https://www.babylonjs-playground.com/#RNASML
  74714. */
  74715. boundingBoxSize: Vector3;
  74716. /**
  74717. * In case the RTT has been created with a depth texture, get the associated
  74718. * depth texture.
  74719. * Otherwise, return null.
  74720. */
  74721. depthStencilTexture: Nullable<InternalTexture>;
  74722. /**
  74723. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74724. * or used a shadow, depth texture...
  74725. * @param name The friendly name of the texture
  74726. * @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)
  74727. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74728. * @param generateMipMaps True if mip maps need to be generated after render.
  74729. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74730. * @param type The type of the buffer in the RTT (int, half float, float...)
  74731. * @param isCube True if a cube texture needs to be created
  74732. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74733. * @param generateDepthBuffer True to generate a depth buffer
  74734. * @param generateStencilBuffer True to generate a stencil buffer
  74735. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74736. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74737. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74738. */
  74739. constructor(name: string, size: number | {
  74740. width: number;
  74741. height: number;
  74742. } | {
  74743. ratio: number;
  74744. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74745. /**
  74746. * Creates a depth stencil texture.
  74747. * This is only available in WebGL 2 or with the depth texture extension available.
  74748. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74749. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74750. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74751. */
  74752. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74753. private _processSizeParameter;
  74754. /**
  74755. * Define the number of samples to use in case of MSAA.
  74756. * It defaults to one meaning no MSAA has been enabled.
  74757. */
  74758. samples: number;
  74759. /**
  74760. * Resets the refresh counter of the texture and start bak from scratch.
  74761. * Could be useful to regenerate the texture if it is setup to render only once.
  74762. */
  74763. resetRefreshCounter(): void;
  74764. /**
  74765. * Define the refresh rate of the texture or the rendering frequency.
  74766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74767. */
  74768. refreshRate: number;
  74769. /**
  74770. * Adds a post process to the render target rendering passes.
  74771. * @param postProcess define the post process to add
  74772. */
  74773. addPostProcess(postProcess: PostProcess): void;
  74774. /**
  74775. * Clear all the post processes attached to the render target
  74776. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74777. */
  74778. clearPostProcesses(dispose?: boolean): void;
  74779. /**
  74780. * Remove one of the post process from the list of attached post processes to the texture
  74781. * @param postProcess define the post process to remove from the list
  74782. */
  74783. removePostProcess(postProcess: PostProcess): void;
  74784. /** @hidden */
  74785. _shouldRender(): boolean;
  74786. /**
  74787. * Gets the actual render size of the texture.
  74788. * @returns the width of the render size
  74789. */
  74790. getRenderSize(): number;
  74791. /**
  74792. * Gets the actual render width of the texture.
  74793. * @returns the width of the render size
  74794. */
  74795. getRenderWidth(): number;
  74796. /**
  74797. * Gets the actual render height of the texture.
  74798. * @returns the height of the render size
  74799. */
  74800. getRenderHeight(): number;
  74801. /**
  74802. * Get if the texture can be rescaled or not.
  74803. */
  74804. readonly canRescale: boolean;
  74805. /**
  74806. * Resize the texture using a ratio.
  74807. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74808. */
  74809. scale(ratio: number): void;
  74810. /**
  74811. * Get the texture reflection matrix used to rotate/transform the reflection.
  74812. * @returns the reflection matrix
  74813. */
  74814. getReflectionTextureMatrix(): Matrix;
  74815. /**
  74816. * Resize the texture to a new desired size.
  74817. * Be carrefull as it will recreate all the data in the new texture.
  74818. * @param size Define the new size. It can be:
  74819. * - a number for squared texture,
  74820. * - an object containing { width: number, height: number }
  74821. * - or an object containing a ratio { ratio: number }
  74822. */
  74823. resize(size: number | {
  74824. width: number;
  74825. height: number;
  74826. } | {
  74827. ratio: number;
  74828. }): void;
  74829. /**
  74830. * Renders all the objects from the render list into the texture.
  74831. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74832. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74833. */
  74834. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74835. private _bestReflectionRenderTargetDimension;
  74836. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74837. private renderToTarget;
  74838. /**
  74839. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74840. * This allowed control for front to back rendering or reversly depending of the special needs.
  74841. *
  74842. * @param renderingGroupId The rendering group id corresponding to its index
  74843. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74844. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74845. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74846. */
  74847. 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;
  74848. /**
  74849. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74850. *
  74851. * @param renderingGroupId The rendering group id corresponding to its index
  74852. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74853. */
  74854. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74855. /**
  74856. * Clones the texture.
  74857. * @returns the cloned texture
  74858. */
  74859. clone(): RenderTargetTexture;
  74860. /**
  74861. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74862. * @returns The JSON representation of the texture
  74863. */
  74864. serialize(): any;
  74865. /**
  74866. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74867. */
  74868. disposeFramebufferObjects(): void;
  74869. /**
  74870. * Dispose the texture and release its associated resources.
  74871. */
  74872. dispose(): void;
  74873. /** @hidden */
  74874. _rebuild(): void;
  74875. /**
  74876. * Clear the info related to rendering groups preventing retention point in material dispose.
  74877. */
  74878. freeRenderingGroups(): void;
  74879. }
  74880. }
  74881. declare module BABYLON {
  74882. /**
  74883. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74884. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74885. * You can then easily use it as a reflectionTexture on a flat surface.
  74886. * In case the surface is not a plane, please consider relying on reflection probes.
  74887. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74888. */
  74889. export class MirrorTexture extends RenderTargetTexture {
  74890. private scene;
  74891. /**
  74892. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74893. * 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.
  74894. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74895. */
  74896. mirrorPlane: Plane;
  74897. /**
  74898. * Define the blur ratio used to blur the reflection if needed.
  74899. */
  74900. blurRatio: number;
  74901. /**
  74902. * Define the adaptive blur kernel used to blur the reflection if needed.
  74903. * This will autocompute the closest best match for the `blurKernel`
  74904. */
  74905. adaptiveBlurKernel: number;
  74906. /**
  74907. * Define the blur kernel used to blur the reflection if needed.
  74908. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74909. */
  74910. blurKernel: number;
  74911. /**
  74912. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74913. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74914. */
  74915. blurKernelX: number;
  74916. /**
  74917. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74918. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74919. */
  74920. blurKernelY: number;
  74921. private _autoComputeBlurKernel;
  74922. protected _onRatioRescale(): void;
  74923. private _updateGammaSpace;
  74924. private _imageProcessingConfigChangeObserver;
  74925. private _transformMatrix;
  74926. private _mirrorMatrix;
  74927. private _savedViewMatrix;
  74928. private _blurX;
  74929. private _blurY;
  74930. private _adaptiveBlurKernel;
  74931. private _blurKernelX;
  74932. private _blurKernelY;
  74933. private _blurRatio;
  74934. /**
  74935. * Instantiates a Mirror Texture.
  74936. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74937. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74938. * You can then easily use it as a reflectionTexture on a flat surface.
  74939. * In case the surface is not a plane, please consider relying on reflection probes.
  74940. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74941. * @param name
  74942. * @param size
  74943. * @param scene
  74944. * @param generateMipMaps
  74945. * @param type
  74946. * @param samplingMode
  74947. * @param generateDepthBuffer
  74948. */
  74949. constructor(name: string, size: number | {
  74950. width: number;
  74951. height: number;
  74952. } | {
  74953. ratio: number;
  74954. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74955. private _preparePostProcesses;
  74956. /**
  74957. * Clone the mirror texture.
  74958. * @returns the cloned texture
  74959. */
  74960. clone(): MirrorTexture;
  74961. /**
  74962. * Serialize the texture to a JSON representation you could use in Parse later on
  74963. * @returns the serialized JSON representation
  74964. */
  74965. serialize(): any;
  74966. /**
  74967. * Dispose the texture and release its associated resources.
  74968. */
  74969. dispose(): void;
  74970. }
  74971. }
  74972. declare module BABYLON {
  74973. /**
  74974. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74975. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74976. */
  74977. export class Texture extends BaseTexture {
  74978. /** @hidden */
  74979. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74980. /** @hidden */
  74981. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74982. /** @hidden */
  74983. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74984. /** nearest is mag = nearest and min = nearest and mip = linear */
  74985. static readonly NEAREST_SAMPLINGMODE: number;
  74986. /** nearest is mag = nearest and min = nearest and mip = linear */
  74987. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74989. static readonly BILINEAR_SAMPLINGMODE: number;
  74990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74991. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74992. /** Trilinear is mag = linear and min = linear and mip = linear */
  74993. static readonly TRILINEAR_SAMPLINGMODE: number;
  74994. /** Trilinear is mag = linear and min = linear and mip = linear */
  74995. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74996. /** mag = nearest and min = nearest and mip = nearest */
  74997. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74998. /** mag = nearest and min = linear and mip = nearest */
  74999. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75000. /** mag = nearest and min = linear and mip = linear */
  75001. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75002. /** mag = nearest and min = linear and mip = none */
  75003. static readonly NEAREST_LINEAR: number;
  75004. /** mag = nearest and min = nearest and mip = none */
  75005. static readonly NEAREST_NEAREST: number;
  75006. /** mag = linear and min = nearest and mip = nearest */
  75007. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75008. /** mag = linear and min = nearest and mip = linear */
  75009. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75010. /** mag = linear and min = linear and mip = none */
  75011. static readonly LINEAR_LINEAR: number;
  75012. /** mag = linear and min = nearest and mip = none */
  75013. static readonly LINEAR_NEAREST: number;
  75014. /** Explicit coordinates mode */
  75015. static readonly EXPLICIT_MODE: number;
  75016. /** Spherical coordinates mode */
  75017. static readonly SPHERICAL_MODE: number;
  75018. /** Planar coordinates mode */
  75019. static readonly PLANAR_MODE: number;
  75020. /** Cubic coordinates mode */
  75021. static readonly CUBIC_MODE: number;
  75022. /** Projection coordinates mode */
  75023. static readonly PROJECTION_MODE: number;
  75024. /** Inverse Cubic coordinates mode */
  75025. static readonly SKYBOX_MODE: number;
  75026. /** Inverse Cubic coordinates mode */
  75027. static readonly INVCUBIC_MODE: number;
  75028. /** Equirectangular coordinates mode */
  75029. static readonly EQUIRECTANGULAR_MODE: number;
  75030. /** Equirectangular Fixed coordinates mode */
  75031. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75032. /** Equirectangular Fixed Mirrored coordinates mode */
  75033. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75034. /** Texture is not repeating outside of 0..1 UVs */
  75035. static readonly CLAMP_ADDRESSMODE: number;
  75036. /** Texture is repeating outside of 0..1 UVs */
  75037. static readonly WRAP_ADDRESSMODE: number;
  75038. /** Texture is repeating and mirrored */
  75039. static readonly MIRROR_ADDRESSMODE: number;
  75040. /**
  75041. * 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
  75042. */
  75043. static UseSerializedUrlIfAny: boolean;
  75044. /**
  75045. * Define the url of the texture.
  75046. */
  75047. url: Nullable<string>;
  75048. /**
  75049. * Define an offset on the texture to offset the u coordinates of the UVs
  75050. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75051. */
  75052. uOffset: number;
  75053. /**
  75054. * Define an offset on the texture to offset the v coordinates of the UVs
  75055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75056. */
  75057. vOffset: number;
  75058. /**
  75059. * Define an offset on the texture to scale the u coordinates of the UVs
  75060. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75061. */
  75062. uScale: number;
  75063. /**
  75064. * Define an offset on the texture to scale the v coordinates of the UVs
  75065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75066. */
  75067. vScale: number;
  75068. /**
  75069. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75070. * @see http://doc.babylonjs.com/how_to/more_materials
  75071. */
  75072. uAng: number;
  75073. /**
  75074. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75075. * @see http://doc.babylonjs.com/how_to/more_materials
  75076. */
  75077. vAng: number;
  75078. /**
  75079. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75080. * @see http://doc.babylonjs.com/how_to/more_materials
  75081. */
  75082. wAng: number;
  75083. /**
  75084. * Defines the center of rotation (U)
  75085. */
  75086. uRotationCenter: number;
  75087. /**
  75088. * Defines the center of rotation (V)
  75089. */
  75090. vRotationCenter: number;
  75091. /**
  75092. * Defines the center of rotation (W)
  75093. */
  75094. wRotationCenter: number;
  75095. /**
  75096. * Are mip maps generated for this texture or not.
  75097. */
  75098. readonly noMipmap: boolean;
  75099. private _noMipmap;
  75100. /** @hidden */
  75101. _invertY: boolean;
  75102. private _rowGenerationMatrix;
  75103. private _cachedTextureMatrix;
  75104. private _projectionModeMatrix;
  75105. private _t0;
  75106. private _t1;
  75107. private _t2;
  75108. private _cachedUOffset;
  75109. private _cachedVOffset;
  75110. private _cachedUScale;
  75111. private _cachedVScale;
  75112. private _cachedUAng;
  75113. private _cachedVAng;
  75114. private _cachedWAng;
  75115. private _cachedProjectionMatrixId;
  75116. private _cachedCoordinatesMode;
  75117. /** @hidden */
  75118. protected _initialSamplingMode: number;
  75119. /** @hidden */
  75120. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75121. private _deleteBuffer;
  75122. protected _format: Nullable<number>;
  75123. private _delayedOnLoad;
  75124. private _delayedOnError;
  75125. /**
  75126. * Observable triggered once the texture has been loaded.
  75127. */
  75128. onLoadObservable: Observable<Texture>;
  75129. protected _isBlocking: boolean;
  75130. /**
  75131. * Is the texture preventing material to render while loading.
  75132. * If false, a default texture will be used instead of the loading one during the preparation step.
  75133. */
  75134. isBlocking: boolean;
  75135. /**
  75136. * Get the current sampling mode associated with the texture.
  75137. */
  75138. readonly samplingMode: number;
  75139. /**
  75140. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75141. */
  75142. readonly invertY: boolean;
  75143. /**
  75144. * Instantiates a new texture.
  75145. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75146. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75147. * @param url define the url of the picture to load as a texture
  75148. * @param scene define the scene the texture will belong to
  75149. * @param noMipmap define if the texture will require mip maps or not
  75150. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75151. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75152. * @param onLoad define a callback triggered when the texture has been loaded
  75153. * @param onError define a callback triggered when an error occurred during the loading session
  75154. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75155. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75156. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75157. */
  75158. 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);
  75159. /**
  75160. * Update the url (and optional buffer) of this texture if url was null during construction.
  75161. * @param url the url of the texture
  75162. * @param buffer the buffer of the texture (defaults to null)
  75163. * @param onLoad callback called when the texture is loaded (defaults to null)
  75164. */
  75165. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75166. /**
  75167. * Finish the loading sequence of a texture flagged as delayed load.
  75168. * @hidden
  75169. */
  75170. delayLoad(): void;
  75171. private _prepareRowForTextureGeneration;
  75172. /**
  75173. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75174. * @returns the transform matrix of the texture.
  75175. */
  75176. getTextureMatrix(): Matrix;
  75177. /**
  75178. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75179. * @returns The reflection texture transform
  75180. */
  75181. getReflectionTextureMatrix(): Matrix;
  75182. /**
  75183. * Clones the texture.
  75184. * @returns the cloned texture
  75185. */
  75186. clone(): Texture;
  75187. /**
  75188. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75189. * @returns The JSON representation of the texture
  75190. */
  75191. serialize(): any;
  75192. /**
  75193. * Get the current class name of the texture useful for serialization or dynamic coding.
  75194. * @returns "Texture"
  75195. */
  75196. getClassName(): string;
  75197. /**
  75198. * Dispose the texture and release its associated resources.
  75199. */
  75200. dispose(): void;
  75201. /**
  75202. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75203. * @param parsedTexture Define the JSON representation of the texture
  75204. * @param scene Define the scene the parsed texture should be instantiated in
  75205. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75206. * @returns The parsed texture if successful
  75207. */
  75208. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75209. /**
  75210. * Creates a texture from its base 64 representation.
  75211. * @param data Define the base64 payload without the data: prefix
  75212. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75213. * @param scene Define the scene the texture should belong to
  75214. * @param noMipmap Forces the texture to not create mip map information if true
  75215. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75216. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75217. * @param onLoad define a callback triggered when the texture has been loaded
  75218. * @param onError define a callback triggered when an error occurred during the loading session
  75219. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75220. * @returns the created texture
  75221. */
  75222. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75223. /**
  75224. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75225. * @param data Define the base64 payload without the data: prefix
  75226. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75227. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75228. * @param scene Define the scene the texture should belong to
  75229. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75230. * @param noMipmap Forces the texture to not create mip map information if true
  75231. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75232. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75233. * @param onLoad define a callback triggered when the texture has been loaded
  75234. * @param onError define a callback triggered when an error occurred during the loading session
  75235. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75236. * @returns the created texture
  75237. */
  75238. 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;
  75239. }
  75240. }
  75241. declare module BABYLON {
  75242. /**
  75243. * Raw texture can help creating a texture directly from an array of data.
  75244. * This can be super useful if you either get the data from an uncompressed source or
  75245. * if you wish to create your texture pixel by pixel.
  75246. */
  75247. export class RawTexture extends Texture {
  75248. /**
  75249. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75250. */
  75251. format: number;
  75252. private _engine;
  75253. /**
  75254. * Instantiates a new RawTexture.
  75255. * Raw texture can help creating a texture directly from an array of data.
  75256. * This can be super useful if you either get the data from an uncompressed source or
  75257. * if you wish to create your texture pixel by pixel.
  75258. * @param data define the array of data to use to create the texture
  75259. * @param width define the width of the texture
  75260. * @param height define the height of the texture
  75261. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75262. * @param scene define the scene the texture belongs to
  75263. * @param generateMipMaps define whether mip maps should be generated or not
  75264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75266. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75267. */
  75268. constructor(data: ArrayBufferView, width: number, height: number,
  75269. /**
  75270. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75271. */
  75272. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75273. /**
  75274. * Updates the texture underlying data.
  75275. * @param data Define the new data of the texture
  75276. */
  75277. update(data: ArrayBufferView): void;
  75278. /**
  75279. * Creates a luminance texture from some data.
  75280. * @param data Define the texture data
  75281. * @param width Define the width of the texture
  75282. * @param height Define the height of the texture
  75283. * @param scene Define the scene the texture belongs to
  75284. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75285. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75286. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75287. * @returns the luminance texture
  75288. */
  75289. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75290. /**
  75291. * Creates a luminance alpha texture from some data.
  75292. * @param data Define the texture data
  75293. * @param width Define the width of the texture
  75294. * @param height Define the height of the texture
  75295. * @param scene Define the scene the texture belongs to
  75296. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75297. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75298. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75299. * @returns the luminance alpha texture
  75300. */
  75301. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75302. /**
  75303. * Creates an alpha texture from some data.
  75304. * @param data Define the texture data
  75305. * @param width Define the width of the texture
  75306. * @param height Define the height of the texture
  75307. * @param scene Define the scene the texture belongs to
  75308. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75309. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75310. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75311. * @returns the alpha texture
  75312. */
  75313. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75314. /**
  75315. * Creates a RGB texture from some data.
  75316. * @param data Define the texture data
  75317. * @param width Define the width of the texture
  75318. * @param height Define the height of the texture
  75319. * @param scene Define the scene the texture belongs to
  75320. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75321. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75322. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75323. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75324. * @returns the RGB alpha texture
  75325. */
  75326. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75327. /**
  75328. * Creates a RGBA texture from some data.
  75329. * @param data Define the texture data
  75330. * @param width Define the width of the texture
  75331. * @param height Define the height of the texture
  75332. * @param scene Define the scene the texture belongs to
  75333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75336. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75337. * @returns the RGBA texture
  75338. */
  75339. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75340. /**
  75341. * Creates a R texture from some data.
  75342. * @param data Define the texture data
  75343. * @param width Define the width of the texture
  75344. * @param height Define the height of the texture
  75345. * @param scene Define the scene the texture belongs to
  75346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75349. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75350. * @returns the R texture
  75351. */
  75352. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75353. }
  75354. }
  75355. declare module BABYLON {
  75356. /**
  75357. * Defines a runtime animation
  75358. */
  75359. export class RuntimeAnimation {
  75360. private _events;
  75361. /**
  75362. * The current frame of the runtime animation
  75363. */
  75364. private _currentFrame;
  75365. /**
  75366. * The animation used by the runtime animation
  75367. */
  75368. private _animation;
  75369. /**
  75370. * The target of the runtime animation
  75371. */
  75372. private _target;
  75373. /**
  75374. * The initiating animatable
  75375. */
  75376. private _host;
  75377. /**
  75378. * The original value of the runtime animation
  75379. */
  75380. private _originalValue;
  75381. /**
  75382. * The original blend value of the runtime animation
  75383. */
  75384. private _originalBlendValue;
  75385. /**
  75386. * The offsets cache of the runtime animation
  75387. */
  75388. private _offsetsCache;
  75389. /**
  75390. * The high limits cache of the runtime animation
  75391. */
  75392. private _highLimitsCache;
  75393. /**
  75394. * Specifies if the runtime animation has been stopped
  75395. */
  75396. private _stopped;
  75397. /**
  75398. * The blending factor of the runtime animation
  75399. */
  75400. private _blendingFactor;
  75401. /**
  75402. * The BabylonJS scene
  75403. */
  75404. private _scene;
  75405. /**
  75406. * The current value of the runtime animation
  75407. */
  75408. private _currentValue;
  75409. /** @hidden */
  75410. _workValue: any;
  75411. /**
  75412. * The active target of the runtime animation
  75413. */
  75414. private _activeTarget;
  75415. /**
  75416. * The target path of the runtime animation
  75417. */
  75418. private _targetPath;
  75419. /**
  75420. * The weight of the runtime animation
  75421. */
  75422. private _weight;
  75423. /**
  75424. * The ratio offset of the runtime animation
  75425. */
  75426. private _ratioOffset;
  75427. /**
  75428. * The previous delay of the runtime animation
  75429. */
  75430. private _previousDelay;
  75431. /**
  75432. * The previous ratio of the runtime animation
  75433. */
  75434. private _previousRatio;
  75435. /**
  75436. * Gets the current frame of the runtime animation
  75437. */
  75438. readonly currentFrame: number;
  75439. /**
  75440. * Gets the weight of the runtime animation
  75441. */
  75442. readonly weight: number;
  75443. /**
  75444. * Gets the current value of the runtime animation
  75445. */
  75446. readonly currentValue: any;
  75447. /**
  75448. * Gets the target path of the runtime animation
  75449. */
  75450. readonly targetPath: string;
  75451. /**
  75452. * Gets the actual target of the runtime animation
  75453. */
  75454. readonly target: any;
  75455. /**
  75456. * Create a new RuntimeAnimation object
  75457. * @param target defines the target of the animation
  75458. * @param animation defines the source animation object
  75459. * @param scene defines the hosting scene
  75460. * @param host defines the initiating Animatable
  75461. */
  75462. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75463. /**
  75464. * Gets the animation from the runtime animation
  75465. */
  75466. readonly animation: Animation;
  75467. /**
  75468. * Resets the runtime animation to the beginning
  75469. * @param restoreOriginal defines whether to restore the target property to the original value
  75470. */
  75471. reset(restoreOriginal?: boolean): void;
  75472. /**
  75473. * Specifies if the runtime animation is stopped
  75474. * @returns Boolean specifying if the runtime animation is stopped
  75475. */
  75476. isStopped(): boolean;
  75477. /**
  75478. * Disposes of the runtime animation
  75479. */
  75480. dispose(): void;
  75481. /**
  75482. * Interpolates the animation from the current frame
  75483. * @param currentFrame The frame to interpolate the animation to
  75484. * @param repeatCount The number of times that the animation should loop
  75485. * @param loopMode The type of looping mode to use
  75486. * @param offsetValue Animation offset value
  75487. * @param highLimitValue The high limit value
  75488. * @returns The interpolated value
  75489. */
  75490. private _interpolate;
  75491. /**
  75492. * Apply the interpolated value to the target
  75493. * @param currentValue defines the value computed by the animation
  75494. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75495. */
  75496. setValue(currentValue: any, weight?: number): void;
  75497. private _setValue;
  75498. /**
  75499. * Gets the loop pmode of the runtime animation
  75500. * @returns Loop Mode
  75501. */
  75502. private _getCorrectLoopMode;
  75503. /**
  75504. * Move the current animation to a given frame
  75505. * @param frame defines the frame to move to
  75506. */
  75507. goToFrame(frame: number): void;
  75508. /**
  75509. * @hidden Internal use only
  75510. */
  75511. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75512. /**
  75513. * Execute the current animation
  75514. * @param delay defines the delay to add to the current frame
  75515. * @param from defines the lower bound of the animation range
  75516. * @param to defines the upper bound of the animation range
  75517. * @param loop defines if the current animation must loop
  75518. * @param speedRatio defines the current speed ratio
  75519. * @param weight defines the weight of the animation (default is -1 so no weight)
  75520. * @param onLoop optional callback called when animation loops
  75521. * @returns a boolean indicating if the animation is running
  75522. */
  75523. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75524. }
  75525. }
  75526. declare module BABYLON {
  75527. /**
  75528. * Class used to store an actual running animation
  75529. */
  75530. export class Animatable {
  75531. /** defines the target object */
  75532. target: any;
  75533. /** defines the starting frame number (default is 0) */
  75534. fromFrame: number;
  75535. /** defines the ending frame number (default is 100) */
  75536. toFrame: number;
  75537. /** defines if the animation must loop (default is false) */
  75538. loopAnimation: boolean;
  75539. /** defines a callback to call when animation ends if it is not looping */
  75540. onAnimationEnd?: (() => void) | null | undefined;
  75541. /** defines a callback to call when animation loops */
  75542. onAnimationLoop?: (() => void) | null | undefined;
  75543. private _localDelayOffset;
  75544. private _pausedDelay;
  75545. private _runtimeAnimations;
  75546. private _paused;
  75547. private _scene;
  75548. private _speedRatio;
  75549. private _weight;
  75550. private _syncRoot;
  75551. /**
  75552. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75553. * This will only apply for non looping animation (default is true)
  75554. */
  75555. disposeOnEnd: boolean;
  75556. /**
  75557. * Gets a boolean indicating if the animation has started
  75558. */
  75559. animationStarted: boolean;
  75560. /**
  75561. * Observer raised when the animation ends
  75562. */
  75563. onAnimationEndObservable: Observable<Animatable>;
  75564. /**
  75565. * Observer raised when the animation loops
  75566. */
  75567. onAnimationLoopObservable: Observable<Animatable>;
  75568. /**
  75569. * Gets the root Animatable used to synchronize and normalize animations
  75570. */
  75571. readonly syncRoot: Animatable;
  75572. /**
  75573. * Gets the current frame of the first RuntimeAnimation
  75574. * Used to synchronize Animatables
  75575. */
  75576. readonly masterFrame: number;
  75577. /**
  75578. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75579. */
  75580. weight: number;
  75581. /**
  75582. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75583. */
  75584. speedRatio: number;
  75585. /**
  75586. * Creates a new Animatable
  75587. * @param scene defines the hosting scene
  75588. * @param target defines the target object
  75589. * @param fromFrame defines the starting frame number (default is 0)
  75590. * @param toFrame defines the ending frame number (default is 100)
  75591. * @param loopAnimation defines if the animation must loop (default is false)
  75592. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75593. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75594. * @param animations defines a group of animation to add to the new Animatable
  75595. * @param onAnimationLoop defines a callback to call when animation loops
  75596. */
  75597. constructor(scene: Scene,
  75598. /** defines the target object */
  75599. target: any,
  75600. /** defines the starting frame number (default is 0) */
  75601. fromFrame?: number,
  75602. /** defines the ending frame number (default is 100) */
  75603. toFrame?: number,
  75604. /** defines if the animation must loop (default is false) */
  75605. loopAnimation?: boolean, speedRatio?: number,
  75606. /** defines a callback to call when animation ends if it is not looping */
  75607. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75608. /** defines a callback to call when animation loops */
  75609. onAnimationLoop?: (() => void) | null | undefined);
  75610. /**
  75611. * Synchronize and normalize current Animatable with a source Animatable
  75612. * This is useful when using animation weights and when animations are not of the same length
  75613. * @param root defines the root Animatable to synchronize with
  75614. * @returns the current Animatable
  75615. */
  75616. syncWith(root: Animatable): Animatable;
  75617. /**
  75618. * Gets the list of runtime animations
  75619. * @returns an array of RuntimeAnimation
  75620. */
  75621. getAnimations(): RuntimeAnimation[];
  75622. /**
  75623. * Adds more animations to the current animatable
  75624. * @param target defines the target of the animations
  75625. * @param animations defines the new animations to add
  75626. */
  75627. appendAnimations(target: any, animations: Animation[]): void;
  75628. /**
  75629. * Gets the source animation for a specific property
  75630. * @param property defines the propertyu to look for
  75631. * @returns null or the source animation for the given property
  75632. */
  75633. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75634. /**
  75635. * Gets the runtime animation for a specific property
  75636. * @param property defines the propertyu to look for
  75637. * @returns null or the runtime animation for the given property
  75638. */
  75639. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75640. /**
  75641. * Resets the animatable to its original state
  75642. */
  75643. reset(): void;
  75644. /**
  75645. * Allows the animatable to blend with current running animations
  75646. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75647. * @param blendingSpeed defines the blending speed to use
  75648. */
  75649. enableBlending(blendingSpeed: number): void;
  75650. /**
  75651. * Disable animation blending
  75652. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75653. */
  75654. disableBlending(): void;
  75655. /**
  75656. * Jump directly to a given frame
  75657. * @param frame defines the frame to jump to
  75658. */
  75659. goToFrame(frame: number): void;
  75660. /**
  75661. * Pause the animation
  75662. */
  75663. pause(): void;
  75664. /**
  75665. * Restart the animation
  75666. */
  75667. restart(): void;
  75668. private _raiseOnAnimationEnd;
  75669. /**
  75670. * Stop and delete the current animation
  75671. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75672. * @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)
  75673. */
  75674. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75675. /**
  75676. * Wait asynchronously for the animation to end
  75677. * @returns a promise which will be fullfilled when the animation ends
  75678. */
  75679. waitAsync(): Promise<Animatable>;
  75680. /** @hidden */
  75681. _animate(delay: number): boolean;
  75682. }
  75683. interface Scene {
  75684. /** @hidden */
  75685. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75686. /** @hidden */
  75687. _processLateAnimationBindingsForMatrices(holder: {
  75688. totalWeight: number;
  75689. animations: RuntimeAnimation[];
  75690. originalValue: Matrix;
  75691. }): any;
  75692. /** @hidden */
  75693. _processLateAnimationBindingsForQuaternions(holder: {
  75694. totalWeight: number;
  75695. animations: RuntimeAnimation[];
  75696. originalValue: Quaternion;
  75697. }, refQuaternion: Quaternion): Quaternion;
  75698. /** @hidden */
  75699. _processLateAnimationBindings(): void;
  75700. /**
  75701. * Will start the animation sequence of a given target
  75702. * @param target defines the target
  75703. * @param from defines from which frame should animation start
  75704. * @param to defines until which frame should animation run.
  75705. * @param weight defines the weight to apply to the animation (1.0 by default)
  75706. * @param loop defines if the animation loops
  75707. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75708. * @param onAnimationEnd defines the function to be executed when the animation ends
  75709. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75710. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75711. * @param onAnimationLoop defines the callback to call when an animation loops
  75712. * @returns the animatable object created for this animation
  75713. */
  75714. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75715. /**
  75716. * Will start the animation sequence of a given target
  75717. * @param target defines the target
  75718. * @param from defines from which frame should animation start
  75719. * @param to defines until which frame should animation run.
  75720. * @param loop defines if the animation loops
  75721. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75722. * @param onAnimationEnd defines the function to be executed when the animation ends
  75723. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75724. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75725. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75726. * @param onAnimationLoop defines the callback to call when an animation loops
  75727. * @returns the animatable object created for this animation
  75728. */
  75729. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75730. /**
  75731. * Will start the animation sequence of a given target and its hierarchy
  75732. * @param target defines the target
  75733. * @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.
  75734. * @param from defines from which frame should animation start
  75735. * @param to defines until which frame should animation run.
  75736. * @param loop defines if the animation loops
  75737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75738. * @param onAnimationEnd defines the function to be executed when the animation ends
  75739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75740. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75741. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75742. * @param onAnimationLoop defines the callback to call when an animation loops
  75743. * @returns the list of created animatables
  75744. */
  75745. 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[];
  75746. /**
  75747. * Begin a new animation on a given node
  75748. * @param target defines the target where the animation will take place
  75749. * @param animations defines the list of animations to start
  75750. * @param from defines the initial value
  75751. * @param to defines the final value
  75752. * @param loop defines if you want animation to loop (off by default)
  75753. * @param speedRatio defines the speed ratio to apply to all animations
  75754. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75755. * @param onAnimationLoop defines the callback to call when an animation loops
  75756. * @returns the list of created animatables
  75757. */
  75758. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75759. /**
  75760. * Begin a new animation on a given node and its hierarchy
  75761. * @param target defines the root node where the animation will take place
  75762. * @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.
  75763. * @param animations defines the list of animations to start
  75764. * @param from defines the initial value
  75765. * @param to defines the final value
  75766. * @param loop defines if you want animation to loop (off by default)
  75767. * @param speedRatio defines the speed ratio to apply to all animations
  75768. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75769. * @param onAnimationLoop defines the callback to call when an animation loops
  75770. * @returns the list of animatables created for all nodes
  75771. */
  75772. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75773. /**
  75774. * Gets the animatable associated with a specific target
  75775. * @param target defines the target of the animatable
  75776. * @returns the required animatable if found
  75777. */
  75778. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75779. /**
  75780. * Gets all animatables associated with a given target
  75781. * @param target defines the target to look animatables for
  75782. * @returns an array of Animatables
  75783. */
  75784. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75785. /**
  75786. * Will stop the animation of the given target
  75787. * @param target - the target
  75788. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75789. * @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)
  75790. */
  75791. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75792. /**
  75793. * Stops and removes all animations that have been applied to the scene
  75794. */
  75795. stopAllAnimations(): void;
  75796. }
  75797. interface Bone {
  75798. /**
  75799. * Copy an animation range from another bone
  75800. * @param source defines the source bone
  75801. * @param rangeName defines the range name to copy
  75802. * @param frameOffset defines the frame offset
  75803. * @param rescaleAsRequired defines if rescaling must be applied if required
  75804. * @param skelDimensionsRatio defines the scaling ratio
  75805. * @returns true if operation was successful
  75806. */
  75807. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75808. }
  75809. }
  75810. declare module BABYLON {
  75811. /**
  75812. * Class used to handle skinning animations
  75813. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75814. */
  75815. export class Skeleton implements IAnimatable {
  75816. /** defines the skeleton name */
  75817. name: string;
  75818. /** defines the skeleton Id */
  75819. id: string;
  75820. /**
  75821. * Defines the list of child bones
  75822. */
  75823. bones: Bone[];
  75824. /**
  75825. * Defines an estimate of the dimension of the skeleton at rest
  75826. */
  75827. dimensionsAtRest: Vector3;
  75828. /**
  75829. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75830. */
  75831. needInitialSkinMatrix: boolean;
  75832. /**
  75833. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75834. */
  75835. overrideMesh: Nullable<AbstractMesh>;
  75836. /**
  75837. * Gets the list of animations attached to this skeleton
  75838. */
  75839. animations: Array<Animation>;
  75840. private _scene;
  75841. private _isDirty;
  75842. private _transformMatrices;
  75843. private _transformMatrixTexture;
  75844. private _meshesWithPoseMatrix;
  75845. private _animatables;
  75846. private _identity;
  75847. private _synchronizedWithMesh;
  75848. private _ranges;
  75849. private _lastAbsoluteTransformsUpdateId;
  75850. private _canUseTextureForBones;
  75851. /** @hidden */
  75852. _numBonesWithLinkedTransformNode: number;
  75853. /**
  75854. * Specifies if the skeleton should be serialized
  75855. */
  75856. doNotSerialize: boolean;
  75857. /**
  75858. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75859. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75860. */
  75861. useTextureToStoreBoneMatrices: boolean;
  75862. private _animationPropertiesOverride;
  75863. /**
  75864. * Gets or sets the animation properties override
  75865. */
  75866. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75867. /**
  75868. * An observable triggered before computing the skeleton's matrices
  75869. */
  75870. onBeforeComputeObservable: Observable<Skeleton>;
  75871. /**
  75872. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75873. */
  75874. readonly isUsingTextureForMatrices: boolean;
  75875. /**
  75876. * Creates a new skeleton
  75877. * @param name defines the skeleton name
  75878. * @param id defines the skeleton Id
  75879. * @param scene defines the hosting scene
  75880. */
  75881. constructor(
  75882. /** defines the skeleton name */
  75883. name: string,
  75884. /** defines the skeleton Id */
  75885. id: string, scene: Scene);
  75886. /**
  75887. * Gets the current object class name.
  75888. * @return the class name
  75889. */
  75890. getClassName(): string;
  75891. /**
  75892. * Returns an array containing the root bones
  75893. * @returns an array containing the root bones
  75894. */
  75895. getChildren(): Array<Bone>;
  75896. /**
  75897. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75898. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75899. * @returns a Float32Array containing matrices data
  75900. */
  75901. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75902. /**
  75903. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75904. * @returns a raw texture containing the data
  75905. */
  75906. getTransformMatrixTexture(): Nullable<RawTexture>;
  75907. /**
  75908. * Gets the current hosting scene
  75909. * @returns a scene object
  75910. */
  75911. getScene(): Scene;
  75912. /**
  75913. * Gets a string representing the current skeleton data
  75914. * @param fullDetails defines a boolean indicating if we want a verbose version
  75915. * @returns a string representing the current skeleton data
  75916. */
  75917. toString(fullDetails?: boolean): string;
  75918. /**
  75919. * Get bone's index searching by name
  75920. * @param name defines bone's name to search for
  75921. * @return the indice of the bone. Returns -1 if not found
  75922. */
  75923. getBoneIndexByName(name: string): number;
  75924. /**
  75925. * Creater a new animation range
  75926. * @param name defines the name of the range
  75927. * @param from defines the start key
  75928. * @param to defines the end key
  75929. */
  75930. createAnimationRange(name: string, from: number, to: number): void;
  75931. /**
  75932. * Delete a specific animation range
  75933. * @param name defines the name of the range
  75934. * @param deleteFrames defines if frames must be removed as well
  75935. */
  75936. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75937. /**
  75938. * Gets a specific animation range
  75939. * @param name defines the name of the range to look for
  75940. * @returns the requested animation range or null if not found
  75941. */
  75942. getAnimationRange(name: string): Nullable<AnimationRange>;
  75943. /**
  75944. * Gets the list of all animation ranges defined on this skeleton
  75945. * @returns an array
  75946. */
  75947. getAnimationRanges(): Nullable<AnimationRange>[];
  75948. /**
  75949. * Copy animation range from a source skeleton.
  75950. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75951. * @param source defines the source skeleton
  75952. * @param name defines the name of the range to copy
  75953. * @param rescaleAsRequired defines if rescaling must be applied if required
  75954. * @returns true if operation was successful
  75955. */
  75956. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75957. /**
  75958. * Forces the skeleton to go to rest pose
  75959. */
  75960. returnToRest(): void;
  75961. private _getHighestAnimationFrame;
  75962. /**
  75963. * Begin a specific animation range
  75964. * @param name defines the name of the range to start
  75965. * @param loop defines if looping must be turned on (false by default)
  75966. * @param speedRatio defines the speed ratio to apply (1 by default)
  75967. * @param onAnimationEnd defines a callback which will be called when animation will end
  75968. * @returns a new animatable
  75969. */
  75970. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75971. /** @hidden */
  75972. _markAsDirty(): void;
  75973. /** @hidden */
  75974. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75975. /** @hidden */
  75976. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75977. private _computeTransformMatrices;
  75978. /**
  75979. * Build all resources required to render a skeleton
  75980. */
  75981. prepare(): void;
  75982. /**
  75983. * Gets the list of animatables currently running for this skeleton
  75984. * @returns an array of animatables
  75985. */
  75986. getAnimatables(): IAnimatable[];
  75987. /**
  75988. * Clone the current skeleton
  75989. * @param name defines the name of the new skeleton
  75990. * @param id defines the id of the enw skeleton
  75991. * @returns the new skeleton
  75992. */
  75993. clone(name: string, id: string): Skeleton;
  75994. /**
  75995. * Enable animation blending for this skeleton
  75996. * @param blendingSpeed defines the blending speed to apply
  75997. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75998. */
  75999. enableBlending(blendingSpeed?: number): void;
  76000. /**
  76001. * Releases all resources associated with the current skeleton
  76002. */
  76003. dispose(): void;
  76004. /**
  76005. * Serialize the skeleton in a JSON object
  76006. * @returns a JSON object
  76007. */
  76008. serialize(): any;
  76009. /**
  76010. * Creates a new skeleton from serialized data
  76011. * @param parsedSkeleton defines the serialized data
  76012. * @param scene defines the hosting scene
  76013. * @returns a new skeleton
  76014. */
  76015. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76016. /**
  76017. * Compute all node absolute transforms
  76018. * @param forceUpdate defines if computation must be done even if cache is up to date
  76019. */
  76020. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76021. /**
  76022. * Gets the root pose matrix
  76023. * @returns a matrix
  76024. */
  76025. getPoseMatrix(): Nullable<Matrix>;
  76026. /**
  76027. * Sorts bones per internal index
  76028. */
  76029. sortBones(): void;
  76030. private _sortBones;
  76031. }
  76032. }
  76033. declare module BABYLON {
  76034. /**
  76035. * Defines a target to use with MorphTargetManager
  76036. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76037. */
  76038. export class MorphTarget implements IAnimatable {
  76039. /** defines the name of the target */
  76040. name: string;
  76041. /**
  76042. * Gets or sets the list of animations
  76043. */
  76044. animations: Animation[];
  76045. private _scene;
  76046. private _positions;
  76047. private _normals;
  76048. private _tangents;
  76049. private _influence;
  76050. /**
  76051. * Observable raised when the influence changes
  76052. */
  76053. onInfluenceChanged: Observable<boolean>;
  76054. /** @hidden */
  76055. _onDataLayoutChanged: Observable<void>;
  76056. /**
  76057. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76058. */
  76059. influence: number;
  76060. /**
  76061. * Gets or sets the id of the morph Target
  76062. */
  76063. id: string;
  76064. private _animationPropertiesOverride;
  76065. /**
  76066. * Gets or sets the animation properties override
  76067. */
  76068. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76069. /**
  76070. * Creates a new MorphTarget
  76071. * @param name defines the name of the target
  76072. * @param influence defines the influence to use
  76073. * @param scene defines the scene the morphtarget belongs to
  76074. */
  76075. constructor(
  76076. /** defines the name of the target */
  76077. name: string, influence?: number, scene?: Nullable<Scene>);
  76078. /**
  76079. * Gets a boolean defining if the target contains position data
  76080. */
  76081. readonly hasPositions: boolean;
  76082. /**
  76083. * Gets a boolean defining if the target contains normal data
  76084. */
  76085. readonly hasNormals: boolean;
  76086. /**
  76087. * Gets a boolean defining if the target contains tangent data
  76088. */
  76089. readonly hasTangents: boolean;
  76090. /**
  76091. * Affects position data to this target
  76092. * @param data defines the position data to use
  76093. */
  76094. setPositions(data: Nullable<FloatArray>): void;
  76095. /**
  76096. * Gets the position data stored in this target
  76097. * @returns a FloatArray containing the position data (or null if not present)
  76098. */
  76099. getPositions(): Nullable<FloatArray>;
  76100. /**
  76101. * Affects normal data to this target
  76102. * @param data defines the normal data to use
  76103. */
  76104. setNormals(data: Nullable<FloatArray>): void;
  76105. /**
  76106. * Gets the normal data stored in this target
  76107. * @returns a FloatArray containing the normal data (or null if not present)
  76108. */
  76109. getNormals(): Nullable<FloatArray>;
  76110. /**
  76111. * Affects tangent data to this target
  76112. * @param data defines the tangent data to use
  76113. */
  76114. setTangents(data: Nullable<FloatArray>): void;
  76115. /**
  76116. * Gets the tangent data stored in this target
  76117. * @returns a FloatArray containing the tangent data (or null if not present)
  76118. */
  76119. getTangents(): Nullable<FloatArray>;
  76120. /**
  76121. * Serializes the current target into a Serialization object
  76122. * @returns the serialized object
  76123. */
  76124. serialize(): any;
  76125. /**
  76126. * Returns the string "MorphTarget"
  76127. * @returns "MorphTarget"
  76128. */
  76129. getClassName(): string;
  76130. /**
  76131. * Creates a new target from serialized data
  76132. * @param serializationObject defines the serialized data to use
  76133. * @returns a new MorphTarget
  76134. */
  76135. static Parse(serializationObject: any): MorphTarget;
  76136. /**
  76137. * Creates a MorphTarget from mesh data
  76138. * @param mesh defines the source mesh
  76139. * @param name defines the name to use for the new target
  76140. * @param influence defines the influence to attach to the target
  76141. * @returns a new MorphTarget
  76142. */
  76143. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76144. }
  76145. }
  76146. declare module BABYLON {
  76147. /**
  76148. * This class is used to deform meshes using morphing between different targets
  76149. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76150. */
  76151. export class MorphTargetManager {
  76152. private _targets;
  76153. private _targetInfluenceChangedObservers;
  76154. private _targetDataLayoutChangedObservers;
  76155. private _activeTargets;
  76156. private _scene;
  76157. private _influences;
  76158. private _supportsNormals;
  76159. private _supportsTangents;
  76160. private _vertexCount;
  76161. private _uniqueId;
  76162. private _tempInfluences;
  76163. /**
  76164. * Creates a new MorphTargetManager
  76165. * @param scene defines the current scene
  76166. */
  76167. constructor(scene?: Nullable<Scene>);
  76168. /**
  76169. * Gets the unique ID of this manager
  76170. */
  76171. readonly uniqueId: number;
  76172. /**
  76173. * Gets the number of vertices handled by this manager
  76174. */
  76175. readonly vertexCount: number;
  76176. /**
  76177. * Gets a boolean indicating if this manager supports morphing of normals
  76178. */
  76179. readonly supportsNormals: boolean;
  76180. /**
  76181. * Gets a boolean indicating if this manager supports morphing of tangents
  76182. */
  76183. readonly supportsTangents: boolean;
  76184. /**
  76185. * Gets the number of targets stored in this manager
  76186. */
  76187. readonly numTargets: number;
  76188. /**
  76189. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76190. */
  76191. readonly numInfluencers: number;
  76192. /**
  76193. * Gets the list of influences (one per target)
  76194. */
  76195. readonly influences: Float32Array;
  76196. /**
  76197. * Gets the active target at specified index. An active target is a target with an influence > 0
  76198. * @param index defines the index to check
  76199. * @returns the requested target
  76200. */
  76201. getActiveTarget(index: number): MorphTarget;
  76202. /**
  76203. * Gets the target at specified index
  76204. * @param index defines the index to check
  76205. * @returns the requested target
  76206. */
  76207. getTarget(index: number): MorphTarget;
  76208. /**
  76209. * Add a new target to this manager
  76210. * @param target defines the target to add
  76211. */
  76212. addTarget(target: MorphTarget): void;
  76213. /**
  76214. * Removes a target from the manager
  76215. * @param target defines the target to remove
  76216. */
  76217. removeTarget(target: MorphTarget): void;
  76218. /**
  76219. * Serializes the current manager into a Serialization object
  76220. * @returns the serialized object
  76221. */
  76222. serialize(): any;
  76223. private _syncActiveTargets;
  76224. /**
  76225. * Syncrhonize the targets with all the meshes using this morph target manager
  76226. */
  76227. synchronize(): void;
  76228. /**
  76229. * Creates a new MorphTargetManager from serialized data
  76230. * @param serializationObject defines the serialized data
  76231. * @param scene defines the hosting scene
  76232. * @returns the new MorphTargetManager
  76233. */
  76234. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76235. }
  76236. }
  76237. declare module BABYLON {
  76238. /**
  76239. * Mesh representing the gorund
  76240. */
  76241. export class GroundMesh extends Mesh {
  76242. /** If octree should be generated */
  76243. generateOctree: boolean;
  76244. private _heightQuads;
  76245. /** @hidden */
  76246. _subdivisionsX: number;
  76247. /** @hidden */
  76248. _subdivisionsY: number;
  76249. /** @hidden */
  76250. _width: number;
  76251. /** @hidden */
  76252. _height: number;
  76253. /** @hidden */
  76254. _minX: number;
  76255. /** @hidden */
  76256. _maxX: number;
  76257. /** @hidden */
  76258. _minZ: number;
  76259. /** @hidden */
  76260. _maxZ: number;
  76261. constructor(name: string, scene: Scene);
  76262. /**
  76263. * "GroundMesh"
  76264. * @returns "GroundMesh"
  76265. */
  76266. getClassName(): string;
  76267. /**
  76268. * The minimum of x and y subdivisions
  76269. */
  76270. readonly subdivisions: number;
  76271. /**
  76272. * X subdivisions
  76273. */
  76274. readonly subdivisionsX: number;
  76275. /**
  76276. * Y subdivisions
  76277. */
  76278. readonly subdivisionsY: number;
  76279. /**
  76280. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76281. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76282. * @param chunksCount the number of subdivisions for x and y
  76283. * @param octreeBlocksSize (Default: 32)
  76284. */
  76285. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76286. /**
  76287. * Returns a height (y) value in the Worl system :
  76288. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76289. * @param x x coordinate
  76290. * @param z z coordinate
  76291. * @returns the ground y position if (x, z) are outside the ground surface.
  76292. */
  76293. getHeightAtCoordinates(x: number, z: number): number;
  76294. /**
  76295. * Returns a normalized vector (Vector3) orthogonal to the ground
  76296. * at the ground coordinates (x, z) expressed in the World system.
  76297. * @param x x coordinate
  76298. * @param z z coordinate
  76299. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76300. */
  76301. getNormalAtCoordinates(x: number, z: number): Vector3;
  76302. /**
  76303. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76304. * at the ground coordinates (x, z) expressed in the World system.
  76305. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76306. * @param x x coordinate
  76307. * @param z z coordinate
  76308. * @param ref vector to store the result
  76309. * @returns the GroundMesh.
  76310. */
  76311. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76312. /**
  76313. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76314. * if the ground has been updated.
  76315. * This can be used in the render loop.
  76316. * @returns the GroundMesh.
  76317. */
  76318. updateCoordinateHeights(): GroundMesh;
  76319. private _getFacetAt;
  76320. private _initHeightQuads;
  76321. private _computeHeightQuads;
  76322. /**
  76323. * Serializes this ground mesh
  76324. * @param serializationObject object to write serialization to
  76325. */
  76326. serialize(serializationObject: any): void;
  76327. /**
  76328. * Parses a serialized ground mesh
  76329. * @param parsedMesh the serialized mesh
  76330. * @param scene the scene to create the ground mesh in
  76331. * @returns the created ground mesh
  76332. */
  76333. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76334. }
  76335. }
  76336. declare module BABYLON {
  76337. /**
  76338. * Interface for Physics-Joint data
  76339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76340. */
  76341. export interface PhysicsJointData {
  76342. /**
  76343. * The main pivot of the joint
  76344. */
  76345. mainPivot?: Vector3;
  76346. /**
  76347. * The connected pivot of the joint
  76348. */
  76349. connectedPivot?: Vector3;
  76350. /**
  76351. * The main axis of the joint
  76352. */
  76353. mainAxis?: Vector3;
  76354. /**
  76355. * The connected axis of the joint
  76356. */
  76357. connectedAxis?: Vector3;
  76358. /**
  76359. * The collision of the joint
  76360. */
  76361. collision?: boolean;
  76362. /**
  76363. * Native Oimo/Cannon/Energy data
  76364. */
  76365. nativeParams?: any;
  76366. }
  76367. /**
  76368. * This is a holder class for the physics joint created by the physics plugin
  76369. * It holds a set of functions to control the underlying joint
  76370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76371. */
  76372. export class PhysicsJoint {
  76373. /**
  76374. * The type of the physics joint
  76375. */
  76376. type: number;
  76377. /**
  76378. * The data for the physics joint
  76379. */
  76380. jointData: PhysicsJointData;
  76381. private _physicsJoint;
  76382. protected _physicsPlugin: IPhysicsEnginePlugin;
  76383. /**
  76384. * Initializes the physics joint
  76385. * @param type The type of the physics joint
  76386. * @param jointData The data for the physics joint
  76387. */
  76388. constructor(
  76389. /**
  76390. * The type of the physics joint
  76391. */
  76392. type: number,
  76393. /**
  76394. * The data for the physics joint
  76395. */
  76396. jointData: PhysicsJointData);
  76397. /**
  76398. * Gets the physics joint
  76399. */
  76400. /**
  76401. * Sets the physics joint
  76402. */
  76403. physicsJoint: any;
  76404. /**
  76405. * Sets the physics plugin
  76406. */
  76407. physicsPlugin: IPhysicsEnginePlugin;
  76408. /**
  76409. * Execute a function that is physics-plugin specific.
  76410. * @param {Function} func the function that will be executed.
  76411. * It accepts two parameters: the physics world and the physics joint
  76412. */
  76413. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76414. /**
  76415. * Distance-Joint type
  76416. */
  76417. static DistanceJoint: number;
  76418. /**
  76419. * Hinge-Joint type
  76420. */
  76421. static HingeJoint: number;
  76422. /**
  76423. * Ball-and-Socket joint type
  76424. */
  76425. static BallAndSocketJoint: number;
  76426. /**
  76427. * Wheel-Joint type
  76428. */
  76429. static WheelJoint: number;
  76430. /**
  76431. * Slider-Joint type
  76432. */
  76433. static SliderJoint: number;
  76434. /**
  76435. * Prismatic-Joint type
  76436. */
  76437. static PrismaticJoint: number;
  76438. /**
  76439. * Universal-Joint type
  76440. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76441. */
  76442. static UniversalJoint: number;
  76443. /**
  76444. * Hinge-Joint 2 type
  76445. */
  76446. static Hinge2Joint: number;
  76447. /**
  76448. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76449. */
  76450. static PointToPointJoint: number;
  76451. /**
  76452. * Spring-Joint type
  76453. */
  76454. static SpringJoint: number;
  76455. /**
  76456. * Lock-Joint type
  76457. */
  76458. static LockJoint: number;
  76459. }
  76460. /**
  76461. * A class representing a physics distance joint
  76462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76463. */
  76464. export class DistanceJoint extends PhysicsJoint {
  76465. /**
  76466. *
  76467. * @param jointData The data for the Distance-Joint
  76468. */
  76469. constructor(jointData: DistanceJointData);
  76470. /**
  76471. * Update the predefined distance.
  76472. * @param maxDistance The maximum preferred distance
  76473. * @param minDistance The minimum preferred distance
  76474. */
  76475. updateDistance(maxDistance: number, minDistance?: number): void;
  76476. }
  76477. /**
  76478. * Represents a Motor-Enabled Joint
  76479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76480. */
  76481. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76482. /**
  76483. * Initializes the Motor-Enabled Joint
  76484. * @param type The type of the joint
  76485. * @param jointData The physica joint data for the joint
  76486. */
  76487. constructor(type: number, jointData: PhysicsJointData);
  76488. /**
  76489. * Set the motor values.
  76490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76491. * @param force the force to apply
  76492. * @param maxForce max force for this motor.
  76493. */
  76494. setMotor(force?: number, maxForce?: number): void;
  76495. /**
  76496. * Set the motor's limits.
  76497. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76498. * @param upperLimit The upper limit of the motor
  76499. * @param lowerLimit The lower limit of the motor
  76500. */
  76501. setLimit(upperLimit: number, lowerLimit?: number): void;
  76502. }
  76503. /**
  76504. * This class represents a single physics Hinge-Joint
  76505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76506. */
  76507. export class HingeJoint extends MotorEnabledJoint {
  76508. /**
  76509. * Initializes the Hinge-Joint
  76510. * @param jointData The joint data for the Hinge-Joint
  76511. */
  76512. constructor(jointData: PhysicsJointData);
  76513. /**
  76514. * Set the motor values.
  76515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76516. * @param {number} force the force to apply
  76517. * @param {number} maxForce max force for this motor.
  76518. */
  76519. setMotor(force?: number, maxForce?: number): void;
  76520. /**
  76521. * Set the motor's limits.
  76522. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76523. * @param upperLimit The upper limit of the motor
  76524. * @param lowerLimit The lower limit of the motor
  76525. */
  76526. setLimit(upperLimit: number, lowerLimit?: number): void;
  76527. }
  76528. /**
  76529. * This class represents a dual hinge physics joint (same as wheel joint)
  76530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76531. */
  76532. export class Hinge2Joint extends MotorEnabledJoint {
  76533. /**
  76534. * Initializes the Hinge2-Joint
  76535. * @param jointData The joint data for the Hinge2-Joint
  76536. */
  76537. constructor(jointData: PhysicsJointData);
  76538. /**
  76539. * Set the motor values.
  76540. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76541. * @param {number} targetSpeed the speed the motor is to reach
  76542. * @param {number} maxForce max force for this motor.
  76543. * @param {motorIndex} the motor's index, 0 or 1.
  76544. */
  76545. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76546. /**
  76547. * Set the motor limits.
  76548. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76549. * @param {number} upperLimit the upper limit
  76550. * @param {number} lowerLimit lower limit
  76551. * @param {motorIndex} the motor's index, 0 or 1.
  76552. */
  76553. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76554. }
  76555. /**
  76556. * Interface for a motor enabled joint
  76557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76558. */
  76559. export interface IMotorEnabledJoint {
  76560. /**
  76561. * Physics joint
  76562. */
  76563. physicsJoint: any;
  76564. /**
  76565. * Sets the motor of the motor-enabled joint
  76566. * @param force The force of the motor
  76567. * @param maxForce The maximum force of the motor
  76568. * @param motorIndex The index of the motor
  76569. */
  76570. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76571. /**
  76572. * Sets the limit of the motor
  76573. * @param upperLimit The upper limit of the motor
  76574. * @param lowerLimit The lower limit of the motor
  76575. * @param motorIndex The index of the motor
  76576. */
  76577. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76578. }
  76579. /**
  76580. * Joint data for a Distance-Joint
  76581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76582. */
  76583. export interface DistanceJointData extends PhysicsJointData {
  76584. /**
  76585. * Max distance the 2 joint objects can be apart
  76586. */
  76587. maxDistance: number;
  76588. }
  76589. /**
  76590. * Joint data from a spring joint
  76591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76592. */
  76593. export interface SpringJointData extends PhysicsJointData {
  76594. /**
  76595. * Length of the spring
  76596. */
  76597. length: number;
  76598. /**
  76599. * Stiffness of the spring
  76600. */
  76601. stiffness: number;
  76602. /**
  76603. * Damping of the spring
  76604. */
  76605. damping: number;
  76606. /** this callback will be called when applying the force to the impostors. */
  76607. forceApplicationCallback: () => void;
  76608. }
  76609. }
  76610. declare module BABYLON {
  76611. /**
  76612. * Interface used to describe a physics joint
  76613. */
  76614. export interface PhysicsImpostorJoint {
  76615. /** Defines the main impostor to which the joint is linked */
  76616. mainImpostor: PhysicsImpostor;
  76617. /** Defines the impostor that is connected to the main impostor using this joint */
  76618. connectedImpostor: PhysicsImpostor;
  76619. /** Defines the joint itself */
  76620. joint: PhysicsJoint;
  76621. }
  76622. /** @hidden */
  76623. export interface IPhysicsEnginePlugin {
  76624. world: any;
  76625. name: string;
  76626. setGravity(gravity: Vector3): void;
  76627. setTimeStep(timeStep: number): void;
  76628. getTimeStep(): number;
  76629. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76632. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76633. removePhysicsBody(impostor: PhysicsImpostor): void;
  76634. generateJoint(joint: PhysicsImpostorJoint): void;
  76635. removeJoint(joint: PhysicsImpostorJoint): void;
  76636. isSupported(): boolean;
  76637. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76638. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76639. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76640. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76641. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76642. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76643. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76644. getBodyMass(impostor: PhysicsImpostor): number;
  76645. getBodyFriction(impostor: PhysicsImpostor): number;
  76646. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76647. getBodyRestitution(impostor: PhysicsImpostor): number;
  76648. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76649. sleepBody(impostor: PhysicsImpostor): void;
  76650. wakeUpBody(impostor: PhysicsImpostor): void;
  76651. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76652. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76654. getRadius(impostor: PhysicsImpostor): number;
  76655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76656. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76657. dispose(): void;
  76658. }
  76659. /**
  76660. * Interface used to define a physics engine
  76661. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76662. */
  76663. export interface IPhysicsEngine {
  76664. /**
  76665. * Gets the gravity vector used by the simulation
  76666. */
  76667. gravity: Vector3;
  76668. /**
  76669. * Sets the gravity vector used by the simulation
  76670. * @param gravity defines the gravity vector to use
  76671. */
  76672. setGravity(gravity: Vector3): void;
  76673. /**
  76674. * Set the time step of the physics engine.
  76675. * Default is 1/60.
  76676. * To slow it down, enter 1/600 for example.
  76677. * To speed it up, 1/30
  76678. * @param newTimeStep the new timestep to apply to this world.
  76679. */
  76680. setTimeStep(newTimeStep: number): void;
  76681. /**
  76682. * Get the time step of the physics engine.
  76683. * @returns the current time step
  76684. */
  76685. getTimeStep(): number;
  76686. /**
  76687. * Release all resources
  76688. */
  76689. dispose(): void;
  76690. /**
  76691. * Gets the name of the current physics plugin
  76692. * @returns the name of the plugin
  76693. */
  76694. getPhysicsPluginName(): string;
  76695. /**
  76696. * Adding a new impostor for the impostor tracking.
  76697. * This will be done by the impostor itself.
  76698. * @param impostor the impostor to add
  76699. */
  76700. addImpostor(impostor: PhysicsImpostor): void;
  76701. /**
  76702. * Remove an impostor from the engine.
  76703. * This impostor and its mesh will not longer be updated by the physics engine.
  76704. * @param impostor the impostor to remove
  76705. */
  76706. removeImpostor(impostor: PhysicsImpostor): void;
  76707. /**
  76708. * Add a joint to the physics engine
  76709. * @param mainImpostor defines the main impostor to which the joint is added.
  76710. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76711. * @param joint defines the joint that will connect both impostors.
  76712. */
  76713. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76714. /**
  76715. * Removes a joint from the simulation
  76716. * @param mainImpostor defines the impostor used with the joint
  76717. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76718. * @param joint defines the joint to remove
  76719. */
  76720. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76721. /**
  76722. * Gets the current plugin used to run the simulation
  76723. * @returns current plugin
  76724. */
  76725. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76726. /**
  76727. * Gets the list of physic impostors
  76728. * @returns an array of PhysicsImpostor
  76729. */
  76730. getImpostors(): Array<PhysicsImpostor>;
  76731. /**
  76732. * Gets the impostor for a physics enabled object
  76733. * @param object defines the object impersonated by the impostor
  76734. * @returns the PhysicsImpostor or null if not found
  76735. */
  76736. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76737. /**
  76738. * Gets the impostor for a physics body object
  76739. * @param body defines physics body used by the impostor
  76740. * @returns the PhysicsImpostor or null if not found
  76741. */
  76742. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76743. /**
  76744. * Called by the scene. No need to call it.
  76745. * @param delta defines the timespam between frames
  76746. */
  76747. _step(delta: number): void;
  76748. }
  76749. }
  76750. declare module BABYLON {
  76751. /**
  76752. * The interface for the physics imposter parameters
  76753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76754. */
  76755. export interface PhysicsImpostorParameters {
  76756. /**
  76757. * The mass of the physics imposter
  76758. */
  76759. mass: number;
  76760. /**
  76761. * The friction of the physics imposter
  76762. */
  76763. friction?: number;
  76764. /**
  76765. * The coefficient of restitution of the physics imposter
  76766. */
  76767. restitution?: number;
  76768. /**
  76769. * The native options of the physics imposter
  76770. */
  76771. nativeOptions?: any;
  76772. /**
  76773. * Specifies if the parent should be ignored
  76774. */
  76775. ignoreParent?: boolean;
  76776. /**
  76777. * Specifies if bi-directional transformations should be disabled
  76778. */
  76779. disableBidirectionalTransformation?: boolean;
  76780. }
  76781. /**
  76782. * Interface for a physics-enabled object
  76783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76784. */
  76785. export interface IPhysicsEnabledObject {
  76786. /**
  76787. * The position of the physics-enabled object
  76788. */
  76789. position: Vector3;
  76790. /**
  76791. * The rotation of the physics-enabled object
  76792. */
  76793. rotationQuaternion: Nullable<Quaternion>;
  76794. /**
  76795. * The scale of the physics-enabled object
  76796. */
  76797. scaling: Vector3;
  76798. /**
  76799. * The rotation of the physics-enabled object
  76800. */
  76801. rotation?: Vector3;
  76802. /**
  76803. * The parent of the physics-enabled object
  76804. */
  76805. parent?: any;
  76806. /**
  76807. * The bounding info of the physics-enabled object
  76808. * @returns The bounding info of the physics-enabled object
  76809. */
  76810. getBoundingInfo(): BoundingInfo;
  76811. /**
  76812. * Computes the world matrix
  76813. * @param force Specifies if the world matrix should be computed by force
  76814. * @returns A world matrix
  76815. */
  76816. computeWorldMatrix(force: boolean): Matrix;
  76817. /**
  76818. * Gets the world matrix
  76819. * @returns A world matrix
  76820. */
  76821. getWorldMatrix?(): Matrix;
  76822. /**
  76823. * Gets the child meshes
  76824. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76825. * @returns An array of abstract meshes
  76826. */
  76827. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76828. /**
  76829. * Gets the vertex data
  76830. * @param kind The type of vertex data
  76831. * @returns A nullable array of numbers, or a float32 array
  76832. */
  76833. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76834. /**
  76835. * Gets the indices from the mesh
  76836. * @returns A nullable array of index arrays
  76837. */
  76838. getIndices?(): Nullable<IndicesArray>;
  76839. /**
  76840. * Gets the scene from the mesh
  76841. * @returns the indices array or null
  76842. */
  76843. getScene?(): Scene;
  76844. /**
  76845. * Gets the absolute position from the mesh
  76846. * @returns the absolute position
  76847. */
  76848. getAbsolutePosition(): Vector3;
  76849. /**
  76850. * Gets the absolute pivot point from the mesh
  76851. * @returns the absolute pivot point
  76852. */
  76853. getAbsolutePivotPoint(): Vector3;
  76854. /**
  76855. * Rotates the mesh
  76856. * @param axis The axis of rotation
  76857. * @param amount The amount of rotation
  76858. * @param space The space of the rotation
  76859. * @returns The rotation transform node
  76860. */
  76861. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76862. /**
  76863. * Translates the mesh
  76864. * @param axis The axis of translation
  76865. * @param distance The distance of translation
  76866. * @param space The space of the translation
  76867. * @returns The transform node
  76868. */
  76869. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76870. /**
  76871. * Sets the absolute position of the mesh
  76872. * @param absolutePosition The absolute position of the mesh
  76873. * @returns The transform node
  76874. */
  76875. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76876. /**
  76877. * Gets the class name of the mesh
  76878. * @returns The class name
  76879. */
  76880. getClassName(): string;
  76881. }
  76882. /**
  76883. * Represents a physics imposter
  76884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76885. */
  76886. export class PhysicsImpostor {
  76887. /**
  76888. * The physics-enabled object used as the physics imposter
  76889. */
  76890. object: IPhysicsEnabledObject;
  76891. /**
  76892. * The type of the physics imposter
  76893. */
  76894. type: number;
  76895. private _options;
  76896. private _scene?;
  76897. /**
  76898. * The default object size of the imposter
  76899. */
  76900. static DEFAULT_OBJECT_SIZE: Vector3;
  76901. /**
  76902. * The identity quaternion of the imposter
  76903. */
  76904. static IDENTITY_QUATERNION: Quaternion;
  76905. /** @hidden */
  76906. _pluginData: any;
  76907. private _physicsEngine;
  76908. private _physicsBody;
  76909. private _bodyUpdateRequired;
  76910. private _onBeforePhysicsStepCallbacks;
  76911. private _onAfterPhysicsStepCallbacks;
  76912. /** @hidden */
  76913. _onPhysicsCollideCallbacks: Array<{
  76914. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76915. otherImpostors: Array<PhysicsImpostor>;
  76916. }>;
  76917. private _deltaPosition;
  76918. private _deltaRotation;
  76919. private _deltaRotationConjugated;
  76920. private _parent;
  76921. private _isDisposed;
  76922. private static _tmpVecs;
  76923. private static _tmpQuat;
  76924. /**
  76925. * Specifies if the physics imposter is disposed
  76926. */
  76927. readonly isDisposed: boolean;
  76928. /**
  76929. * Gets the mass of the physics imposter
  76930. */
  76931. mass: number;
  76932. /**
  76933. * Gets the coefficient of friction
  76934. */
  76935. /**
  76936. * Sets the coefficient of friction
  76937. */
  76938. friction: number;
  76939. /**
  76940. * Gets the coefficient of restitution
  76941. */
  76942. /**
  76943. * Sets the coefficient of restitution
  76944. */
  76945. restitution: number;
  76946. /**
  76947. * The unique id of the physics imposter
  76948. * set by the physics engine when adding this impostor to the array
  76949. */
  76950. uniqueId: number;
  76951. private _joints;
  76952. /**
  76953. * Initializes the physics imposter
  76954. * @param object The physics-enabled object used as the physics imposter
  76955. * @param type The type of the physics imposter
  76956. * @param _options The options for the physics imposter
  76957. * @param _scene The Babylon scene
  76958. */
  76959. constructor(
  76960. /**
  76961. * The physics-enabled object used as the physics imposter
  76962. */
  76963. object: IPhysicsEnabledObject,
  76964. /**
  76965. * The type of the physics imposter
  76966. */
  76967. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76968. /**
  76969. * This function will completly initialize this impostor.
  76970. * It will create a new body - but only if this mesh has no parent.
  76971. * If it has, this impostor will not be used other than to define the impostor
  76972. * of the child mesh.
  76973. * @hidden
  76974. */
  76975. _init(): void;
  76976. private _getPhysicsParent;
  76977. /**
  76978. * Should a new body be generated.
  76979. * @returns boolean specifying if body initialization is required
  76980. */
  76981. isBodyInitRequired(): boolean;
  76982. /**
  76983. * Sets the updated scaling
  76984. * @param updated Specifies if the scaling is updated
  76985. */
  76986. setScalingUpdated(): void;
  76987. /**
  76988. * Force a regeneration of this or the parent's impostor's body.
  76989. * Use under cautious - This will remove all joints already implemented.
  76990. */
  76991. forceUpdate(): void;
  76992. /**
  76993. * Gets the body that holds this impostor. Either its own, or its parent.
  76994. */
  76995. /**
  76996. * Set the physics body. Used mainly by the physics engine/plugin
  76997. */
  76998. physicsBody: any;
  76999. /**
  77000. * Get the parent of the physics imposter
  77001. * @returns Physics imposter or null
  77002. */
  77003. /**
  77004. * Sets the parent of the physics imposter
  77005. */
  77006. parent: Nullable<PhysicsImpostor>;
  77007. /**
  77008. * Resets the update flags
  77009. */
  77010. resetUpdateFlags(): void;
  77011. /**
  77012. * Gets the object extend size
  77013. * @returns the object extend size
  77014. */
  77015. getObjectExtendSize(): Vector3;
  77016. /**
  77017. * Gets the object center
  77018. * @returns The object center
  77019. */
  77020. getObjectCenter(): Vector3;
  77021. /**
  77022. * Get a specific parametes from the options parameter
  77023. * @param paramName The object parameter name
  77024. * @returns The object parameter
  77025. */
  77026. getParam(paramName: string): any;
  77027. /**
  77028. * Sets a specific parameter in the options given to the physics plugin
  77029. * @param paramName The parameter name
  77030. * @param value The value of the parameter
  77031. */
  77032. setParam(paramName: string, value: number): void;
  77033. /**
  77034. * Specifically change the body's mass option. Won't recreate the physics body object
  77035. * @param mass The mass of the physics imposter
  77036. */
  77037. setMass(mass: number): void;
  77038. /**
  77039. * Gets the linear velocity
  77040. * @returns linear velocity or null
  77041. */
  77042. getLinearVelocity(): Nullable<Vector3>;
  77043. /**
  77044. * Sets the linear velocity
  77045. * @param velocity linear velocity or null
  77046. */
  77047. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77048. /**
  77049. * Gets the angular velocity
  77050. * @returns angular velocity or null
  77051. */
  77052. getAngularVelocity(): Nullable<Vector3>;
  77053. /**
  77054. * Sets the angular velocity
  77055. * @param velocity The velocity or null
  77056. */
  77057. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77058. /**
  77059. * Execute a function with the physics plugin native code
  77060. * Provide a function the will have two variables - the world object and the physics body object
  77061. * @param func The function to execute with the physics plugin native code
  77062. */
  77063. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77064. /**
  77065. * Register a function that will be executed before the physics world is stepping forward
  77066. * @param func The function to execute before the physics world is stepped forward
  77067. */
  77068. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77069. /**
  77070. * Unregister a function that will be executed before the physics world is stepping forward
  77071. * @param func The function to execute before the physics world is stepped forward
  77072. */
  77073. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77074. /**
  77075. * Register a function that will be executed after the physics step
  77076. * @param func The function to execute after physics step
  77077. */
  77078. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77079. /**
  77080. * Unregisters a function that will be executed after the physics step
  77081. * @param func The function to execute after physics step
  77082. */
  77083. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77084. /**
  77085. * register a function that will be executed when this impostor collides against a different body
  77086. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77087. * @param func Callback that is executed on collision
  77088. */
  77089. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77090. /**
  77091. * Unregisters the physics imposter on contact
  77092. * @param collideAgainst The physics object to collide against
  77093. * @param func Callback to execute on collision
  77094. */
  77095. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77096. private _tmpQuat;
  77097. private _tmpQuat2;
  77098. /**
  77099. * Get the parent rotation
  77100. * @returns The parent rotation
  77101. */
  77102. getParentsRotation(): Quaternion;
  77103. /**
  77104. * this function is executed by the physics engine.
  77105. */
  77106. beforeStep: () => void;
  77107. /**
  77108. * this function is executed by the physics engine
  77109. */
  77110. afterStep: () => void;
  77111. /**
  77112. * Legacy collision detection event support
  77113. */
  77114. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77115. /**
  77116. * event and body object due to cannon's event-based architecture.
  77117. */
  77118. onCollide: (e: {
  77119. body: any;
  77120. }) => void;
  77121. /**
  77122. * Apply a force
  77123. * @param force The force to apply
  77124. * @param contactPoint The contact point for the force
  77125. * @returns The physics imposter
  77126. */
  77127. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77128. /**
  77129. * Apply an impulse
  77130. * @param force The impulse force
  77131. * @param contactPoint The contact point for the impulse force
  77132. * @returns The physics imposter
  77133. */
  77134. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77135. /**
  77136. * A help function to create a joint
  77137. * @param otherImpostor A physics imposter used to create a joint
  77138. * @param jointType The type of joint
  77139. * @param jointData The data for the joint
  77140. * @returns The physics imposter
  77141. */
  77142. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77143. /**
  77144. * Add a joint to this impostor with a different impostor
  77145. * @param otherImpostor A physics imposter used to add a joint
  77146. * @param joint The joint to add
  77147. * @returns The physics imposter
  77148. */
  77149. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77150. /**
  77151. * Will keep this body still, in a sleep mode.
  77152. * @returns the physics imposter
  77153. */
  77154. sleep(): PhysicsImpostor;
  77155. /**
  77156. * Wake the body up.
  77157. * @returns The physics imposter
  77158. */
  77159. wakeUp(): PhysicsImpostor;
  77160. /**
  77161. * Clones the physics imposter
  77162. * @param newObject The physics imposter clones to this physics-enabled object
  77163. * @returns A nullable physics imposter
  77164. */
  77165. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77166. /**
  77167. * Disposes the physics imposter
  77168. */
  77169. dispose(): void;
  77170. /**
  77171. * Sets the delta position
  77172. * @param position The delta position amount
  77173. */
  77174. setDeltaPosition(position: Vector3): void;
  77175. /**
  77176. * Sets the delta rotation
  77177. * @param rotation The delta rotation amount
  77178. */
  77179. setDeltaRotation(rotation: Quaternion): void;
  77180. /**
  77181. * Gets the box size of the physics imposter and stores the result in the input parameter
  77182. * @param result Stores the box size
  77183. * @returns The physics imposter
  77184. */
  77185. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77186. /**
  77187. * Gets the radius of the physics imposter
  77188. * @returns Radius of the physics imposter
  77189. */
  77190. getRadius(): number;
  77191. /**
  77192. * Sync a bone with this impostor
  77193. * @param bone The bone to sync to the impostor.
  77194. * @param boneMesh The mesh that the bone is influencing.
  77195. * @param jointPivot The pivot of the joint / bone in local space.
  77196. * @param distToJoint Optional distance from the impostor to the joint.
  77197. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77198. */
  77199. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77200. /**
  77201. * Sync impostor to a bone
  77202. * @param bone The bone that the impostor will be synced to.
  77203. * @param boneMesh The mesh that the bone is influencing.
  77204. * @param jointPivot The pivot of the joint / bone in local space.
  77205. * @param distToJoint Optional distance from the impostor to the joint.
  77206. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77207. * @param boneAxis Optional vector3 axis the bone is aligned with
  77208. */
  77209. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77210. /**
  77211. * No-Imposter type
  77212. */
  77213. static NoImpostor: number;
  77214. /**
  77215. * Sphere-Imposter type
  77216. */
  77217. static SphereImpostor: number;
  77218. /**
  77219. * Box-Imposter type
  77220. */
  77221. static BoxImpostor: number;
  77222. /**
  77223. * Plane-Imposter type
  77224. */
  77225. static PlaneImpostor: number;
  77226. /**
  77227. * Mesh-imposter type
  77228. */
  77229. static MeshImpostor: number;
  77230. /**
  77231. * Cylinder-Imposter type
  77232. */
  77233. static CylinderImpostor: number;
  77234. /**
  77235. * Particle-Imposter type
  77236. */
  77237. static ParticleImpostor: number;
  77238. /**
  77239. * Heightmap-Imposter type
  77240. */
  77241. static HeightmapImpostor: number;
  77242. }
  77243. }
  77244. declare module BABYLON {
  77245. /**
  77246. * Class used to represent a specific level of detail of a mesh
  77247. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77248. */
  77249. export class MeshLODLevel {
  77250. /** Defines the distance where this level should star being displayed */
  77251. distance: number;
  77252. /** Defines the mesh to use to render this level */
  77253. mesh: Nullable<Mesh>;
  77254. /**
  77255. * Creates a new LOD level
  77256. * @param distance defines the distance where this level should star being displayed
  77257. * @param mesh defines the mesh to use to render this level
  77258. */
  77259. constructor(
  77260. /** Defines the distance where this level should star being displayed */
  77261. distance: number,
  77262. /** Defines the mesh to use to render this level */
  77263. mesh: Nullable<Mesh>);
  77264. }
  77265. /**
  77266. * @hidden
  77267. **/
  77268. export class _CreationDataStorage {
  77269. closePath?: boolean;
  77270. closeArray?: boolean;
  77271. idx: number[];
  77272. dashSize: number;
  77273. gapSize: number;
  77274. path3D: Path3D;
  77275. pathArray: Vector3[][];
  77276. arc: number;
  77277. radius: number;
  77278. cap: number;
  77279. tessellation: number;
  77280. }
  77281. /**
  77282. * @hidden
  77283. **/
  77284. class _InstanceDataStorage {
  77285. visibleInstances: any;
  77286. renderIdForInstances: number[];
  77287. batchCache: _InstancesBatch;
  77288. instancesBufferSize: number;
  77289. instancesBuffer: Nullable<Buffer>;
  77290. instancesData: Float32Array;
  77291. overridenInstanceCount: number;
  77292. }
  77293. /**
  77294. * @hidden
  77295. **/
  77296. export class _InstancesBatch {
  77297. mustReturn: boolean;
  77298. visibleInstances: Nullable<InstancedMesh[]>[];
  77299. renderSelf: boolean[];
  77300. }
  77301. /**
  77302. * Class used to represent renderable models
  77303. */
  77304. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77305. /**
  77306. * Mesh side orientation : usually the external or front surface
  77307. */
  77308. static readonly FRONTSIDE: number;
  77309. /**
  77310. * Mesh side orientation : usually the internal or back surface
  77311. */
  77312. static readonly BACKSIDE: number;
  77313. /**
  77314. * Mesh side orientation : both internal and external or front and back surfaces
  77315. */
  77316. static readonly DOUBLESIDE: number;
  77317. /**
  77318. * Mesh side orientation : by default, `FRONTSIDE`
  77319. */
  77320. static readonly DEFAULTSIDE: number;
  77321. /**
  77322. * Mesh cap setting : no cap
  77323. */
  77324. static readonly NO_CAP: number;
  77325. /**
  77326. * Mesh cap setting : one cap at the beginning of the mesh
  77327. */
  77328. static readonly CAP_START: number;
  77329. /**
  77330. * Mesh cap setting : one cap at the end of the mesh
  77331. */
  77332. static readonly CAP_END: number;
  77333. /**
  77334. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77335. */
  77336. static readonly CAP_ALL: number;
  77337. /**
  77338. * Gets the default side orientation.
  77339. * @param orientation the orientation to value to attempt to get
  77340. * @returns the default orientation
  77341. * @hidden
  77342. */
  77343. static _GetDefaultSideOrientation(orientation?: number): number;
  77344. private _onBeforeRenderObservable;
  77345. private _onBeforeBindObservable;
  77346. private _onAfterRenderObservable;
  77347. private _onBeforeDrawObservable;
  77348. /**
  77349. * An event triggered before rendering the mesh
  77350. */
  77351. readonly onBeforeRenderObservable: Observable<Mesh>;
  77352. /**
  77353. * An event triggered before binding the mesh
  77354. */
  77355. readonly onBeforeBindObservable: Observable<Mesh>;
  77356. /**
  77357. * An event triggered after rendering the mesh
  77358. */
  77359. readonly onAfterRenderObservable: Observable<Mesh>;
  77360. /**
  77361. * An event triggered before drawing the mesh
  77362. */
  77363. readonly onBeforeDrawObservable: Observable<Mesh>;
  77364. private _onBeforeDrawObserver;
  77365. /**
  77366. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77367. */
  77368. onBeforeDraw: () => void;
  77369. /**
  77370. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77371. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77372. */
  77373. delayLoadState: number;
  77374. /**
  77375. * Gets the list of instances created from this mesh
  77376. * it is not supposed to be modified manually.
  77377. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77378. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77379. */
  77380. instances: InstancedMesh[];
  77381. /**
  77382. * Gets the file containing delay loading data for this mesh
  77383. */
  77384. delayLoadingFile: string;
  77385. /** @hidden */
  77386. _binaryInfo: any;
  77387. private _LODLevels;
  77388. /**
  77389. * User defined function used to change how LOD level selection is done
  77390. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77391. */
  77392. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77393. private _morphTargetManager;
  77394. /**
  77395. * Gets or sets the morph target manager
  77396. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77397. */
  77398. morphTargetManager: Nullable<MorphTargetManager>;
  77399. /** @hidden */
  77400. _creationDataStorage: Nullable<_CreationDataStorage>;
  77401. /** @hidden */
  77402. _geometry: Nullable<Geometry>;
  77403. /** @hidden */
  77404. _delayInfo: Array<string>;
  77405. /** @hidden */
  77406. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77407. /** @hidden */
  77408. _instanceDataStorage: _InstanceDataStorage;
  77409. private _effectiveMaterial;
  77410. /** @hidden */
  77411. _shouldGenerateFlatShading: boolean;
  77412. private _preActivateId;
  77413. /** @hidden */
  77414. _originalBuilderSideOrientation: number;
  77415. /**
  77416. * Use this property to change the original side orientation defined at construction time
  77417. */
  77418. overrideMaterialSideOrientation: Nullable<number>;
  77419. private _areNormalsFrozen;
  77420. private _sourcePositions;
  77421. private _sourceNormals;
  77422. private _source;
  77423. private meshMap;
  77424. /**
  77425. * Gets the source mesh (the one used to clone this one from)
  77426. */
  77427. readonly source: Nullable<Mesh>;
  77428. /**
  77429. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77430. */
  77431. isUnIndexed: boolean;
  77432. /**
  77433. * @constructor
  77434. * @param name The value used by scene.getMeshByName() to do a lookup.
  77435. * @param scene The scene to add this mesh to.
  77436. * @param parent The parent of this mesh, if it has one
  77437. * @param source An optional Mesh from which geometry is shared, cloned.
  77438. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77439. * When false, achieved by calling a clone(), also passing False.
  77440. * This will make creation of children, recursive.
  77441. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77442. */
  77443. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77444. /**
  77445. * Gets the class name
  77446. * @returns the string "Mesh".
  77447. */
  77448. getClassName(): string;
  77449. /** @hidden */
  77450. readonly _isMesh: boolean;
  77451. /**
  77452. * Returns a description of this mesh
  77453. * @param fullDetails define if full details about this mesh must be used
  77454. * @returns a descriptive string representing this mesh
  77455. */
  77456. toString(fullDetails?: boolean): string;
  77457. /** @hidden */
  77458. _unBindEffect(): void;
  77459. /**
  77460. * Gets a boolean indicating if this mesh has LOD
  77461. */
  77462. readonly hasLODLevels: boolean;
  77463. /**
  77464. * Gets the list of MeshLODLevel associated with the current mesh
  77465. * @returns an array of MeshLODLevel
  77466. */
  77467. getLODLevels(): MeshLODLevel[];
  77468. private _sortLODLevels;
  77469. /**
  77470. * Add a mesh as LOD level triggered at the given distance.
  77471. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77472. * @param distance The distance from the center of the object to show this level
  77473. * @param mesh The mesh to be added as LOD level (can be null)
  77474. * @return This mesh (for chaining)
  77475. */
  77476. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77477. /**
  77478. * Returns the LOD level mesh at the passed distance or null if not found.
  77479. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77480. * @param distance The distance from the center of the object to show this level
  77481. * @returns a Mesh or `null`
  77482. */
  77483. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77484. /**
  77485. * Remove a mesh from the LOD array
  77486. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77487. * @param mesh defines the mesh to be removed
  77488. * @return This mesh (for chaining)
  77489. */
  77490. removeLODLevel(mesh: Mesh): Mesh;
  77491. /**
  77492. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77493. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77494. * @param camera defines the camera to use to compute distance
  77495. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77496. * @return This mesh (for chaining)
  77497. */
  77498. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77499. /**
  77500. * Gets the mesh internal Geometry object
  77501. */
  77502. readonly geometry: Nullable<Geometry>;
  77503. /**
  77504. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77505. * @returns the total number of vertices
  77506. */
  77507. getTotalVertices(): number;
  77508. /**
  77509. * Returns the content of an associated vertex buffer
  77510. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77511. * - VertexBuffer.PositionKind
  77512. * - VertexBuffer.UVKind
  77513. * - VertexBuffer.UV2Kind
  77514. * - VertexBuffer.UV3Kind
  77515. * - VertexBuffer.UV4Kind
  77516. * - VertexBuffer.UV5Kind
  77517. * - VertexBuffer.UV6Kind
  77518. * - VertexBuffer.ColorKind
  77519. * - VertexBuffer.MatricesIndicesKind
  77520. * - VertexBuffer.MatricesIndicesExtraKind
  77521. * - VertexBuffer.MatricesWeightsKind
  77522. * - VertexBuffer.MatricesWeightsExtraKind
  77523. * @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
  77524. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77525. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77526. */
  77527. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77528. /**
  77529. * Returns the mesh VertexBuffer object from the requested `kind`
  77530. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77531. * - VertexBuffer.PositionKind
  77532. * - VertexBuffer.UVKind
  77533. * - VertexBuffer.UV2Kind
  77534. * - VertexBuffer.UV3Kind
  77535. * - VertexBuffer.UV4Kind
  77536. * - VertexBuffer.UV5Kind
  77537. * - VertexBuffer.UV6Kind
  77538. * - VertexBuffer.ColorKind
  77539. * - VertexBuffer.MatricesIndicesKind
  77540. * - VertexBuffer.MatricesIndicesExtraKind
  77541. * - VertexBuffer.MatricesWeightsKind
  77542. * - VertexBuffer.MatricesWeightsExtraKind
  77543. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77544. */
  77545. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77546. /**
  77547. * Tests if a specific vertex buffer is associated with this mesh
  77548. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77549. * - VertexBuffer.PositionKind
  77550. * - VertexBuffer.UVKind
  77551. * - VertexBuffer.UV2Kind
  77552. * - VertexBuffer.UV3Kind
  77553. * - VertexBuffer.UV4Kind
  77554. * - VertexBuffer.UV5Kind
  77555. * - VertexBuffer.UV6Kind
  77556. * - VertexBuffer.ColorKind
  77557. * - VertexBuffer.MatricesIndicesKind
  77558. * - VertexBuffer.MatricesIndicesExtraKind
  77559. * - VertexBuffer.MatricesWeightsKind
  77560. * - VertexBuffer.MatricesWeightsExtraKind
  77561. * @returns a boolean
  77562. */
  77563. isVerticesDataPresent(kind: string): boolean;
  77564. /**
  77565. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77566. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77567. * - VertexBuffer.PositionKind
  77568. * - VertexBuffer.UVKind
  77569. * - VertexBuffer.UV2Kind
  77570. * - VertexBuffer.UV3Kind
  77571. * - VertexBuffer.UV4Kind
  77572. * - VertexBuffer.UV5Kind
  77573. * - VertexBuffer.UV6Kind
  77574. * - VertexBuffer.ColorKind
  77575. * - VertexBuffer.MatricesIndicesKind
  77576. * - VertexBuffer.MatricesIndicesExtraKind
  77577. * - VertexBuffer.MatricesWeightsKind
  77578. * - VertexBuffer.MatricesWeightsExtraKind
  77579. * @returns a boolean
  77580. */
  77581. isVertexBufferUpdatable(kind: string): boolean;
  77582. /**
  77583. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77584. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77585. * - VertexBuffer.PositionKind
  77586. * - VertexBuffer.UVKind
  77587. * - VertexBuffer.UV2Kind
  77588. * - VertexBuffer.UV3Kind
  77589. * - VertexBuffer.UV4Kind
  77590. * - VertexBuffer.UV5Kind
  77591. * - VertexBuffer.UV6Kind
  77592. * - VertexBuffer.ColorKind
  77593. * - VertexBuffer.MatricesIndicesKind
  77594. * - VertexBuffer.MatricesIndicesExtraKind
  77595. * - VertexBuffer.MatricesWeightsKind
  77596. * - VertexBuffer.MatricesWeightsExtraKind
  77597. * @returns an array of strings
  77598. */
  77599. getVerticesDataKinds(): string[];
  77600. /**
  77601. * Returns a positive integer : the total number of indices in this mesh geometry.
  77602. * @returns the numner of indices or zero if the mesh has no geometry.
  77603. */
  77604. getTotalIndices(): number;
  77605. /**
  77606. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77607. * @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.
  77608. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77609. * @returns the indices array or an empty array if the mesh has no geometry
  77610. */
  77611. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77612. readonly isBlocked: boolean;
  77613. /**
  77614. * Determine if the current mesh is ready to be rendered
  77615. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77616. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77617. * @returns true if all associated assets are ready (material, textures, shaders)
  77618. */
  77619. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77620. /**
  77621. * 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.
  77622. */
  77623. readonly areNormalsFrozen: boolean;
  77624. /**
  77625. * 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.
  77626. * @returns the current mesh
  77627. */
  77628. freezeNormals(): Mesh;
  77629. /**
  77630. * 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
  77631. * @returns the current mesh
  77632. */
  77633. unfreezeNormals(): Mesh;
  77634. /**
  77635. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77636. */
  77637. overridenInstanceCount: number;
  77638. /** @hidden */
  77639. _preActivate(): Mesh;
  77640. /** @hidden */
  77641. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77642. /** @hidden */
  77643. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77644. /**
  77645. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77646. * This means the mesh underlying bounding box and sphere are recomputed.
  77647. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77648. * @returns the current mesh
  77649. */
  77650. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77651. /** @hidden */
  77652. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77653. /**
  77654. * This function will subdivide the mesh into multiple submeshes
  77655. * @param count defines the expected number of submeshes
  77656. */
  77657. subdivide(count: number): void;
  77658. /**
  77659. * Copy a FloatArray into a specific associated vertex buffer
  77660. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77661. * - VertexBuffer.PositionKind
  77662. * - VertexBuffer.UVKind
  77663. * - VertexBuffer.UV2Kind
  77664. * - VertexBuffer.UV3Kind
  77665. * - VertexBuffer.UV4Kind
  77666. * - VertexBuffer.UV5Kind
  77667. * - VertexBuffer.UV6Kind
  77668. * - VertexBuffer.ColorKind
  77669. * - VertexBuffer.MatricesIndicesKind
  77670. * - VertexBuffer.MatricesIndicesExtraKind
  77671. * - VertexBuffer.MatricesWeightsKind
  77672. * - VertexBuffer.MatricesWeightsExtraKind
  77673. * @param data defines the data source
  77674. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77675. * @param stride defines the data stride size (can be null)
  77676. * @returns the current mesh
  77677. */
  77678. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77679. /**
  77680. * Flags an associated vertex buffer as updatable
  77681. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77682. * - VertexBuffer.PositionKind
  77683. * - VertexBuffer.UVKind
  77684. * - VertexBuffer.UV2Kind
  77685. * - VertexBuffer.UV3Kind
  77686. * - VertexBuffer.UV4Kind
  77687. * - VertexBuffer.UV5Kind
  77688. * - VertexBuffer.UV6Kind
  77689. * - VertexBuffer.ColorKind
  77690. * - VertexBuffer.MatricesIndicesKind
  77691. * - VertexBuffer.MatricesIndicesExtraKind
  77692. * - VertexBuffer.MatricesWeightsKind
  77693. * - VertexBuffer.MatricesWeightsExtraKind
  77694. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77695. */
  77696. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77697. /**
  77698. * Sets the mesh global Vertex Buffer
  77699. * @param buffer defines the buffer to use
  77700. * @returns the current mesh
  77701. */
  77702. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77703. /**
  77704. * Update a specific associated vertex buffer
  77705. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77706. * - VertexBuffer.PositionKind
  77707. * - VertexBuffer.UVKind
  77708. * - VertexBuffer.UV2Kind
  77709. * - VertexBuffer.UV3Kind
  77710. * - VertexBuffer.UV4Kind
  77711. * - VertexBuffer.UV5Kind
  77712. * - VertexBuffer.UV6Kind
  77713. * - VertexBuffer.ColorKind
  77714. * - VertexBuffer.MatricesIndicesKind
  77715. * - VertexBuffer.MatricesIndicesExtraKind
  77716. * - VertexBuffer.MatricesWeightsKind
  77717. * - VertexBuffer.MatricesWeightsExtraKind
  77718. * @param data defines the data source
  77719. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77720. * @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)
  77721. * @returns the current mesh
  77722. */
  77723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77724. /**
  77725. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77726. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77727. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77728. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77729. * @returns the current mesh
  77730. */
  77731. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77732. /**
  77733. * Creates a un-shared specific occurence of the geometry for the mesh.
  77734. * @returns the current mesh
  77735. */
  77736. makeGeometryUnique(): Mesh;
  77737. /**
  77738. * Set the index buffer of this mesh
  77739. * @param indices defines the source data
  77740. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77741. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77742. * @returns the current mesh
  77743. */
  77744. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77745. /**
  77746. * Update the current index buffer
  77747. * @param indices defines the source data
  77748. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77749. * @returns the current mesh
  77750. */
  77751. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77752. /**
  77753. * Invert the geometry to move from a right handed system to a left handed one.
  77754. * @returns the current mesh
  77755. */
  77756. toLeftHanded(): Mesh;
  77757. /** @hidden */
  77758. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77759. /** @hidden */
  77760. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77761. /**
  77762. * Registers for this mesh a javascript function called just before the rendering process
  77763. * @param func defines the function to call before rendering this mesh
  77764. * @returns the current mesh
  77765. */
  77766. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77767. /**
  77768. * Disposes a previously registered javascript function called before the rendering
  77769. * @param func defines the function to remove
  77770. * @returns the current mesh
  77771. */
  77772. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77773. /**
  77774. * Registers for this mesh a javascript function called just after the rendering is complete
  77775. * @param func defines the function to call after rendering this mesh
  77776. * @returns the current mesh
  77777. */
  77778. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77779. /**
  77780. * Disposes a previously registered javascript function called after the rendering.
  77781. * @param func defines the function to remove
  77782. * @returns the current mesh
  77783. */
  77784. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77785. /** @hidden */
  77786. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77787. /** @hidden */
  77788. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77789. /** @hidden */
  77790. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77791. /**
  77792. * 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
  77793. * @param subMesh defines the subMesh to render
  77794. * @param enableAlphaMode defines if alpha mode can be changed
  77795. * @returns the current mesh
  77796. */
  77797. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77798. private _onBeforeDraw;
  77799. /**
  77800. * Renormalize the mesh and patch it up if there are no weights
  77801. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77802. * However in the case of zero weights then we set just a single influence to 1.
  77803. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77804. */
  77805. cleanMatrixWeights(): void;
  77806. private normalizeSkinFourWeights;
  77807. private normalizeSkinWeightsAndExtra;
  77808. /**
  77809. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77810. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77811. * the user know there was an issue with importing the mesh
  77812. * @returns a validation object with skinned, valid and report string
  77813. */
  77814. validateSkinning(): {
  77815. skinned: boolean;
  77816. valid: boolean;
  77817. report: string;
  77818. };
  77819. /** @hidden */
  77820. _checkDelayState(): Mesh;
  77821. private _queueLoad;
  77822. /**
  77823. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77824. * A mesh is in the frustum if its bounding box intersects the frustum
  77825. * @param frustumPlanes defines the frustum to test
  77826. * @returns true if the mesh is in the frustum planes
  77827. */
  77828. isInFrustum(frustumPlanes: Plane[]): boolean;
  77829. /**
  77830. * Sets the mesh material by the material or multiMaterial `id` property
  77831. * @param id is a string identifying the material or the multiMaterial
  77832. * @returns the current mesh
  77833. */
  77834. setMaterialByID(id: string): Mesh;
  77835. /**
  77836. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77837. * @returns an array of IAnimatable
  77838. */
  77839. getAnimatables(): IAnimatable[];
  77840. /**
  77841. * Modifies the mesh geometry according to the passed transformation matrix.
  77842. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77843. * The mesh normals are modified using the same transformation.
  77844. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77845. * @param transform defines the transform matrix to use
  77846. * @see http://doc.babylonjs.com/resources/baking_transformations
  77847. * @returns the current mesh
  77848. */
  77849. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77850. /**
  77851. * Modifies the mesh geometry according to its own current World Matrix.
  77852. * The mesh World Matrix is then reset.
  77853. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77854. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77855. * @see http://doc.babylonjs.com/resources/baking_transformations
  77856. * @returns the current mesh
  77857. */
  77858. bakeCurrentTransformIntoVertices(): Mesh;
  77859. /** @hidden */
  77860. readonly _positions: Nullable<Vector3[]>;
  77861. /** @hidden */
  77862. _resetPointsArrayCache(): Mesh;
  77863. /** @hidden */
  77864. _generatePointsArray(): boolean;
  77865. /**
  77866. * Returns a new Mesh object generated from the current mesh properties.
  77867. * This method must not get confused with createInstance()
  77868. * @param name is a string, the name given to the new mesh
  77869. * @param newParent can be any Node object (default `null`)
  77870. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77871. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77872. * @returns a new mesh
  77873. */
  77874. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77875. /**
  77876. * Releases resources associated with this mesh.
  77877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77879. */
  77880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77881. /**
  77882. * Modifies the mesh geometry according to a displacement map.
  77883. * 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.
  77884. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77885. * @param url is a string, the URL from the image file is to be downloaded.
  77886. * @param minHeight is the lower limit of the displacement.
  77887. * @param maxHeight is the upper limit of the displacement.
  77888. * @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.
  77889. * @param uvOffset is an optional vector2 used to offset UV.
  77890. * @param uvScale is an optional vector2 used to scale UV.
  77891. * @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.
  77892. * @returns the Mesh.
  77893. */
  77894. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77895. /**
  77896. * Modifies the mesh geometry according to a displacementMap buffer.
  77897. * 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.
  77898. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77899. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77900. * @param heightMapWidth is the width of the buffer image.
  77901. * @param heightMapHeight is the height of the buffer image.
  77902. * @param minHeight is the lower limit of the displacement.
  77903. * @param maxHeight is the upper limit of the displacement.
  77904. * @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.
  77905. * @param uvOffset is an optional vector2 used to offset UV.
  77906. * @param uvScale is an optional vector2 used to scale UV.
  77907. * @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.
  77908. * @returns the Mesh.
  77909. */
  77910. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77911. /**
  77912. * Modify the mesh to get a flat shading rendering.
  77913. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77914. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77915. * @returns current mesh
  77916. */
  77917. convertToFlatShadedMesh(): Mesh;
  77918. /**
  77919. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77920. * In other words, more vertices, no more indices and a single bigger VBO.
  77921. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77922. * @returns current mesh
  77923. */
  77924. convertToUnIndexedMesh(): Mesh;
  77925. /**
  77926. * Inverses facet orientations.
  77927. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77928. * @param flipNormals will also inverts the normals
  77929. * @returns current mesh
  77930. */
  77931. flipFaces(flipNormals?: boolean): Mesh;
  77932. /** @hidden */
  77933. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77934. /** @hidden */
  77935. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77936. /**
  77937. * Creates a new InstancedMesh object from the mesh model.
  77938. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77939. * @param name defines the name of the new instance
  77940. * @returns a new InstancedMesh
  77941. */
  77942. createInstance(name: string): InstancedMesh;
  77943. /**
  77944. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77945. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77946. * @returns the current mesh
  77947. */
  77948. synchronizeInstances(): Mesh;
  77949. /**
  77950. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77951. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77952. * This should be used together with the simplification to avoid disappearing triangles.
  77953. * @param successCallback an optional success callback to be called after the optimization finished.
  77954. * @returns the current mesh
  77955. */
  77956. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77957. /**
  77958. * Serialize current mesh
  77959. * @param serializationObject defines the object which will receive the serialization data
  77960. */
  77961. serialize(serializationObject: any): void;
  77962. /** @hidden */
  77963. _syncGeometryWithMorphTargetManager(): void;
  77964. /** @hidden */
  77965. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77966. /**
  77967. * Returns a new Mesh object parsed from the source provided.
  77968. * @param parsedMesh is the source
  77969. * @param scene defines the hosting scene
  77970. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77971. * @returns a new Mesh
  77972. */
  77973. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77974. /**
  77975. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77976. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77977. * @param name defines the name of the mesh to create
  77978. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77979. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77980. * @param closePath creates a seam between the first and the last points of each path of the path array
  77981. * @param offset is taken in account only if the `pathArray` is containing a single path
  77982. * @param scene defines the hosting scene
  77983. * @param updatable defines if the mesh must be flagged as updatable
  77984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77985. * @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)
  77986. * @returns a new Mesh
  77987. */
  77988. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77989. /**
  77990. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77991. * @param name defines the name of the mesh to create
  77992. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77993. * @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
  77994. * @param scene defines the hosting scene
  77995. * @param updatable defines if the mesh must be flagged as updatable
  77996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77997. * @returns a new Mesh
  77998. */
  77999. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78000. /**
  78001. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78002. * @param name defines the name of the mesh to create
  78003. * @param size sets the size (float) of each box side (default 1)
  78004. * @param scene defines the hosting scene
  78005. * @param updatable defines if the mesh must be flagged as updatable
  78006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78007. * @returns a new Mesh
  78008. */
  78009. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78010. /**
  78011. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78012. * @param name defines the name of the mesh to create
  78013. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78014. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78015. * @param scene defines the hosting scene
  78016. * @param updatable defines if the mesh must be flagged as updatable
  78017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78018. * @returns a new Mesh
  78019. */
  78020. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78021. /**
  78022. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78023. * @param name defines the name of the mesh to create
  78024. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78025. * @param diameterTop set the top cap diameter (floats, default 1)
  78026. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78027. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78028. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78029. * @param scene defines the hosting scene
  78030. * @param updatable defines if the mesh must be flagged as updatable
  78031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78032. * @returns a new Mesh
  78033. */
  78034. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78035. /**
  78036. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78037. * @param name defines the name of the mesh to create
  78038. * @param diameter sets the diameter size (float) of the torus (default 1)
  78039. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78040. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78041. * @param scene defines the hosting scene
  78042. * @param updatable defines if the mesh must be flagged as updatable
  78043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78044. * @returns a new Mesh
  78045. */
  78046. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78047. /**
  78048. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78049. * @param name defines the name of the mesh to create
  78050. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78051. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78052. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78053. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78054. * @param p the number of windings on X axis (positive integers, default 2)
  78055. * @param q the number of windings on Y axis (positive integers, default 3)
  78056. * @param scene defines the hosting scene
  78057. * @param updatable defines if the mesh must be flagged as updatable
  78058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78059. * @returns a new Mesh
  78060. */
  78061. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78062. /**
  78063. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78064. * @param name defines the name of the mesh to create
  78065. * @param points is an array successive Vector3
  78066. * @param scene defines the hosting scene
  78067. * @param updatable defines if the mesh must be flagged as updatable
  78068. * @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).
  78069. * @returns a new Mesh
  78070. */
  78071. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78072. /**
  78073. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78074. * @param name defines the name of the mesh to create
  78075. * @param points is an array successive Vector3
  78076. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78077. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78078. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78079. * @param scene defines the hosting scene
  78080. * @param updatable defines if the mesh must be flagged as updatable
  78081. * @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)
  78082. * @returns a new Mesh
  78083. */
  78084. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78085. /**
  78086. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78087. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78088. * 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.
  78089. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78090. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78091. * Remember you can only change the shape positions, not their number when updating a polygon.
  78092. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78093. * @param name defines the name of the mesh to create
  78094. * @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
  78095. * @param scene defines the hosting scene
  78096. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78097. * @param updatable defines if the mesh must be flagged as updatable
  78098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78099. * @param earcutInjection can be used to inject your own earcut reference
  78100. * @returns a new Mesh
  78101. */
  78102. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78103. /**
  78104. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78105. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78106. * @param name defines the name of the mesh to create
  78107. * @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
  78108. * @param depth defines the height of extrusion
  78109. * @param scene defines the hosting scene
  78110. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78111. * @param updatable defines if the mesh must be flagged as updatable
  78112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78113. * @param earcutInjection can be used to inject your own earcut reference
  78114. * @returns a new Mesh
  78115. */
  78116. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78117. /**
  78118. * Creates an extruded shape mesh.
  78119. * 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
  78120. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78122. * @param name defines the name of the mesh to create
  78123. * @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
  78124. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78125. * @param scale is the value to scale the shape
  78126. * @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
  78127. * @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
  78128. * @param scene defines the hosting scene
  78129. * @param updatable defines if the mesh must be flagged as updatable
  78130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78131. * @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)
  78132. * @returns a new Mesh
  78133. */
  78134. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78135. /**
  78136. * Creates an custom extruded shape mesh.
  78137. * The custom extrusion is a parametric shape.
  78138. * It has no predefined shape. Its final shape will depend on the input parameters.
  78139. * Please consider using the same method from the MeshBuilder class instead
  78140. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78141. * @param name defines the name of the mesh to create
  78142. * @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
  78143. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78144. * @param scaleFunction is a custom Javascript function called on each path point
  78145. * @param rotationFunction is a custom Javascript function called on each path point
  78146. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78147. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78148. * @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
  78149. * @param scene defines the hosting scene
  78150. * @param updatable defines if the mesh must be flagged as updatable
  78151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78152. * @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)
  78153. * @returns a new Mesh
  78154. */
  78155. 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;
  78156. /**
  78157. * Creates lathe mesh.
  78158. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78159. * Please consider using the same method from the MeshBuilder class instead
  78160. * @param name defines the name of the mesh to create
  78161. * @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
  78162. * @param radius is the radius value of the lathe
  78163. * @param tessellation is the side number of the lathe.
  78164. * @param scene defines the hosting scene
  78165. * @param updatable defines if the mesh must be flagged as updatable
  78166. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78167. * @returns a new Mesh
  78168. */
  78169. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78170. /**
  78171. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78172. * @param name defines the name of the mesh to create
  78173. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78174. * @param scene defines the hosting scene
  78175. * @param updatable defines if the mesh must be flagged as updatable
  78176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78177. * @returns a new Mesh
  78178. */
  78179. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78180. /**
  78181. * Creates a ground mesh.
  78182. * Please consider using the same method from the MeshBuilder class instead
  78183. * @param name defines the name of the mesh to create
  78184. * @param width set the width of the ground
  78185. * @param height set the height of the ground
  78186. * @param subdivisions sets the number of subdivisions per side
  78187. * @param scene defines the hosting scene
  78188. * @param updatable defines if the mesh must be flagged as updatable
  78189. * @returns a new Mesh
  78190. */
  78191. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78192. /**
  78193. * Creates a tiled ground mesh.
  78194. * Please consider using the same method from the MeshBuilder class instead
  78195. * @param name defines the name of the mesh to create
  78196. * @param xmin set the ground minimum X coordinate
  78197. * @param zmin set the ground minimum Y coordinate
  78198. * @param xmax set the ground maximum X coordinate
  78199. * @param zmax set the ground maximum Z coordinate
  78200. * @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
  78201. * @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
  78202. * @param scene defines the hosting scene
  78203. * @param updatable defines if the mesh must be flagged as updatable
  78204. * @returns a new Mesh
  78205. */
  78206. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78207. w: number;
  78208. h: number;
  78209. }, precision: {
  78210. w: number;
  78211. h: number;
  78212. }, scene: Scene, updatable?: boolean): Mesh;
  78213. /**
  78214. * Creates a ground mesh from a height map.
  78215. * Please consider using the same method from the MeshBuilder class instead
  78216. * @see http://doc.babylonjs.com/babylon101/height_map
  78217. * @param name defines the name of the mesh to create
  78218. * @param url sets the URL of the height map image resource
  78219. * @param width set the ground width size
  78220. * @param height set the ground height size
  78221. * @param subdivisions sets the number of subdivision per side
  78222. * @param minHeight is the minimum altitude on the ground
  78223. * @param maxHeight is the maximum altitude on the ground
  78224. * @param scene defines the hosting scene
  78225. * @param updatable defines if the mesh must be flagged as updatable
  78226. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78227. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78228. * @returns a new Mesh
  78229. */
  78230. 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;
  78231. /**
  78232. * Creates a tube mesh.
  78233. * The tube is a parametric shape.
  78234. * It has no predefined shape. Its final shape will depend on the input parameters.
  78235. * Please consider using the same method from the MeshBuilder class instead
  78236. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78237. * @param name defines the name of the mesh to create
  78238. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78239. * @param radius sets the tube radius size
  78240. * @param tessellation is the number of sides on the tubular surface
  78241. * @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
  78242. * @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
  78243. * @param scene defines the hosting scene
  78244. * @param updatable defines if the mesh must be flagged as updatable
  78245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78246. * @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)
  78247. * @returns a new Mesh
  78248. */
  78249. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78250. (i: number, distance: number): number;
  78251. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78252. /**
  78253. * Creates a polyhedron mesh.
  78254. * Please consider using the same method from the MeshBuilder class instead.
  78255. * * 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
  78256. * * The parameter `size` (positive float, default 1) sets the polygon size
  78257. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78258. * * 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`
  78259. * * 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
  78260. * * 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)`)
  78261. * * 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
  78262. * * 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
  78263. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78264. * * If you create a double-sided mesh, you can choose what parts of 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
  78265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78266. * @param name defines the name of the mesh to create
  78267. * @param options defines the options used to create the mesh
  78268. * @param scene defines the hosting scene
  78269. * @returns a new Mesh
  78270. */
  78271. static CreatePolyhedron(name: string, options: {
  78272. type?: number;
  78273. size?: number;
  78274. sizeX?: number;
  78275. sizeY?: number;
  78276. sizeZ?: number;
  78277. custom?: any;
  78278. faceUV?: Vector4[];
  78279. faceColors?: Color4[];
  78280. updatable?: boolean;
  78281. sideOrientation?: number;
  78282. }, scene: Scene): Mesh;
  78283. /**
  78284. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78285. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78286. * * 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`)
  78287. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78288. * * 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
  78289. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78290. * * If you create a double-sided mesh, you can choose what parts of 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
  78291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78292. * @param name defines the name of the mesh
  78293. * @param options defines the options used to create the mesh
  78294. * @param scene defines the hosting scene
  78295. * @returns a new Mesh
  78296. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78297. */
  78298. static CreateIcoSphere(name: string, options: {
  78299. radius?: number;
  78300. flat?: boolean;
  78301. subdivisions?: number;
  78302. sideOrientation?: number;
  78303. updatable?: boolean;
  78304. }, scene: Scene): Mesh;
  78305. /**
  78306. * Creates a decal mesh.
  78307. * Please consider using the same method from the MeshBuilder class instead.
  78308. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78309. * @param name defines the name of the mesh
  78310. * @param sourceMesh defines the mesh receiving the decal
  78311. * @param position sets the position of the decal in world coordinates
  78312. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78313. * @param size sets the decal scaling
  78314. * @param angle sets the angle to rotate the decal
  78315. * @returns a new Mesh
  78316. */
  78317. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78318. /**
  78319. * Prepare internal position array for software CPU skinning
  78320. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78321. */
  78322. setPositionsForCPUSkinning(): Float32Array;
  78323. /**
  78324. * Prepare internal normal array for software CPU skinning
  78325. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78326. */
  78327. setNormalsForCPUSkinning(): Float32Array;
  78328. /**
  78329. * Updates the vertex buffer by applying transformation from the bones
  78330. * @param skeleton defines the skeleton to apply to current mesh
  78331. * @returns the current mesh
  78332. */
  78333. applySkeleton(skeleton: Skeleton): Mesh;
  78334. /**
  78335. * 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
  78336. * @param meshes defines the list of meshes to scan
  78337. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78338. */
  78339. static MinMax(meshes: AbstractMesh[]): {
  78340. min: Vector3;
  78341. max: Vector3;
  78342. };
  78343. /**
  78344. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78345. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78346. * @returns a vector3
  78347. */
  78348. static Center(meshesOrMinMaxVector: {
  78349. min: Vector3;
  78350. max: Vector3;
  78351. } | AbstractMesh[]): Vector3;
  78352. /**
  78353. * Merge the array of meshes into a single mesh for performance reasons.
  78354. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78355. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78356. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78357. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78358. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78359. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78360. * @returns a new mesh
  78361. */
  78362. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78363. /** @hidden */
  78364. addInstance(instance: InstancedMesh): void;
  78365. /** @hidden */
  78366. removeInstance(instance: InstancedMesh): void;
  78367. }
  78368. }
  78369. declare module BABYLON {
  78370. /**
  78371. * Base class for the main features of a material in Babylon.js
  78372. */
  78373. export class Material implements IAnimatable {
  78374. /**
  78375. * Returns the triangle fill mode
  78376. */
  78377. static readonly TriangleFillMode: number;
  78378. /**
  78379. * Returns the wireframe mode
  78380. */
  78381. static readonly WireFrameFillMode: number;
  78382. /**
  78383. * Returns the point fill mode
  78384. */
  78385. static readonly PointFillMode: number;
  78386. /**
  78387. * Returns the point list draw mode
  78388. */
  78389. static readonly PointListDrawMode: number;
  78390. /**
  78391. * Returns the line list draw mode
  78392. */
  78393. static readonly LineListDrawMode: number;
  78394. /**
  78395. * Returns the line loop draw mode
  78396. */
  78397. static readonly LineLoopDrawMode: number;
  78398. /**
  78399. * Returns the line strip draw mode
  78400. */
  78401. static readonly LineStripDrawMode: number;
  78402. /**
  78403. * Returns the triangle strip draw mode
  78404. */
  78405. static readonly TriangleStripDrawMode: number;
  78406. /**
  78407. * Returns the triangle fan draw mode
  78408. */
  78409. static readonly TriangleFanDrawMode: number;
  78410. /**
  78411. * Stores the clock-wise side orientation
  78412. */
  78413. static readonly ClockWiseSideOrientation: number;
  78414. /**
  78415. * Stores the counter clock-wise side orientation
  78416. */
  78417. static readonly CounterClockWiseSideOrientation: number;
  78418. /**
  78419. * The dirty texture flag value
  78420. */
  78421. static readonly TextureDirtyFlag: number;
  78422. /**
  78423. * The dirty light flag value
  78424. */
  78425. static readonly LightDirtyFlag: number;
  78426. /**
  78427. * The dirty fresnel flag value
  78428. */
  78429. static readonly FresnelDirtyFlag: number;
  78430. /**
  78431. * The dirty attribute flag value
  78432. */
  78433. static readonly AttributesDirtyFlag: number;
  78434. /**
  78435. * The dirty misc flag value
  78436. */
  78437. static readonly MiscDirtyFlag: number;
  78438. /**
  78439. * The all dirty flag value
  78440. */
  78441. static readonly AllDirtyFlag: number;
  78442. /**
  78443. * The ID of the material
  78444. */
  78445. id: string;
  78446. /**
  78447. * Gets or sets the unique id of the material
  78448. */
  78449. uniqueId: number;
  78450. /**
  78451. * The name of the material
  78452. */
  78453. name: string;
  78454. /**
  78455. * Gets or sets user defined metadata
  78456. */
  78457. metadata: any;
  78458. /**
  78459. * For internal use only. Please do not use.
  78460. */
  78461. reservedDataStore: any;
  78462. /**
  78463. * Specifies if the ready state should be checked on each call
  78464. */
  78465. checkReadyOnEveryCall: boolean;
  78466. /**
  78467. * Specifies if the ready state should be checked once
  78468. */
  78469. checkReadyOnlyOnce: boolean;
  78470. /**
  78471. * The state of the material
  78472. */
  78473. state: string;
  78474. /**
  78475. * The alpha value of the material
  78476. */
  78477. protected _alpha: number;
  78478. /**
  78479. * Sets the alpha value of the material
  78480. */
  78481. /**
  78482. * Gets the alpha value of the material
  78483. */
  78484. alpha: number;
  78485. /**
  78486. * Specifies if back face culling is enabled
  78487. */
  78488. protected _backFaceCulling: boolean;
  78489. /**
  78490. * Sets the back-face culling state
  78491. */
  78492. /**
  78493. * Gets the back-face culling state
  78494. */
  78495. backFaceCulling: boolean;
  78496. /**
  78497. * Stores the value for side orientation
  78498. */
  78499. sideOrientation: number;
  78500. /**
  78501. * Callback triggered when the material is compiled
  78502. */
  78503. onCompiled: (effect: Effect) => void;
  78504. /**
  78505. * Callback triggered when an error occurs
  78506. */
  78507. onError: (effect: Effect, errors: string) => void;
  78508. /**
  78509. * Callback triggered to get the render target textures
  78510. */
  78511. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78512. /**
  78513. * Gets a boolean indicating that current material needs to register RTT
  78514. */
  78515. readonly hasRenderTargetTextures: boolean;
  78516. /**
  78517. * Specifies if the material should be serialized
  78518. */
  78519. doNotSerialize: boolean;
  78520. /**
  78521. * @hidden
  78522. */
  78523. _storeEffectOnSubMeshes: boolean;
  78524. /**
  78525. * Stores the animations for the material
  78526. */
  78527. animations: Array<Animation>;
  78528. /**
  78529. * An event triggered when the material is disposed
  78530. */
  78531. onDisposeObservable: Observable<Material>;
  78532. /**
  78533. * An observer which watches for dispose events
  78534. */
  78535. private _onDisposeObserver;
  78536. private _onUnBindObservable;
  78537. /**
  78538. * Called during a dispose event
  78539. */
  78540. onDispose: () => void;
  78541. private _onBindObservable;
  78542. /**
  78543. * An event triggered when the material is bound
  78544. */
  78545. readonly onBindObservable: Observable<AbstractMesh>;
  78546. /**
  78547. * An observer which watches for bind events
  78548. */
  78549. private _onBindObserver;
  78550. /**
  78551. * Called during a bind event
  78552. */
  78553. onBind: (Mesh: AbstractMesh) => void;
  78554. /**
  78555. * An event triggered when the material is unbound
  78556. */
  78557. readonly onUnBindObservable: Observable<Material>;
  78558. /**
  78559. * Stores the value of the alpha mode
  78560. */
  78561. private _alphaMode;
  78562. /**
  78563. * Sets the value of the alpha mode.
  78564. *
  78565. * | Value | Type | Description |
  78566. * | --- | --- | --- |
  78567. * | 0 | ALPHA_DISABLE | |
  78568. * | 1 | ALPHA_ADD | |
  78569. * | 2 | ALPHA_COMBINE | |
  78570. * | 3 | ALPHA_SUBTRACT | |
  78571. * | 4 | ALPHA_MULTIPLY | |
  78572. * | 5 | ALPHA_MAXIMIZED | |
  78573. * | 6 | ALPHA_ONEONE | |
  78574. * | 7 | ALPHA_PREMULTIPLIED | |
  78575. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78576. * | 9 | ALPHA_INTERPOLATE | |
  78577. * | 10 | ALPHA_SCREENMODE | |
  78578. *
  78579. */
  78580. /**
  78581. * Gets the value of the alpha mode
  78582. */
  78583. alphaMode: number;
  78584. /**
  78585. * Stores the state of the need depth pre-pass value
  78586. */
  78587. private _needDepthPrePass;
  78588. /**
  78589. * Sets the need depth pre-pass value
  78590. */
  78591. /**
  78592. * Gets the depth pre-pass value
  78593. */
  78594. needDepthPrePass: boolean;
  78595. /**
  78596. * Specifies if depth writing should be disabled
  78597. */
  78598. disableDepthWrite: boolean;
  78599. /**
  78600. * Specifies if depth writing should be forced
  78601. */
  78602. forceDepthWrite: boolean;
  78603. /**
  78604. * Specifies if there should be a separate pass for culling
  78605. */
  78606. separateCullingPass: boolean;
  78607. /**
  78608. * Stores the state specifing if fog should be enabled
  78609. */
  78610. private _fogEnabled;
  78611. /**
  78612. * Sets the state for enabling fog
  78613. */
  78614. /**
  78615. * Gets the value of the fog enabled state
  78616. */
  78617. fogEnabled: boolean;
  78618. /**
  78619. * Stores the size of points
  78620. */
  78621. pointSize: number;
  78622. /**
  78623. * Stores the z offset value
  78624. */
  78625. zOffset: number;
  78626. /**
  78627. * Gets a value specifying if wireframe mode is enabled
  78628. */
  78629. /**
  78630. * Sets the state of wireframe mode
  78631. */
  78632. wireframe: boolean;
  78633. /**
  78634. * Gets the value specifying if point clouds are enabled
  78635. */
  78636. /**
  78637. * Sets the state of point cloud mode
  78638. */
  78639. pointsCloud: boolean;
  78640. /**
  78641. * Gets the material fill mode
  78642. */
  78643. /**
  78644. * Sets the material fill mode
  78645. */
  78646. fillMode: number;
  78647. /**
  78648. * @hidden
  78649. * Stores the effects for the material
  78650. */
  78651. _effect: Nullable<Effect>;
  78652. /**
  78653. * @hidden
  78654. * Specifies if the material was previously ready
  78655. */
  78656. _wasPreviouslyReady: boolean;
  78657. /**
  78658. * Specifies if uniform buffers should be used
  78659. */
  78660. private _useUBO;
  78661. /**
  78662. * Stores a reference to the scene
  78663. */
  78664. private _scene;
  78665. /**
  78666. * Stores the fill mode state
  78667. */
  78668. private _fillMode;
  78669. /**
  78670. * Specifies if the depth write state should be cached
  78671. */
  78672. private _cachedDepthWriteState;
  78673. /**
  78674. * Stores the uniform buffer
  78675. */
  78676. protected _uniformBuffer: UniformBuffer;
  78677. /** @hidden */
  78678. _indexInSceneMaterialArray: number;
  78679. /** @hidden */
  78680. meshMap: Nullable<{
  78681. [id: string]: AbstractMesh | undefined;
  78682. }>;
  78683. /**
  78684. * Creates a material instance
  78685. * @param name defines the name of the material
  78686. * @param scene defines the scene to reference
  78687. * @param doNotAdd specifies if the material should be added to the scene
  78688. */
  78689. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78690. /**
  78691. * Returns a string representation of the current material
  78692. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78693. * @returns a string with material information
  78694. */
  78695. toString(fullDetails?: boolean): string;
  78696. /**
  78697. * Gets the class name of the material
  78698. * @returns a string with the class name of the material
  78699. */
  78700. getClassName(): string;
  78701. /**
  78702. * Specifies if updates for the material been locked
  78703. */
  78704. readonly isFrozen: boolean;
  78705. /**
  78706. * Locks updates for the material
  78707. */
  78708. freeze(): void;
  78709. /**
  78710. * Unlocks updates for the material
  78711. */
  78712. unfreeze(): void;
  78713. /**
  78714. * Specifies if the material is ready to be used
  78715. * @param mesh defines the mesh to check
  78716. * @param useInstances specifies if instances should be used
  78717. * @returns a boolean indicating if the material is ready to be used
  78718. */
  78719. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78720. /**
  78721. * Specifies that the submesh is ready to be used
  78722. * @param mesh defines the mesh to check
  78723. * @param subMesh defines which submesh to check
  78724. * @param useInstances specifies that instances should be used
  78725. * @returns a boolean indicating that the submesh is ready or not
  78726. */
  78727. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78728. /**
  78729. * Returns the material effect
  78730. * @returns the effect associated with the material
  78731. */
  78732. getEffect(): Nullable<Effect>;
  78733. /**
  78734. * Returns the current scene
  78735. * @returns a Scene
  78736. */
  78737. getScene(): Scene;
  78738. /**
  78739. * Specifies if the material will require alpha blending
  78740. * @returns a boolean specifying if alpha blending is needed
  78741. */
  78742. needAlphaBlending(): boolean;
  78743. /**
  78744. * Specifies if the mesh will require alpha blending
  78745. * @param mesh defines the mesh to check
  78746. * @returns a boolean specifying if alpha blending is needed for the mesh
  78747. */
  78748. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78749. /**
  78750. * Specifies if this material should be rendered in alpha test mode
  78751. * @returns a boolean specifying if an alpha test is needed.
  78752. */
  78753. needAlphaTesting(): boolean;
  78754. /**
  78755. * Gets the texture used for the alpha test
  78756. * @returns the texture to use for alpha testing
  78757. */
  78758. getAlphaTestTexture(): Nullable<BaseTexture>;
  78759. /**
  78760. * Marks the material to indicate that it needs to be re-calculated
  78761. */
  78762. markDirty(): void;
  78763. /** @hidden */
  78764. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78765. /**
  78766. * Binds the material to the mesh
  78767. * @param world defines the world transformation matrix
  78768. * @param mesh defines the mesh to bind the material to
  78769. */
  78770. bind(world: Matrix, mesh?: Mesh): void;
  78771. /**
  78772. * Binds the submesh to the material
  78773. * @param world defines the world transformation matrix
  78774. * @param mesh defines the mesh containing the submesh
  78775. * @param subMesh defines the submesh to bind the material to
  78776. */
  78777. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78778. /**
  78779. * Binds the world matrix to the material
  78780. * @param world defines the world transformation matrix
  78781. */
  78782. bindOnlyWorldMatrix(world: Matrix): void;
  78783. /**
  78784. * Binds the scene's uniform buffer to the effect.
  78785. * @param effect defines the effect to bind to the scene uniform buffer
  78786. * @param sceneUbo defines the uniform buffer storing scene data
  78787. */
  78788. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78789. /**
  78790. * Binds the view matrix to the effect
  78791. * @param effect defines the effect to bind the view matrix to
  78792. */
  78793. bindView(effect: Effect): void;
  78794. /**
  78795. * Binds the view projection matrix to the effect
  78796. * @param effect defines the effect to bind the view projection matrix to
  78797. */
  78798. bindViewProjection(effect: Effect): void;
  78799. /**
  78800. * Specifies if material alpha testing should be turned on for the mesh
  78801. * @param mesh defines the mesh to check
  78802. */
  78803. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78804. /**
  78805. * Processes to execute after binding the material to a mesh
  78806. * @param mesh defines the rendered mesh
  78807. */
  78808. protected _afterBind(mesh?: Mesh): void;
  78809. /**
  78810. * Unbinds the material from the mesh
  78811. */
  78812. unbind(): void;
  78813. /**
  78814. * Gets the active textures from the material
  78815. * @returns an array of textures
  78816. */
  78817. getActiveTextures(): BaseTexture[];
  78818. /**
  78819. * Specifies if the material uses a texture
  78820. * @param texture defines the texture to check against the material
  78821. * @returns a boolean specifying if the material uses the texture
  78822. */
  78823. hasTexture(texture: BaseTexture): boolean;
  78824. /**
  78825. * Makes a duplicate of the material, and gives it a new name
  78826. * @param name defines the new name for the duplicated material
  78827. * @returns the cloned material
  78828. */
  78829. clone(name: string): Nullable<Material>;
  78830. /**
  78831. * Gets the meshes bound to the material
  78832. * @returns an array of meshes bound to the material
  78833. */
  78834. getBindedMeshes(): AbstractMesh[];
  78835. /**
  78836. * Force shader compilation
  78837. * @param mesh defines the mesh associated with this material
  78838. * @param onCompiled defines a function to execute once the material is compiled
  78839. * @param options defines the options to configure the compilation
  78840. */
  78841. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78842. clipPlane: boolean;
  78843. }>): void;
  78844. /**
  78845. * Force shader compilation
  78846. * @param mesh defines the mesh that will use this material
  78847. * @param options defines additional options for compiling the shaders
  78848. * @returns a promise that resolves when the compilation completes
  78849. */
  78850. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78851. clipPlane: boolean;
  78852. }>): Promise<void>;
  78853. private static readonly _ImageProcessingDirtyCallBack;
  78854. private static readonly _TextureDirtyCallBack;
  78855. private static readonly _FresnelDirtyCallBack;
  78856. private static readonly _MiscDirtyCallBack;
  78857. private static readonly _LightsDirtyCallBack;
  78858. private static readonly _AttributeDirtyCallBack;
  78859. private static _FresnelAndMiscDirtyCallBack;
  78860. private static _TextureAndMiscDirtyCallBack;
  78861. private static readonly _DirtyCallbackArray;
  78862. private static readonly _RunDirtyCallBacks;
  78863. /**
  78864. * Marks a define in the material to indicate that it needs to be re-computed
  78865. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78866. */
  78867. markAsDirty(flag: number): void;
  78868. /**
  78869. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78870. * @param func defines a function which checks material defines against the submeshes
  78871. */
  78872. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78873. /**
  78874. * Indicates that image processing needs to be re-calculated for all submeshes
  78875. */
  78876. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78877. /**
  78878. * Indicates that textures need to be re-calculated for all submeshes
  78879. */
  78880. protected _markAllSubMeshesAsTexturesDirty(): void;
  78881. /**
  78882. * Indicates that fresnel needs to be re-calculated for all submeshes
  78883. */
  78884. protected _markAllSubMeshesAsFresnelDirty(): void;
  78885. /**
  78886. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78887. */
  78888. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78889. /**
  78890. * Indicates that lights need to be re-calculated for all submeshes
  78891. */
  78892. protected _markAllSubMeshesAsLightsDirty(): void;
  78893. /**
  78894. * Indicates that attributes need to be re-calculated for all submeshes
  78895. */
  78896. protected _markAllSubMeshesAsAttributesDirty(): void;
  78897. /**
  78898. * Indicates that misc needs to be re-calculated for all submeshes
  78899. */
  78900. protected _markAllSubMeshesAsMiscDirty(): void;
  78901. /**
  78902. * Indicates that textures and misc need to be re-calculated for all submeshes
  78903. */
  78904. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78905. /**
  78906. * Disposes the material
  78907. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78908. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78909. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78910. */
  78911. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78912. /** @hidden */
  78913. private releaseVertexArrayObject;
  78914. /**
  78915. * Serializes this material
  78916. * @returns the serialized material object
  78917. */
  78918. serialize(): any;
  78919. /**
  78920. * Creates a material from parsed material data
  78921. * @param parsedMaterial defines parsed material data
  78922. * @param scene defines the hosting scene
  78923. * @param rootUrl defines the root URL to use to load textures
  78924. * @returns a new material
  78925. */
  78926. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78927. }
  78928. }
  78929. declare module BABYLON {
  78930. /**
  78931. * Base class for submeshes
  78932. */
  78933. export class BaseSubMesh {
  78934. /** @hidden */
  78935. _materialDefines: Nullable<MaterialDefines>;
  78936. /** @hidden */
  78937. _materialEffect: Nullable<Effect>;
  78938. /**
  78939. * Gets associated effect
  78940. */
  78941. readonly effect: Nullable<Effect>;
  78942. /**
  78943. * Sets associated effect (effect used to render this submesh)
  78944. * @param effect defines the effect to associate with
  78945. * @param defines defines the set of defines used to compile this effect
  78946. */
  78947. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78948. }
  78949. /**
  78950. * Defines a subdivision inside a mesh
  78951. */
  78952. export class SubMesh extends BaseSubMesh implements ICullable {
  78953. /** the material index to use */
  78954. materialIndex: number;
  78955. /** vertex index start */
  78956. verticesStart: number;
  78957. /** vertices count */
  78958. verticesCount: number;
  78959. /** index start */
  78960. indexStart: number;
  78961. /** indices count */
  78962. indexCount: number;
  78963. /** @hidden */
  78964. _linesIndexCount: number;
  78965. private _mesh;
  78966. private _renderingMesh;
  78967. private _boundingInfo;
  78968. private _linesIndexBuffer;
  78969. /** @hidden */
  78970. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78971. /** @hidden */
  78972. _trianglePlanes: Plane[];
  78973. /** @hidden */
  78974. _lastColliderTransformMatrix: Matrix;
  78975. /** @hidden */
  78976. _renderId: number;
  78977. /** @hidden */
  78978. _alphaIndex: number;
  78979. /** @hidden */
  78980. _distanceToCamera: number;
  78981. /** @hidden */
  78982. _id: number;
  78983. private _currentMaterial;
  78984. /**
  78985. * Add a new submesh to a mesh
  78986. * @param materialIndex defines the material index to use
  78987. * @param verticesStart defines vertex index start
  78988. * @param verticesCount defines vertices count
  78989. * @param indexStart defines index start
  78990. * @param indexCount defines indices count
  78991. * @param mesh defines the parent mesh
  78992. * @param renderingMesh defines an optional rendering mesh
  78993. * @param createBoundingBox defines if bounding box should be created for this submesh
  78994. * @returns the new submesh
  78995. */
  78996. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78997. /**
  78998. * Creates a new submesh
  78999. * @param materialIndex defines the material index to use
  79000. * @param verticesStart defines vertex index start
  79001. * @param verticesCount defines vertices count
  79002. * @param indexStart defines index start
  79003. * @param indexCount defines indices count
  79004. * @param mesh defines the parent mesh
  79005. * @param renderingMesh defines an optional rendering mesh
  79006. * @param createBoundingBox defines if bounding box should be created for this submesh
  79007. */
  79008. constructor(
  79009. /** the material index to use */
  79010. materialIndex: number,
  79011. /** vertex index start */
  79012. verticesStart: number,
  79013. /** vertices count */
  79014. verticesCount: number,
  79015. /** index start */
  79016. indexStart: number,
  79017. /** indices count */
  79018. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79019. /**
  79020. * Returns true if this submesh covers the entire parent mesh
  79021. * @ignorenaming
  79022. */
  79023. readonly IsGlobal: boolean;
  79024. /**
  79025. * Returns the submesh BoudingInfo object
  79026. * @returns current bounding info (or mesh's one if the submesh is global)
  79027. */
  79028. getBoundingInfo(): BoundingInfo;
  79029. /**
  79030. * Sets the submesh BoundingInfo
  79031. * @param boundingInfo defines the new bounding info to use
  79032. * @returns the SubMesh
  79033. */
  79034. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79035. /**
  79036. * Returns the mesh of the current submesh
  79037. * @return the parent mesh
  79038. */
  79039. getMesh(): AbstractMesh;
  79040. /**
  79041. * Returns the rendering mesh of the submesh
  79042. * @returns the rendering mesh (could be different from parent mesh)
  79043. */
  79044. getRenderingMesh(): Mesh;
  79045. /**
  79046. * Returns the submesh material
  79047. * @returns null or the current material
  79048. */
  79049. getMaterial(): Nullable<Material>;
  79050. /**
  79051. * Sets a new updated BoundingInfo object to the submesh
  79052. * @returns the SubMesh
  79053. */
  79054. refreshBoundingInfo(): SubMesh;
  79055. /** @hidden */
  79056. _checkCollision(collider: Collider): boolean;
  79057. /**
  79058. * Updates the submesh BoundingInfo
  79059. * @param world defines the world matrix to use to update the bounding info
  79060. * @returns the submesh
  79061. */
  79062. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79063. /**
  79064. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79065. * @param frustumPlanes defines the frustum planes
  79066. * @returns true if the submesh is intersecting with the frustum
  79067. */
  79068. isInFrustum(frustumPlanes: Plane[]): boolean;
  79069. /**
  79070. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79071. * @param frustumPlanes defines the frustum planes
  79072. * @returns true if the submesh is inside the frustum
  79073. */
  79074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79075. /**
  79076. * Renders the submesh
  79077. * @param enableAlphaMode defines if alpha needs to be used
  79078. * @returns the submesh
  79079. */
  79080. render(enableAlphaMode: boolean): SubMesh;
  79081. /**
  79082. * @hidden
  79083. */
  79084. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79085. /**
  79086. * Checks if the submesh intersects with a ray
  79087. * @param ray defines the ray to test
  79088. * @returns true is the passed ray intersects the submesh bounding box
  79089. */
  79090. canIntersects(ray: Ray): boolean;
  79091. /**
  79092. * Intersects current submesh with a ray
  79093. * @param ray defines the ray to test
  79094. * @param positions defines mesh's positions array
  79095. * @param indices defines mesh's indices array
  79096. * @param fastCheck defines if only bounding info should be used
  79097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79098. * @returns intersection info or null if no intersection
  79099. */
  79100. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79101. /** @hidden */
  79102. private _intersectLines;
  79103. /** @hidden */
  79104. private _intersectTriangles;
  79105. /** @hidden */
  79106. _rebuild(): void;
  79107. /**
  79108. * Creates a new submesh from the passed mesh
  79109. * @param newMesh defines the new hosting mesh
  79110. * @param newRenderingMesh defines an optional rendering mesh
  79111. * @returns the new submesh
  79112. */
  79113. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79114. /**
  79115. * Release associated resources
  79116. */
  79117. dispose(): void;
  79118. /**
  79119. * Gets the class name
  79120. * @returns the string "SubMesh".
  79121. */
  79122. getClassName(): string;
  79123. /**
  79124. * Creates a new submesh from indices data
  79125. * @param materialIndex the index of the main mesh material
  79126. * @param startIndex the index where to start the copy in the mesh indices array
  79127. * @param indexCount the number of indices to copy then from the startIndex
  79128. * @param mesh the main mesh to create the submesh from
  79129. * @param renderingMesh the optional rendering mesh
  79130. * @returns a new submesh
  79131. */
  79132. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79133. }
  79134. }
  79135. declare module BABYLON {
  79136. /**
  79137. * Class used to store geometry data (vertex buffers + index buffer)
  79138. */
  79139. export class Geometry implements IGetSetVerticesData {
  79140. /**
  79141. * Gets or sets the ID of the geometry
  79142. */
  79143. id: string;
  79144. /**
  79145. * Gets or sets the unique ID of the geometry
  79146. */
  79147. uniqueId: number;
  79148. /**
  79149. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79150. */
  79151. delayLoadState: number;
  79152. /**
  79153. * Gets the file containing the data to load when running in delay load state
  79154. */
  79155. delayLoadingFile: Nullable<string>;
  79156. /**
  79157. * Callback called when the geometry is updated
  79158. */
  79159. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79160. private _scene;
  79161. private _engine;
  79162. private _meshes;
  79163. private _totalVertices;
  79164. /** @hidden */
  79165. _indices: IndicesArray;
  79166. /** @hidden */
  79167. _vertexBuffers: {
  79168. [key: string]: VertexBuffer;
  79169. };
  79170. private _isDisposed;
  79171. private _extend;
  79172. private _boundingBias;
  79173. /** @hidden */
  79174. _delayInfo: Array<string>;
  79175. private _indexBuffer;
  79176. private _indexBufferIsUpdatable;
  79177. /** @hidden */
  79178. _boundingInfo: Nullable<BoundingInfo>;
  79179. /** @hidden */
  79180. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79181. /** @hidden */
  79182. _softwareSkinningFrameId: number;
  79183. private _vertexArrayObjects;
  79184. private _updatable;
  79185. /** @hidden */
  79186. _positions: Nullable<Vector3[]>;
  79187. /**
  79188. * 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
  79189. */
  79190. /**
  79191. * 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
  79192. */
  79193. boundingBias: Vector2;
  79194. /**
  79195. * Static function used to attach a new empty geometry to a mesh
  79196. * @param mesh defines the mesh to attach the geometry to
  79197. * @returns the new Geometry
  79198. */
  79199. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79200. /**
  79201. * Creates a new geometry
  79202. * @param id defines the unique ID
  79203. * @param scene defines the hosting scene
  79204. * @param vertexData defines the VertexData used to get geometry data
  79205. * @param updatable defines if geometry must be updatable (false by default)
  79206. * @param mesh defines the mesh that will be associated with the geometry
  79207. */
  79208. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79209. /**
  79210. * Gets the current extend of the geometry
  79211. */
  79212. readonly extend: {
  79213. minimum: Vector3;
  79214. maximum: Vector3;
  79215. };
  79216. /**
  79217. * Gets the hosting scene
  79218. * @returns the hosting Scene
  79219. */
  79220. getScene(): Scene;
  79221. /**
  79222. * Gets the hosting engine
  79223. * @returns the hosting Engine
  79224. */
  79225. getEngine(): Engine;
  79226. /**
  79227. * Defines if the geometry is ready to use
  79228. * @returns true if the geometry is ready to be used
  79229. */
  79230. isReady(): boolean;
  79231. /**
  79232. * Gets a value indicating that the geometry should not be serialized
  79233. */
  79234. readonly doNotSerialize: boolean;
  79235. /** @hidden */
  79236. _rebuild(): void;
  79237. /**
  79238. * Affects all geometry data in one call
  79239. * @param vertexData defines the geometry data
  79240. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79241. */
  79242. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79243. /**
  79244. * Set specific vertex data
  79245. * @param kind defines the data kind (Position, normal, etc...)
  79246. * @param data defines the vertex data to use
  79247. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79248. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79249. */
  79250. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79251. /**
  79252. * Removes a specific vertex data
  79253. * @param kind defines the data kind (Position, normal, etc...)
  79254. */
  79255. removeVerticesData(kind: string): void;
  79256. /**
  79257. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79258. * @param buffer defines the vertex buffer to use
  79259. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79260. */
  79261. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79262. /**
  79263. * Update a specific vertex buffer
  79264. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79265. * It will do nothing if the buffer is not updatable
  79266. * @param kind defines the data kind (Position, normal, etc...)
  79267. * @param data defines the data to use
  79268. * @param offset defines the offset in the target buffer where to store the data
  79269. * @param useBytes set to true if the offset is in bytes
  79270. */
  79271. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79272. /**
  79273. * Update a specific vertex buffer
  79274. * This function will create a new buffer if the current one is not updatable
  79275. * @param kind defines the data kind (Position, normal, etc...)
  79276. * @param data defines the data to use
  79277. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79278. */
  79279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79280. private _updateBoundingInfo;
  79281. /** @hidden */
  79282. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79283. /**
  79284. * Gets total number of vertices
  79285. * @returns the total number of vertices
  79286. */
  79287. getTotalVertices(): number;
  79288. /**
  79289. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79290. * @param kind defines the data kind (Position, normal, etc...)
  79291. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79293. * @returns a float array containing vertex data
  79294. */
  79295. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79296. /**
  79297. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79298. * @param kind defines the data kind (Position, normal, etc...)
  79299. * @returns true if the vertex buffer with the specified kind is updatable
  79300. */
  79301. isVertexBufferUpdatable(kind: string): boolean;
  79302. /**
  79303. * Gets a specific vertex buffer
  79304. * @param kind defines the data kind (Position, normal, etc...)
  79305. * @returns a VertexBuffer
  79306. */
  79307. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79308. /**
  79309. * Returns all vertex buffers
  79310. * @return an object holding all vertex buffers indexed by kind
  79311. */
  79312. getVertexBuffers(): Nullable<{
  79313. [key: string]: VertexBuffer;
  79314. }>;
  79315. /**
  79316. * Gets a boolean indicating if specific vertex buffer is present
  79317. * @param kind defines the data kind (Position, normal, etc...)
  79318. * @returns true if data is present
  79319. */
  79320. isVerticesDataPresent(kind: string): boolean;
  79321. /**
  79322. * Gets a list of all attached data kinds (Position, normal, etc...)
  79323. * @returns a list of string containing all kinds
  79324. */
  79325. getVerticesDataKinds(): string[];
  79326. /**
  79327. * Update index buffer
  79328. * @param indices defines the indices to store in the index buffer
  79329. * @param offset defines the offset in the target buffer where to store the data
  79330. */
  79331. updateIndices(indices: IndicesArray, offset?: number): void;
  79332. /**
  79333. * Creates a new index buffer
  79334. * @param indices defines the indices to store in the index buffer
  79335. * @param totalVertices defines the total number of vertices (could be null)
  79336. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79337. */
  79338. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79339. /**
  79340. * Return the total number of indices
  79341. * @returns the total number of indices
  79342. */
  79343. getTotalIndices(): number;
  79344. /**
  79345. * Gets the index buffer array
  79346. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79348. * @returns the index buffer array
  79349. */
  79350. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79351. /**
  79352. * Gets the index buffer
  79353. * @return the index buffer
  79354. */
  79355. getIndexBuffer(): Nullable<WebGLBuffer>;
  79356. /** @hidden */
  79357. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79358. /**
  79359. * Release the associated resources for a specific mesh
  79360. * @param mesh defines the source mesh
  79361. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79362. */
  79363. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79364. /**
  79365. * Apply current geometry to a given mesh
  79366. * @param mesh defines the mesh to apply geometry to
  79367. */
  79368. applyToMesh(mesh: Mesh): void;
  79369. private _updateExtend;
  79370. private _applyToMesh;
  79371. private notifyUpdate;
  79372. /**
  79373. * Load the geometry if it was flagged as delay loaded
  79374. * @param scene defines the hosting scene
  79375. * @param onLoaded defines a callback called when the geometry is loaded
  79376. */
  79377. load(scene: Scene, onLoaded?: () => void): void;
  79378. private _queueLoad;
  79379. /**
  79380. * Invert the geometry to move from a right handed system to a left handed one.
  79381. */
  79382. toLeftHanded(): void;
  79383. /** @hidden */
  79384. _resetPointsArrayCache(): void;
  79385. /** @hidden */
  79386. _generatePointsArray(): boolean;
  79387. /**
  79388. * Gets a value indicating if the geometry is disposed
  79389. * @returns true if the geometry was disposed
  79390. */
  79391. isDisposed(): boolean;
  79392. private _disposeVertexArrayObjects;
  79393. /**
  79394. * Free all associated resources
  79395. */
  79396. dispose(): void;
  79397. /**
  79398. * Clone the current geometry into a new geometry
  79399. * @param id defines the unique ID of the new geometry
  79400. * @returns a new geometry object
  79401. */
  79402. copy(id: string): Geometry;
  79403. /**
  79404. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79405. * @return a JSON representation of the current geometry data (without the vertices data)
  79406. */
  79407. serialize(): any;
  79408. private toNumberArray;
  79409. /**
  79410. * Serialize all vertices data into a JSON oject
  79411. * @returns a JSON representation of the current geometry data
  79412. */
  79413. serializeVerticeData(): any;
  79414. /**
  79415. * Extracts a clone of a mesh geometry
  79416. * @param mesh defines the source mesh
  79417. * @param id defines the unique ID of the new geometry object
  79418. * @returns the new geometry object
  79419. */
  79420. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79421. /**
  79422. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79423. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79424. * Be aware Math.random() could cause collisions, but:
  79425. * "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"
  79426. * @returns a string containing a new GUID
  79427. */
  79428. static RandomId(): string;
  79429. /** @hidden */
  79430. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79431. private static _CleanMatricesWeights;
  79432. /**
  79433. * Create a new geometry from persisted data (Using .babylon file format)
  79434. * @param parsedVertexData defines the persisted data
  79435. * @param scene defines the hosting scene
  79436. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79437. * @returns the new geometry object
  79438. */
  79439. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79440. }
  79441. }
  79442. declare module BABYLON {
  79443. /**
  79444. * Define an interface for all classes that will get and set the data on vertices
  79445. */
  79446. export interface IGetSetVerticesData {
  79447. /**
  79448. * Gets a boolean indicating if specific vertex data is present
  79449. * @param kind defines the vertex data kind to use
  79450. * @returns true is data kind is present
  79451. */
  79452. isVerticesDataPresent(kind: string): boolean;
  79453. /**
  79454. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79455. * @param kind defines the data kind (Position, normal, etc...)
  79456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79458. * @returns a float array containing vertex data
  79459. */
  79460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79461. /**
  79462. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79463. * @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.
  79464. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79465. * @returns the indices array or an empty array if the mesh has no geometry
  79466. */
  79467. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79468. /**
  79469. * Set specific vertex data
  79470. * @param kind defines the data kind (Position, normal, etc...)
  79471. * @param data defines the vertex data to use
  79472. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79473. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79474. */
  79475. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79476. /**
  79477. * Update a specific associated vertex buffer
  79478. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79479. * - VertexBuffer.PositionKind
  79480. * - VertexBuffer.UVKind
  79481. * - VertexBuffer.UV2Kind
  79482. * - VertexBuffer.UV3Kind
  79483. * - VertexBuffer.UV4Kind
  79484. * - VertexBuffer.UV5Kind
  79485. * - VertexBuffer.UV6Kind
  79486. * - VertexBuffer.ColorKind
  79487. * - VertexBuffer.MatricesIndicesKind
  79488. * - VertexBuffer.MatricesIndicesExtraKind
  79489. * - VertexBuffer.MatricesWeightsKind
  79490. * - VertexBuffer.MatricesWeightsExtraKind
  79491. * @param data defines the data source
  79492. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79493. * @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)
  79494. */
  79495. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79496. /**
  79497. * Creates a new index buffer
  79498. * @param indices defines the indices to store in the index buffer
  79499. * @param totalVertices defines the total number of vertices (could be null)
  79500. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79501. */
  79502. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79503. }
  79504. /**
  79505. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79506. */
  79507. export class VertexData {
  79508. /**
  79509. * Mesh side orientation : usually the external or front surface
  79510. */
  79511. static readonly FRONTSIDE: number;
  79512. /**
  79513. * Mesh side orientation : usually the internal or back surface
  79514. */
  79515. static readonly BACKSIDE: number;
  79516. /**
  79517. * Mesh side orientation : both internal and external or front and back surfaces
  79518. */
  79519. static readonly DOUBLESIDE: number;
  79520. /**
  79521. * Mesh side orientation : by default, `FRONTSIDE`
  79522. */
  79523. static readonly DEFAULTSIDE: number;
  79524. /**
  79525. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79526. */
  79527. positions: Nullable<FloatArray>;
  79528. /**
  79529. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79530. */
  79531. normals: Nullable<FloatArray>;
  79532. /**
  79533. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79534. */
  79535. tangents: Nullable<FloatArray>;
  79536. /**
  79537. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79538. */
  79539. uvs: Nullable<FloatArray>;
  79540. /**
  79541. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79542. */
  79543. uvs2: Nullable<FloatArray>;
  79544. /**
  79545. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79546. */
  79547. uvs3: Nullable<FloatArray>;
  79548. /**
  79549. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79550. */
  79551. uvs4: Nullable<FloatArray>;
  79552. /**
  79553. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79554. */
  79555. uvs5: Nullable<FloatArray>;
  79556. /**
  79557. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79558. */
  79559. uvs6: Nullable<FloatArray>;
  79560. /**
  79561. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79562. */
  79563. colors: Nullable<FloatArray>;
  79564. /**
  79565. * 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).
  79566. */
  79567. matricesIndices: Nullable<FloatArray>;
  79568. /**
  79569. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79570. */
  79571. matricesWeights: Nullable<FloatArray>;
  79572. /**
  79573. * An array extending the number of possible indices
  79574. */
  79575. matricesIndicesExtra: Nullable<FloatArray>;
  79576. /**
  79577. * An array extending the number of possible weights when the number of indices is extended
  79578. */
  79579. matricesWeightsExtra: Nullable<FloatArray>;
  79580. /**
  79581. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79582. */
  79583. indices: Nullable<IndicesArray>;
  79584. /**
  79585. * Uses the passed data array to set the set the values for the specified kind of data
  79586. * @param data a linear array of floating numbers
  79587. * @param kind the type of data that is being set, eg positions, colors etc
  79588. */
  79589. set(data: FloatArray, kind: string): void;
  79590. /**
  79591. * Associates the vertexData to the passed Mesh.
  79592. * Sets it as updatable or not (default `false`)
  79593. * @param mesh the mesh the vertexData is applied to
  79594. * @param updatable when used and having the value true allows new data to update the vertexData
  79595. * @returns the VertexData
  79596. */
  79597. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79598. /**
  79599. * Associates the vertexData to the passed Geometry.
  79600. * Sets it as updatable or not (default `false`)
  79601. * @param geometry the geometry the vertexData is applied to
  79602. * @param updatable when used and having the value true allows new data to update the vertexData
  79603. * @returns VertexData
  79604. */
  79605. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79606. /**
  79607. * Updates the associated mesh
  79608. * @param mesh the mesh to be updated
  79609. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79610. * @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
  79611. * @returns VertexData
  79612. */
  79613. updateMesh(mesh: Mesh): VertexData;
  79614. /**
  79615. * Updates the associated geometry
  79616. * @param geometry the geometry to be updated
  79617. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79618. * @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
  79619. * @returns VertexData.
  79620. */
  79621. updateGeometry(geometry: Geometry): VertexData;
  79622. private _applyTo;
  79623. private _update;
  79624. /**
  79625. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79626. * @param matrix the transforming matrix
  79627. * @returns the VertexData
  79628. */
  79629. transform(matrix: Matrix): VertexData;
  79630. /**
  79631. * Merges the passed VertexData into the current one
  79632. * @param other the VertexData to be merged into the current one
  79633. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79634. * @returns the modified VertexData
  79635. */
  79636. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79637. private _mergeElement;
  79638. private _validate;
  79639. /**
  79640. * Serializes the VertexData
  79641. * @returns a serialized object
  79642. */
  79643. serialize(): any;
  79644. /**
  79645. * Extracts the vertexData from a mesh
  79646. * @param mesh the mesh from which to extract the VertexData
  79647. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79648. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79649. * @returns the object VertexData associated to the passed mesh
  79650. */
  79651. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79652. /**
  79653. * Extracts the vertexData from the geometry
  79654. * @param geometry the geometry from which to extract the VertexData
  79655. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79656. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79657. * @returns the object VertexData associated to the passed mesh
  79658. */
  79659. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79660. private static _ExtractFrom;
  79661. /**
  79662. * Creates the VertexData for a Ribbon
  79663. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79664. * * pathArray array of paths, each of which an array of successive Vector3
  79665. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79666. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79667. * * 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
  79668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79669. * * 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)
  79670. * * 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)
  79671. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79672. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79673. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79674. * @returns the VertexData of the ribbon
  79675. */
  79676. static CreateRibbon(options: {
  79677. pathArray: Vector3[][];
  79678. closeArray?: boolean;
  79679. closePath?: boolean;
  79680. offset?: number;
  79681. sideOrientation?: number;
  79682. frontUVs?: Vector4;
  79683. backUVs?: Vector4;
  79684. invertUV?: boolean;
  79685. uvs?: Vector2[];
  79686. colors?: Color4[];
  79687. }): VertexData;
  79688. /**
  79689. * Creates the VertexData for a box
  79690. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79691. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79692. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79693. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79694. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79695. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79696. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79698. * * 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)
  79699. * * 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)
  79700. * @returns the VertexData of the box
  79701. */
  79702. static CreateBox(options: {
  79703. size?: number;
  79704. width?: number;
  79705. height?: number;
  79706. depth?: number;
  79707. faceUV?: Vector4[];
  79708. faceColors?: Color4[];
  79709. sideOrientation?: number;
  79710. frontUVs?: Vector4;
  79711. backUVs?: Vector4;
  79712. }): VertexData;
  79713. /**
  79714. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79716. * * segments sets the number of horizontal strips optional, default 32
  79717. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79718. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79719. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79720. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79721. * * 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
  79722. * * 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
  79723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79724. * * 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)
  79725. * * 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)
  79726. * @returns the VertexData of the ellipsoid
  79727. */
  79728. static CreateSphere(options: {
  79729. segments?: number;
  79730. diameter?: number;
  79731. diameterX?: number;
  79732. diameterY?: number;
  79733. diameterZ?: number;
  79734. arc?: number;
  79735. slice?: number;
  79736. sideOrientation?: number;
  79737. frontUVs?: Vector4;
  79738. backUVs?: Vector4;
  79739. }): VertexData;
  79740. /**
  79741. * Creates the VertexData for a cylinder, cone or prism
  79742. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79743. * * height sets the height (y direction) of the cylinder, optional, default 2
  79744. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79745. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79746. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79747. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79748. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79749. * * 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
  79750. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79751. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79752. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79753. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79755. * * 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)
  79756. * * 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)
  79757. * @returns the VertexData of the cylinder, cone or prism
  79758. */
  79759. static CreateCylinder(options: {
  79760. height?: number;
  79761. diameterTop?: number;
  79762. diameterBottom?: number;
  79763. diameter?: number;
  79764. tessellation?: number;
  79765. subdivisions?: number;
  79766. arc?: number;
  79767. faceColors?: Color4[];
  79768. faceUV?: Vector4[];
  79769. hasRings?: boolean;
  79770. enclose?: boolean;
  79771. sideOrientation?: number;
  79772. frontUVs?: Vector4;
  79773. backUVs?: Vector4;
  79774. }): VertexData;
  79775. /**
  79776. * Creates the VertexData for a torus
  79777. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79778. * * diameter the diameter of the torus, optional default 1
  79779. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79780. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79782. * * 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)
  79783. * * 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)
  79784. * @returns the VertexData of the torus
  79785. */
  79786. static CreateTorus(options: {
  79787. diameter?: number;
  79788. thickness?: number;
  79789. tessellation?: number;
  79790. sideOrientation?: number;
  79791. frontUVs?: Vector4;
  79792. backUVs?: Vector4;
  79793. }): VertexData;
  79794. /**
  79795. * Creates the VertexData of the LineSystem
  79796. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79797. * - lines an array of lines, each line being an array of successive Vector3
  79798. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79799. * @returns the VertexData of the LineSystem
  79800. */
  79801. static CreateLineSystem(options: {
  79802. lines: Vector3[][];
  79803. colors?: Nullable<Color4[][]>;
  79804. }): VertexData;
  79805. /**
  79806. * Create the VertexData for a DashedLines
  79807. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79808. * - points an array successive Vector3
  79809. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79810. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79811. * - dashNb the intended total number of dashes, optional, default 200
  79812. * @returns the VertexData for the DashedLines
  79813. */
  79814. static CreateDashedLines(options: {
  79815. points: Vector3[];
  79816. dashSize?: number;
  79817. gapSize?: number;
  79818. dashNb?: number;
  79819. }): VertexData;
  79820. /**
  79821. * Creates the VertexData for a Ground
  79822. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79823. * - width the width (x direction) of the ground, optional, default 1
  79824. * - height the height (z direction) of the ground, optional, default 1
  79825. * - subdivisions the number of subdivisions per side, optional, default 1
  79826. * @returns the VertexData of the Ground
  79827. */
  79828. static CreateGround(options: {
  79829. width?: number;
  79830. height?: number;
  79831. subdivisions?: number;
  79832. subdivisionsX?: number;
  79833. subdivisionsY?: number;
  79834. }): VertexData;
  79835. /**
  79836. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79837. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79838. * * xmin the ground minimum X coordinate, optional, default -1
  79839. * * zmin the ground minimum Z coordinate, optional, default -1
  79840. * * xmax the ground maximum X coordinate, optional, default 1
  79841. * * zmax the ground maximum Z coordinate, optional, default 1
  79842. * * 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}
  79843. * * 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}
  79844. * @returns the VertexData of the TiledGround
  79845. */
  79846. static CreateTiledGround(options: {
  79847. xmin: number;
  79848. zmin: number;
  79849. xmax: number;
  79850. zmax: number;
  79851. subdivisions?: {
  79852. w: number;
  79853. h: number;
  79854. };
  79855. precision?: {
  79856. w: number;
  79857. h: number;
  79858. };
  79859. }): VertexData;
  79860. /**
  79861. * Creates the VertexData of the Ground designed from a heightmap
  79862. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79863. * * width the width (x direction) of the ground
  79864. * * height the height (z direction) of the ground
  79865. * * subdivisions the number of subdivisions per side
  79866. * * minHeight the minimum altitude on the ground, optional, default 0
  79867. * * maxHeight the maximum altitude on the ground, optional default 1
  79868. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79869. * * buffer the array holding the image color data
  79870. * * bufferWidth the width of image
  79871. * * bufferHeight the height of image
  79872. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79873. * @returns the VertexData of the Ground designed from a heightmap
  79874. */
  79875. static CreateGroundFromHeightMap(options: {
  79876. width: number;
  79877. height: number;
  79878. subdivisions: number;
  79879. minHeight: number;
  79880. maxHeight: number;
  79881. colorFilter: Color3;
  79882. buffer: Uint8Array;
  79883. bufferWidth: number;
  79884. bufferHeight: number;
  79885. alphaFilter: number;
  79886. }): VertexData;
  79887. /**
  79888. * Creates the VertexData for a Plane
  79889. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79890. * * size sets the width and height of the plane to the value of size, optional default 1
  79891. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79892. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79894. * * 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)
  79895. * * 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)
  79896. * @returns the VertexData of the box
  79897. */
  79898. static CreatePlane(options: {
  79899. size?: number;
  79900. width?: number;
  79901. height?: number;
  79902. sideOrientation?: number;
  79903. frontUVs?: Vector4;
  79904. backUVs?: Vector4;
  79905. }): VertexData;
  79906. /**
  79907. * Creates the VertexData of the Disc or regular Polygon
  79908. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79909. * * radius the radius of the disc, optional default 0.5
  79910. * * tessellation the number of polygon sides, optional, default 64
  79911. * * 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
  79912. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79913. * * 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)
  79914. * * 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)
  79915. * @returns the VertexData of the box
  79916. */
  79917. static CreateDisc(options: {
  79918. radius?: number;
  79919. tessellation?: number;
  79920. arc?: number;
  79921. sideOrientation?: number;
  79922. frontUVs?: Vector4;
  79923. backUVs?: Vector4;
  79924. }): VertexData;
  79925. /**
  79926. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79927. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79928. * @param polygon a mesh built from polygonTriangulation.build()
  79929. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79930. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79931. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79932. * @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)
  79933. * @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)
  79934. * @returns the VertexData of the Polygon
  79935. */
  79936. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79937. /**
  79938. * Creates the VertexData of the IcoSphere
  79939. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79940. * * radius the radius of the IcoSphere, optional default 1
  79941. * * radiusX allows stretching in the x direction, optional, default radius
  79942. * * radiusY allows stretching in the y direction, optional, default radius
  79943. * * radiusZ allows stretching in the z direction, optional, default radius
  79944. * * flat when true creates a flat shaded mesh, optional, default true
  79945. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79947. * * 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)
  79948. * * 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)
  79949. * @returns the VertexData of the IcoSphere
  79950. */
  79951. static CreateIcoSphere(options: {
  79952. radius?: number;
  79953. radiusX?: number;
  79954. radiusY?: number;
  79955. radiusZ?: number;
  79956. flat?: boolean;
  79957. subdivisions?: number;
  79958. sideOrientation?: number;
  79959. frontUVs?: Vector4;
  79960. backUVs?: Vector4;
  79961. }): VertexData;
  79962. /**
  79963. * Creates the VertexData for a Polyhedron
  79964. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79965. * * type provided types are:
  79966. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79967. * * 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)
  79968. * * size the size of the IcoSphere, optional default 1
  79969. * * sizeX allows stretching in the x direction, optional, default size
  79970. * * sizeY allows stretching in the y direction, optional, default size
  79971. * * sizeZ allows stretching in the z direction, optional, default size
  79972. * * 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
  79973. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79974. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79975. * * flat when true creates a flat shaded mesh, optional, default true
  79976. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79978. * * 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)
  79979. * * 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)
  79980. * @returns the VertexData of the Polyhedron
  79981. */
  79982. static CreatePolyhedron(options: {
  79983. type?: number;
  79984. size?: number;
  79985. sizeX?: number;
  79986. sizeY?: number;
  79987. sizeZ?: number;
  79988. custom?: any;
  79989. faceUV?: Vector4[];
  79990. faceColors?: Color4[];
  79991. flat?: boolean;
  79992. sideOrientation?: number;
  79993. frontUVs?: Vector4;
  79994. backUVs?: Vector4;
  79995. }): VertexData;
  79996. /**
  79997. * Creates the VertexData for a TorusKnot
  79998. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79999. * * radius the radius of the torus knot, optional, default 2
  80000. * * tube the thickness of the tube, optional, default 0.5
  80001. * * radialSegments the number of sides on each tube segments, optional, default 32
  80002. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80003. * * p the number of windings around the z axis, optional, default 2
  80004. * * q the number of windings around the x axis, optional, default 3
  80005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80006. * * 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)
  80007. * * 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)
  80008. * @returns the VertexData of the Torus Knot
  80009. */
  80010. static CreateTorusKnot(options: {
  80011. radius?: number;
  80012. tube?: number;
  80013. radialSegments?: number;
  80014. tubularSegments?: number;
  80015. p?: number;
  80016. q?: number;
  80017. sideOrientation?: number;
  80018. frontUVs?: Vector4;
  80019. backUVs?: Vector4;
  80020. }): VertexData;
  80021. /**
  80022. * Compute normals for given positions and indices
  80023. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80024. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80025. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80026. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80027. * * facetNormals : optional array of facet normals (vector3)
  80028. * * facetPositions : optional array of facet positions (vector3)
  80029. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80030. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80031. * * bInfo : optional bounding info, required for facetPartitioning computation
  80032. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80033. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80034. * * useRightHandedSystem: optional boolean to for right handed system computation
  80035. * * depthSort : optional boolean to enable the facet depth sort computation
  80036. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80037. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80038. */
  80039. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80040. facetNormals?: any;
  80041. facetPositions?: any;
  80042. facetPartitioning?: any;
  80043. ratio?: number;
  80044. bInfo?: any;
  80045. bbSize?: Vector3;
  80046. subDiv?: any;
  80047. useRightHandedSystem?: boolean;
  80048. depthSort?: boolean;
  80049. distanceTo?: Vector3;
  80050. depthSortedFacets?: any;
  80051. }): void;
  80052. /** @hidden */
  80053. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80054. /**
  80055. * Applies VertexData created from the imported parameters to the geometry
  80056. * @param parsedVertexData the parsed data from an imported file
  80057. * @param geometry the geometry to apply the VertexData to
  80058. */
  80059. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80060. }
  80061. }
  80062. declare module BABYLON {
  80063. /**
  80064. * Class containing static functions to help procedurally build meshes
  80065. */
  80066. export class DiscBuilder {
  80067. /**
  80068. * Creates a plane polygonal mesh. By default, this is a disc
  80069. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80070. * * 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
  80071. * * 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
  80072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80075. * @param name defines the name of the mesh
  80076. * @param options defines the options used to create the mesh
  80077. * @param scene defines the hosting scene
  80078. * @returns the plane polygonal mesh
  80079. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80080. */
  80081. static CreateDisc(name: string, options: {
  80082. radius?: number;
  80083. tessellation?: number;
  80084. arc?: number;
  80085. updatable?: boolean;
  80086. sideOrientation?: number;
  80087. frontUVs?: Vector4;
  80088. backUVs?: Vector4;
  80089. }, scene?: Nullable<Scene>): Mesh;
  80090. }
  80091. }
  80092. declare module BABYLON {
  80093. /**
  80094. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80095. *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.
  80096. * The SPS is also a particle system. It provides some methods to manage the particles.
  80097. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80098. *
  80099. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80100. */
  80101. export class SolidParticleSystem implements IDisposable {
  80102. /**
  80103. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80104. * Example : var p = SPS.particles[i];
  80105. */
  80106. particles: SolidParticle[];
  80107. /**
  80108. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80109. */
  80110. nbParticles: number;
  80111. /**
  80112. * If the particles must ever face the camera (default false). Useful for planar particles.
  80113. */
  80114. billboard: boolean;
  80115. /**
  80116. * Recompute normals when adding a shape
  80117. */
  80118. recomputeNormals: boolean;
  80119. /**
  80120. * This a counter ofr your own usage. It's not set by any SPS functions.
  80121. */
  80122. counter: number;
  80123. /**
  80124. * The SPS name. This name is also given to the underlying mesh.
  80125. */
  80126. name: string;
  80127. /**
  80128. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80129. */
  80130. mesh: Mesh;
  80131. /**
  80132. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80133. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80134. */
  80135. vars: any;
  80136. /**
  80137. * This array is populated when the SPS is set as 'pickable'.
  80138. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80139. * Each element of this array is an object `{idx: int, faceId: int}`.
  80140. * `idx` is the picked particle index in the `SPS.particles` array
  80141. * `faceId` is the picked face index counted within this particle.
  80142. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80143. */
  80144. pickedParticles: {
  80145. idx: number;
  80146. faceId: number;
  80147. }[];
  80148. /**
  80149. * This array is populated when `enableDepthSort` is set to true.
  80150. * Each element of this array is an instance of the class DepthSortedParticle.
  80151. */
  80152. depthSortedParticles: DepthSortedParticle[];
  80153. /**
  80154. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80155. * @hidden
  80156. */
  80157. _bSphereOnly: boolean;
  80158. /**
  80159. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80160. * @hidden
  80161. */
  80162. _bSphereRadiusFactor: number;
  80163. private _scene;
  80164. private _positions;
  80165. private _indices;
  80166. private _normals;
  80167. private _colors;
  80168. private _uvs;
  80169. private _indices32;
  80170. private _positions32;
  80171. private _normals32;
  80172. private _fixedNormal32;
  80173. private _colors32;
  80174. private _uvs32;
  80175. private _index;
  80176. private _updatable;
  80177. private _pickable;
  80178. private _isVisibilityBoxLocked;
  80179. private _alwaysVisible;
  80180. private _depthSort;
  80181. private _shapeCounter;
  80182. private _copy;
  80183. private _color;
  80184. private _computeParticleColor;
  80185. private _computeParticleTexture;
  80186. private _computeParticleRotation;
  80187. private _computeParticleVertex;
  80188. private _computeBoundingBox;
  80189. private _depthSortParticles;
  80190. private _camera;
  80191. private _mustUnrotateFixedNormals;
  80192. private _particlesIntersect;
  80193. private _needs32Bits;
  80194. /**
  80195. * Creates a SPS (Solid Particle System) object.
  80196. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80197. * @param scene (Scene) is the scene in which the SPS is added.
  80198. * @param options defines the options of the sps e.g.
  80199. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80200. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80201. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80202. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80203. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80204. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80205. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80206. */
  80207. constructor(name: string, scene: Scene, options?: {
  80208. updatable?: boolean;
  80209. isPickable?: boolean;
  80210. enableDepthSort?: boolean;
  80211. particleIntersection?: boolean;
  80212. boundingSphereOnly?: boolean;
  80213. bSphereRadiusFactor?: number;
  80214. });
  80215. /**
  80216. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80217. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80218. * @returns the created mesh
  80219. */
  80220. buildMesh(): Mesh;
  80221. /**
  80222. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80223. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80224. * Thus the particles generated from `digest()` have their property `position` set yet.
  80225. * @param mesh ( Mesh ) is the mesh to be digested
  80226. * @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
  80227. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80228. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80229. * @returns the current SPS
  80230. */
  80231. digest(mesh: Mesh, options?: {
  80232. facetNb?: number;
  80233. number?: number;
  80234. delta?: number;
  80235. }): SolidParticleSystem;
  80236. private _unrotateFixedNormals;
  80237. private _resetCopy;
  80238. private _meshBuilder;
  80239. private _posToShape;
  80240. private _uvsToShapeUV;
  80241. private _addParticle;
  80242. /**
  80243. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80244. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80245. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80246. * @param nb (positive integer) the number of particles to be created from this model
  80247. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80248. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80249. * @returns the number of shapes in the system
  80250. */
  80251. addShape(mesh: Mesh, nb: number, options?: {
  80252. positionFunction?: any;
  80253. vertexFunction?: any;
  80254. }): number;
  80255. private _rebuildParticle;
  80256. /**
  80257. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80258. * @returns the SPS.
  80259. */
  80260. rebuildMesh(): SolidParticleSystem;
  80261. /**
  80262. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80263. * This method calls `updateParticle()` for each particle of the SPS.
  80264. * For an animated SPS, it is usually called within the render loop.
  80265. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80266. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80267. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80268. * @returns the SPS.
  80269. */
  80270. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80271. /**
  80272. * Disposes the SPS.
  80273. */
  80274. dispose(): void;
  80275. /**
  80276. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80277. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80278. * @returns the SPS.
  80279. */
  80280. refreshVisibleSize(): SolidParticleSystem;
  80281. /**
  80282. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80283. * @param size the size (float) of the visibility box
  80284. * note : this doesn't lock the SPS mesh bounding box.
  80285. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80286. */
  80287. setVisibilityBox(size: number): void;
  80288. /**
  80289. * Gets whether the SPS as always visible or not
  80290. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80291. */
  80292. /**
  80293. * Sets the SPS as always visible or not
  80294. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80295. */
  80296. isAlwaysVisible: boolean;
  80297. /**
  80298. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80299. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80300. */
  80301. /**
  80302. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80303. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80304. */
  80305. isVisibilityBoxLocked: boolean;
  80306. /**
  80307. * Tells to `setParticles()` to compute the particle rotations or not.
  80308. * Default value : true. The SPS is faster when it's set to false.
  80309. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80310. */
  80311. /**
  80312. * Gets if `setParticles()` computes the particle rotations or not.
  80313. * Default value : true. The SPS is faster when it's set to false.
  80314. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80315. */
  80316. computeParticleRotation: boolean;
  80317. /**
  80318. * Tells to `setParticles()` to compute the particle colors or not.
  80319. * Default value : true. The SPS is faster when it's set to false.
  80320. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80321. */
  80322. /**
  80323. * Gets if `setParticles()` computes the particle colors or not.
  80324. * Default value : true. The SPS is faster when it's set to false.
  80325. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80326. */
  80327. computeParticleColor: boolean;
  80328. /**
  80329. * Gets if `setParticles()` computes the particle textures or not.
  80330. * Default value : true. The SPS is faster when it's set to false.
  80331. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80332. */
  80333. computeParticleTexture: boolean;
  80334. /**
  80335. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80336. * Default value : false. The SPS is faster when it's set to false.
  80337. * Note : the particle custom vertex positions aren't stored values.
  80338. */
  80339. /**
  80340. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80341. * Default value : false. The SPS is faster when it's set to false.
  80342. * Note : the particle custom vertex positions aren't stored values.
  80343. */
  80344. computeParticleVertex: boolean;
  80345. /**
  80346. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80347. */
  80348. /**
  80349. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80350. */
  80351. computeBoundingBox: boolean;
  80352. /**
  80353. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80354. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80355. * Default : `true`
  80356. */
  80357. /**
  80358. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80359. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80360. * Default : `true`
  80361. */
  80362. depthSortParticles: boolean;
  80363. /**
  80364. * This function does nothing. It may be overwritten to set all the particle first values.
  80365. * The SPS doesn't call this function, you may have to call it by your own.
  80366. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80367. */
  80368. initParticles(): void;
  80369. /**
  80370. * This function does nothing. It may be overwritten to recycle a particle.
  80371. * The SPS doesn't call this function, you may have to call it by your own.
  80372. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80373. * @param particle The particle to recycle
  80374. * @returns the recycled particle
  80375. */
  80376. recycleParticle(particle: SolidParticle): SolidParticle;
  80377. /**
  80378. * Updates a particle : this function should be overwritten by the user.
  80379. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80380. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80381. * @example : just set a particle position or velocity and recycle conditions
  80382. * @param particle The particle to update
  80383. * @returns the updated particle
  80384. */
  80385. updateParticle(particle: SolidParticle): SolidParticle;
  80386. /**
  80387. * Updates a vertex of a particle : it can be overwritten by the user.
  80388. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80389. * @param particle the current particle
  80390. * @param vertex the current index of the current particle
  80391. * @param pt the index of the current vertex in the particle shape
  80392. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80393. * @example : just set a vertex particle position
  80394. * @returns the updated vertex
  80395. */
  80396. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80397. /**
  80398. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80399. * This does nothing and may be overwritten by the user.
  80400. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80401. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80402. * @param update the boolean update value actually passed to setParticles()
  80403. */
  80404. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80405. /**
  80406. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80407. * This will be passed three parameters.
  80408. * This does nothing and may be overwritten by the user.
  80409. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80410. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80411. * @param update the boolean update value actually passed to setParticles()
  80412. */
  80413. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80414. }
  80415. }
  80416. declare module BABYLON {
  80417. /**
  80418. * Represents one particle of a solid particle system.
  80419. */
  80420. export class SolidParticle {
  80421. /**
  80422. * particle global index
  80423. */
  80424. idx: number;
  80425. /**
  80426. * The color of the particle
  80427. */
  80428. color: Nullable<Color4>;
  80429. /**
  80430. * The world space position of the particle.
  80431. */
  80432. position: Vector3;
  80433. /**
  80434. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80435. */
  80436. rotation: Vector3;
  80437. /**
  80438. * The world space rotation quaternion of the particle.
  80439. */
  80440. rotationQuaternion: Nullable<Quaternion>;
  80441. /**
  80442. * The scaling of the particle.
  80443. */
  80444. scaling: Vector3;
  80445. /**
  80446. * The uvs of the particle.
  80447. */
  80448. uvs: Vector4;
  80449. /**
  80450. * The current speed of the particle.
  80451. */
  80452. velocity: Vector3;
  80453. /**
  80454. * The pivot point in the particle local space.
  80455. */
  80456. pivot: Vector3;
  80457. /**
  80458. * Must the particle be translated from its pivot point in its local space ?
  80459. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80460. * Default : false
  80461. */
  80462. translateFromPivot: boolean;
  80463. /**
  80464. * Is the particle active or not ?
  80465. */
  80466. alive: boolean;
  80467. /**
  80468. * Is the particle visible or not ?
  80469. */
  80470. isVisible: boolean;
  80471. /**
  80472. * Index of this particle in the global "positions" array (Internal use)
  80473. * @hidden
  80474. */
  80475. _pos: number;
  80476. /**
  80477. * @hidden Index of this particle in the global "indices" array (Internal use)
  80478. */
  80479. _ind: number;
  80480. /**
  80481. * @hidden ModelShape of this particle (Internal use)
  80482. */
  80483. _model: ModelShape;
  80484. /**
  80485. * ModelShape id of this particle
  80486. */
  80487. shapeId: number;
  80488. /**
  80489. * Index of the particle in its shape id (Internal use)
  80490. */
  80491. idxInShape: number;
  80492. /**
  80493. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80494. */
  80495. _modelBoundingInfo: BoundingInfo;
  80496. /**
  80497. * @hidden Particle BoundingInfo object (Internal use)
  80498. */
  80499. _boundingInfo: BoundingInfo;
  80500. /**
  80501. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80502. */
  80503. _sps: SolidParticleSystem;
  80504. /**
  80505. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80506. */
  80507. _stillInvisible: boolean;
  80508. /**
  80509. * @hidden Last computed particle rotation matrix
  80510. */
  80511. _rotationMatrix: number[];
  80512. /**
  80513. * Parent particle Id, if any.
  80514. * Default null.
  80515. */
  80516. parentId: Nullable<number>;
  80517. /**
  80518. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80519. * The possible values are :
  80520. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80521. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80522. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80523. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80524. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80525. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80526. * */
  80527. cullingStrategy: number;
  80528. /**
  80529. * @hidden Internal global position in the SPS.
  80530. */
  80531. _globalPosition: Vector3;
  80532. /**
  80533. * Creates a Solid Particle object.
  80534. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80535. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80536. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80537. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80538. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80539. * @param shapeId (integer) is the model shape identifier in the SPS.
  80540. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80541. * @param sps defines the sps it is associated to
  80542. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80543. */
  80544. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80545. /**
  80546. * Legacy support, changed scale to scaling
  80547. */
  80548. /**
  80549. * Legacy support, changed scale to scaling
  80550. */
  80551. scale: Vector3;
  80552. /**
  80553. * Legacy support, changed quaternion to rotationQuaternion
  80554. */
  80555. /**
  80556. * Legacy support, changed quaternion to rotationQuaternion
  80557. */
  80558. quaternion: Nullable<Quaternion>;
  80559. /**
  80560. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80561. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80562. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80563. * @returns true if it intersects
  80564. */
  80565. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80566. /**
  80567. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80568. * A particle is in the frustum if its bounding box intersects the frustum
  80569. * @param frustumPlanes defines the frustum to test
  80570. * @returns true if the particle is in the frustum planes
  80571. */
  80572. isInFrustum(frustumPlanes: Plane[]): boolean;
  80573. /**
  80574. * get the rotation matrix of the particle
  80575. * @hidden
  80576. */
  80577. getRotationMatrix(m: Matrix): void;
  80578. }
  80579. /**
  80580. * Represents the shape of the model used by one particle of a solid particle system.
  80581. * SPS internal tool, don't use it manually.
  80582. */
  80583. export class ModelShape {
  80584. /**
  80585. * The shape id
  80586. * @hidden
  80587. */
  80588. shapeID: number;
  80589. /**
  80590. * flat array of model positions (internal use)
  80591. * @hidden
  80592. */
  80593. _shape: Vector3[];
  80594. /**
  80595. * flat array of model UVs (internal use)
  80596. * @hidden
  80597. */
  80598. _shapeUV: number[];
  80599. /**
  80600. * length of the shape in the model indices array (internal use)
  80601. * @hidden
  80602. */
  80603. _indicesLength: number;
  80604. /**
  80605. * Custom position function (internal use)
  80606. * @hidden
  80607. */
  80608. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80609. /**
  80610. * Custom vertex function (internal use)
  80611. * @hidden
  80612. */
  80613. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80614. /**
  80615. * 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.
  80616. * SPS internal tool, don't use it manually.
  80617. * @hidden
  80618. */
  80619. 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>);
  80620. }
  80621. /**
  80622. * Represents a Depth Sorted Particle in the solid particle system.
  80623. */
  80624. export class DepthSortedParticle {
  80625. /**
  80626. * Index of the particle in the "indices" array
  80627. */
  80628. ind: number;
  80629. /**
  80630. * Length of the particle shape in the "indices" array
  80631. */
  80632. indicesLength: number;
  80633. /**
  80634. * Squared distance from the particle to the camera
  80635. */
  80636. sqDistance: number;
  80637. }
  80638. }
  80639. declare module BABYLON {
  80640. /**
  80641. * Class used to store all common mesh properties
  80642. */
  80643. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80644. /** No occlusion */
  80645. static OCCLUSION_TYPE_NONE: number;
  80646. /** Occlusion set to optimisitic */
  80647. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80648. /** Occlusion set to strict */
  80649. static OCCLUSION_TYPE_STRICT: number;
  80650. /** Use an accurante occlusion algorithm */
  80651. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80652. /** Use a conservative occlusion algorithm */
  80653. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80654. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80655. * Test order :
  80656. * Is the bounding sphere outside the frustum ?
  80657. * If not, are the bounding box vertices outside the frustum ?
  80658. * It not, then the cullable object is in the frustum.
  80659. */
  80660. static readonly CULLINGSTRATEGY_STANDARD: number;
  80661. /** Culling strategy : Bounding Sphere Only.
  80662. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80663. * It's also less accurate than the standard because some not visible objects can still be selected.
  80664. * Test : is the bounding sphere outside the frustum ?
  80665. * If not, then the cullable object is in the frustum.
  80666. */
  80667. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80668. /** Culling strategy : Optimistic Inclusion.
  80669. * This in an inclusion test first, then the standard exclusion test.
  80670. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80671. * 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.
  80672. * Anyway, it's as accurate as the standard strategy.
  80673. * Test :
  80674. * Is the cullable object bounding sphere center in the frustum ?
  80675. * If not, apply the default culling strategy.
  80676. */
  80677. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80678. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80679. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80680. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80681. * 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.
  80682. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80683. * Test :
  80684. * Is the cullable object bounding sphere center in the frustum ?
  80685. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80686. */
  80687. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80688. /**
  80689. * No billboard
  80690. */
  80691. static readonly BILLBOARDMODE_NONE: number;
  80692. /** Billboard on X axis */
  80693. static readonly BILLBOARDMODE_X: number;
  80694. /** Billboard on Y axis */
  80695. static readonly BILLBOARDMODE_Y: number;
  80696. /** Billboard on Z axis */
  80697. static readonly BILLBOARDMODE_Z: number;
  80698. /** Billboard on all axes */
  80699. static readonly BILLBOARDMODE_ALL: number;
  80700. private _facetData;
  80701. /**
  80702. * The culling strategy to use to check whether the mesh must be rendered or not.
  80703. * This value can be changed at any time and will be used on the next render mesh selection.
  80704. * The possible values are :
  80705. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80706. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80707. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80708. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80709. * Please read each static variable documentation to get details about the culling process.
  80710. * */
  80711. cullingStrategy: number;
  80712. /**
  80713. * Gets the number of facets in the mesh
  80714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80715. */
  80716. readonly facetNb: number;
  80717. /**
  80718. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80720. */
  80721. partitioningSubdivisions: number;
  80722. /**
  80723. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80724. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80726. */
  80727. partitioningBBoxRatio: number;
  80728. /**
  80729. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80730. * Works only for updatable meshes.
  80731. * Doesn't work with multi-materials
  80732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80733. */
  80734. mustDepthSortFacets: boolean;
  80735. /**
  80736. * The location (Vector3) where the facet depth sort must be computed from.
  80737. * By default, the active camera position.
  80738. * Used only when facet depth sort is enabled
  80739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80740. */
  80741. facetDepthSortFrom: Vector3;
  80742. /**
  80743. * gets a boolean indicating if facetData is enabled
  80744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80745. */
  80746. readonly isFacetDataEnabled: boolean;
  80747. /** @hidden */
  80748. _updateNonUniformScalingState(value: boolean): boolean;
  80749. /**
  80750. * An event triggered when this mesh collides with another one
  80751. */
  80752. onCollideObservable: Observable<AbstractMesh>;
  80753. private _onCollideObserver;
  80754. /** Set a function to call when this mesh collides with another one */
  80755. onCollide: () => void;
  80756. /**
  80757. * An event triggered when the collision's position changes
  80758. */
  80759. onCollisionPositionChangeObservable: Observable<Vector3>;
  80760. private _onCollisionPositionChangeObserver;
  80761. /** Set a function to call when the collision's position changes */
  80762. onCollisionPositionChange: () => void;
  80763. /**
  80764. * An event triggered when material is changed
  80765. */
  80766. onMaterialChangedObservable: Observable<AbstractMesh>;
  80767. /**
  80768. * Gets or sets the orientation for POV movement & rotation
  80769. */
  80770. definedFacingForward: boolean;
  80771. /** @hidden */
  80772. _occlusionQuery: Nullable<WebGLQuery>;
  80773. private _visibility;
  80774. /**
  80775. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80776. */
  80777. /**
  80778. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80779. */
  80780. visibility: number;
  80781. /** Gets or sets the alpha index used to sort transparent meshes
  80782. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80783. */
  80784. alphaIndex: number;
  80785. /**
  80786. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80787. */
  80788. isVisible: boolean;
  80789. /**
  80790. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80791. */
  80792. isPickable: boolean;
  80793. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80794. showSubMeshesBoundingBox: boolean;
  80795. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80796. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80797. */
  80798. isBlocker: boolean;
  80799. /**
  80800. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80801. */
  80802. enablePointerMoveEvents: boolean;
  80803. /**
  80804. * Specifies the rendering group id for this mesh (0 by default)
  80805. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80806. */
  80807. renderingGroupId: number;
  80808. private _material;
  80809. /** Gets or sets current material */
  80810. material: Nullable<Material>;
  80811. private _receiveShadows;
  80812. /**
  80813. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80814. * @see http://doc.babylonjs.com/babylon101/shadows
  80815. */
  80816. receiveShadows: boolean;
  80817. /** Defines color to use when rendering outline */
  80818. outlineColor: Color3;
  80819. /** Define width to use when rendering outline */
  80820. outlineWidth: number;
  80821. /** Defines color to use when rendering overlay */
  80822. overlayColor: Color3;
  80823. /** Defines alpha to use when rendering overlay */
  80824. overlayAlpha: number;
  80825. private _hasVertexAlpha;
  80826. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80827. hasVertexAlpha: boolean;
  80828. private _useVertexColors;
  80829. /** 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) */
  80830. useVertexColors: boolean;
  80831. private _computeBonesUsingShaders;
  80832. /**
  80833. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80834. */
  80835. computeBonesUsingShaders: boolean;
  80836. private _numBoneInfluencers;
  80837. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80838. numBoneInfluencers: number;
  80839. private _applyFog;
  80840. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80841. applyFog: boolean;
  80842. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80843. useOctreeForRenderingSelection: boolean;
  80844. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80845. useOctreeForPicking: boolean;
  80846. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80847. useOctreeForCollisions: boolean;
  80848. private _layerMask;
  80849. /**
  80850. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80851. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80852. */
  80853. layerMask: number;
  80854. /**
  80855. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80856. */
  80857. alwaysSelectAsActiveMesh: boolean;
  80858. /**
  80859. * Gets or sets the current action manager
  80860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80861. */
  80862. actionManager: Nullable<AbstractActionManager>;
  80863. private _checkCollisions;
  80864. private _collisionMask;
  80865. private _collisionGroup;
  80866. /**
  80867. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80869. */
  80870. ellipsoid: Vector3;
  80871. /**
  80872. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80874. */
  80875. ellipsoidOffset: Vector3;
  80876. private _collider;
  80877. private _oldPositionForCollisions;
  80878. private _diffPositionForCollisions;
  80879. /**
  80880. * Gets or sets a collision mask used to mask collisions (default is -1).
  80881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80882. */
  80883. collisionMask: number;
  80884. /**
  80885. * Gets or sets the current collision group mask (-1 by default).
  80886. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80887. */
  80888. collisionGroup: number;
  80889. /**
  80890. * Defines edge width used when edgesRenderer is enabled
  80891. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80892. */
  80893. edgesWidth: number;
  80894. /**
  80895. * Defines edge color used when edgesRenderer is enabled
  80896. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80897. */
  80898. edgesColor: Color4;
  80899. /** @hidden */
  80900. _edgesRenderer: Nullable<IEdgesRenderer>;
  80901. /** @hidden */
  80902. _masterMesh: Nullable<AbstractMesh>;
  80903. /** @hidden */
  80904. _boundingInfo: Nullable<BoundingInfo>;
  80905. /** @hidden */
  80906. _renderId: number;
  80907. /**
  80908. * Gets or sets the list of subMeshes
  80909. * @see http://doc.babylonjs.com/how_to/multi_materials
  80910. */
  80911. subMeshes: SubMesh[];
  80912. /** @hidden */
  80913. _intersectionsInProgress: AbstractMesh[];
  80914. /** @hidden */
  80915. _unIndexed: boolean;
  80916. /** @hidden */
  80917. _lightSources: Light[];
  80918. /** @hidden */
  80919. readonly _positions: Nullable<Vector3[]>;
  80920. /** @hidden */
  80921. _waitingActions: any;
  80922. /** @hidden */
  80923. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80924. private _skeleton;
  80925. /** @hidden */
  80926. _bonesTransformMatrices: Nullable<Float32Array>;
  80927. /**
  80928. * Gets or sets a skeleton to apply skining transformations
  80929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80930. */
  80931. skeleton: Nullable<Skeleton>;
  80932. /**
  80933. * An event triggered when the mesh is rebuilt.
  80934. */
  80935. onRebuildObservable: Observable<AbstractMesh>;
  80936. /**
  80937. * Creates a new AbstractMesh
  80938. * @param name defines the name of the mesh
  80939. * @param scene defines the hosting scene
  80940. */
  80941. constructor(name: string, scene?: Nullable<Scene>);
  80942. /**
  80943. * Returns the string "AbstractMesh"
  80944. * @returns "AbstractMesh"
  80945. */
  80946. getClassName(): string;
  80947. /**
  80948. * Gets a string representation of the current mesh
  80949. * @param fullDetails defines a boolean indicating if full details must be included
  80950. * @returns a string representation of the current mesh
  80951. */
  80952. toString(fullDetails?: boolean): string;
  80953. /** @hidden */
  80954. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80955. /** @hidden */
  80956. _rebuild(): void;
  80957. /** @hidden */
  80958. _resyncLightSources(): void;
  80959. /** @hidden */
  80960. _resyncLighSource(light: Light): void;
  80961. /** @hidden */
  80962. _unBindEffect(): void;
  80963. /** @hidden */
  80964. _removeLightSource(light: Light): void;
  80965. private _markSubMeshesAsDirty;
  80966. /** @hidden */
  80967. _markSubMeshesAsLightDirty(): void;
  80968. /** @hidden */
  80969. _markSubMeshesAsAttributesDirty(): void;
  80970. /** @hidden */
  80971. _markSubMeshesAsMiscDirty(): void;
  80972. /**
  80973. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80974. */
  80975. scaling: Vector3;
  80976. /**
  80977. * Returns true if the mesh is blocked. Implemented by child classes
  80978. */
  80979. readonly isBlocked: boolean;
  80980. /**
  80981. * Returns the mesh itself by default. Implemented by child classes
  80982. * @param camera defines the camera to use to pick the right LOD level
  80983. * @returns the currentAbstractMesh
  80984. */
  80985. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80986. /**
  80987. * Returns 0 by default. Implemented by child classes
  80988. * @returns an integer
  80989. */
  80990. getTotalVertices(): number;
  80991. /**
  80992. * Returns a positive integer : the total number of indices in this mesh geometry.
  80993. * @returns the numner of indices or zero if the mesh has no geometry.
  80994. */
  80995. getTotalIndices(): number;
  80996. /**
  80997. * Returns null by default. Implemented by child classes
  80998. * @returns null
  80999. */
  81000. getIndices(): Nullable<IndicesArray>;
  81001. /**
  81002. * Returns the array of the requested vertex data kind. Implemented by child classes
  81003. * @param kind defines the vertex data kind to use
  81004. * @returns null
  81005. */
  81006. getVerticesData(kind: string): Nullable<FloatArray>;
  81007. /**
  81008. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81009. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81010. * Note that a new underlying VertexBuffer object is created each call.
  81011. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81012. * @param kind defines vertex data kind:
  81013. * * VertexBuffer.PositionKind
  81014. * * VertexBuffer.UVKind
  81015. * * VertexBuffer.UV2Kind
  81016. * * VertexBuffer.UV3Kind
  81017. * * VertexBuffer.UV4Kind
  81018. * * VertexBuffer.UV5Kind
  81019. * * VertexBuffer.UV6Kind
  81020. * * VertexBuffer.ColorKind
  81021. * * VertexBuffer.MatricesIndicesKind
  81022. * * VertexBuffer.MatricesIndicesExtraKind
  81023. * * VertexBuffer.MatricesWeightsKind
  81024. * * VertexBuffer.MatricesWeightsExtraKind
  81025. * @param data defines the data source
  81026. * @param updatable defines if the data must be flagged as updatable (or static)
  81027. * @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
  81028. * @returns the current mesh
  81029. */
  81030. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81031. /**
  81032. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81033. * If the mesh has no geometry, it is simply returned as it is.
  81034. * @param kind defines vertex data kind:
  81035. * * VertexBuffer.PositionKind
  81036. * * VertexBuffer.UVKind
  81037. * * VertexBuffer.UV2Kind
  81038. * * VertexBuffer.UV3Kind
  81039. * * VertexBuffer.UV4Kind
  81040. * * VertexBuffer.UV5Kind
  81041. * * VertexBuffer.UV6Kind
  81042. * * VertexBuffer.ColorKind
  81043. * * VertexBuffer.MatricesIndicesKind
  81044. * * VertexBuffer.MatricesIndicesExtraKind
  81045. * * VertexBuffer.MatricesWeightsKind
  81046. * * VertexBuffer.MatricesWeightsExtraKind
  81047. * @param data defines the data source
  81048. * @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
  81049. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81050. * @returns the current mesh
  81051. */
  81052. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81053. /**
  81054. * Sets the mesh indices,
  81055. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81056. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81057. * @param totalVertices Defines the total number of vertices
  81058. * @returns the current mesh
  81059. */
  81060. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81061. /**
  81062. * Gets a boolean indicating if specific vertex data is present
  81063. * @param kind defines the vertex data kind to use
  81064. * @returns true is data kind is present
  81065. */
  81066. isVerticesDataPresent(kind: string): boolean;
  81067. /**
  81068. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81069. * @returns a BoundingInfo
  81070. */
  81071. getBoundingInfo(): BoundingInfo;
  81072. /**
  81073. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81074. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81075. * @returns the current mesh
  81076. */
  81077. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81078. /**
  81079. * Overwrite the current bounding info
  81080. * @param boundingInfo defines the new bounding info
  81081. * @returns the current mesh
  81082. */
  81083. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81084. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81085. readonly useBones: boolean;
  81086. /** @hidden */
  81087. _preActivate(): void;
  81088. /** @hidden */
  81089. _preActivateForIntermediateRendering(renderId: number): void;
  81090. /** @hidden */
  81091. _activate(renderId: number): void;
  81092. /**
  81093. * Gets the current world matrix
  81094. * @returns a Matrix
  81095. */
  81096. getWorldMatrix(): Matrix;
  81097. /** @hidden */
  81098. _getWorldMatrixDeterminant(): number;
  81099. /**
  81100. * Perform relative position change from the point of view of behind the front of the mesh.
  81101. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81102. * Supports definition of mesh facing forward or backward
  81103. * @param amountRight defines the distance on the right axis
  81104. * @param amountUp defines the distance on the up axis
  81105. * @param amountForward defines the distance on the forward axis
  81106. * @returns the current mesh
  81107. */
  81108. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81109. /**
  81110. * Calculate relative position change from the point of view of behind the front of the mesh.
  81111. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81112. * Supports definition of mesh facing forward or backward
  81113. * @param amountRight defines the distance on the right axis
  81114. * @param amountUp defines the distance on the up axis
  81115. * @param amountForward defines the distance on the forward axis
  81116. * @returns the new displacement vector
  81117. */
  81118. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81119. /**
  81120. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81121. * Supports definition of mesh facing forward or backward
  81122. * @param flipBack defines the flip
  81123. * @param twirlClockwise defines the twirl
  81124. * @param tiltRight defines the tilt
  81125. * @returns the current mesh
  81126. */
  81127. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81128. /**
  81129. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81130. * Supports definition of mesh facing forward or backward.
  81131. * @param flipBack defines the flip
  81132. * @param twirlClockwise defines the twirl
  81133. * @param tiltRight defines the tilt
  81134. * @returns the new rotation vector
  81135. */
  81136. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81137. /**
  81138. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81139. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81140. * @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
  81141. * @returns the new bounding vectors
  81142. */
  81143. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81144. min: Vector3;
  81145. max: Vector3;
  81146. };
  81147. /**
  81148. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81149. * This means the mesh underlying bounding box and sphere are recomputed.
  81150. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81151. * @returns the current mesh
  81152. */
  81153. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81154. /** @hidden */
  81155. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81156. /** @hidden */
  81157. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81158. /** @hidden */
  81159. _updateBoundingInfo(): AbstractMesh;
  81160. /** @hidden */
  81161. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81162. /** @hidden */
  81163. protected _afterComputeWorldMatrix(): void;
  81164. /**
  81165. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81166. * A mesh is in the frustum if its bounding box intersects the frustum
  81167. * @param frustumPlanes defines the frustum to test
  81168. * @returns true if the mesh is in the frustum planes
  81169. */
  81170. isInFrustum(frustumPlanes: Plane[]): boolean;
  81171. /**
  81172. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81173. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81174. * @param frustumPlanes defines the frustum to test
  81175. * @returns true if the mesh is completely in the frustum planes
  81176. */
  81177. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81178. /**
  81179. * True if the mesh intersects another mesh or a SolidParticle object
  81180. * @param mesh defines a target mesh or SolidParticle to test
  81181. * @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)
  81182. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81183. * @returns true if there is an intersection
  81184. */
  81185. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81186. /**
  81187. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81188. * @param point defines the point to test
  81189. * @returns true if there is an intersection
  81190. */
  81191. intersectsPoint(point: Vector3): boolean;
  81192. /**
  81193. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81195. */
  81196. checkCollisions: boolean;
  81197. /**
  81198. * Gets Collider object used to compute collisions (not physics)
  81199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81200. */
  81201. readonly collider: Collider;
  81202. /**
  81203. * Move the mesh using collision engine
  81204. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81205. * @param displacement defines the requested displacement vector
  81206. * @returns the current mesh
  81207. */
  81208. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81209. private _onCollisionPositionChange;
  81210. /** @hidden */
  81211. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81212. /** @hidden */
  81213. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81214. /** @hidden */
  81215. _checkCollision(collider: Collider): AbstractMesh;
  81216. /** @hidden */
  81217. _generatePointsArray(): boolean;
  81218. /**
  81219. * Checks if the passed Ray intersects with the mesh
  81220. * @param ray defines the ray to use
  81221. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81222. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81223. * @returns the picking info
  81224. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81225. */
  81226. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81227. /**
  81228. * Clones the current mesh
  81229. * @param name defines the mesh name
  81230. * @param newParent defines the new mesh parent
  81231. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81232. * @returns the new mesh
  81233. */
  81234. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81235. /**
  81236. * Disposes all the submeshes of the current meshnp
  81237. * @returns the current mesh
  81238. */
  81239. releaseSubMeshes(): AbstractMesh;
  81240. /**
  81241. * Releases resources associated with this abstract mesh.
  81242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81244. */
  81245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81246. /**
  81247. * Adds the passed mesh as a child to the current mesh
  81248. * @param mesh defines the child mesh
  81249. * @returns the current mesh
  81250. */
  81251. addChild(mesh: AbstractMesh): AbstractMesh;
  81252. /**
  81253. * Removes the passed mesh from the current mesh children list
  81254. * @param mesh defines the child mesh
  81255. * @returns the current mesh
  81256. */
  81257. removeChild(mesh: AbstractMesh): AbstractMesh;
  81258. /** @hidden */
  81259. private _initFacetData;
  81260. /**
  81261. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81262. * This method can be called within the render loop.
  81263. * 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
  81264. * @returns the current mesh
  81265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81266. */
  81267. updateFacetData(): AbstractMesh;
  81268. /**
  81269. * Returns the facetLocalNormals array.
  81270. * The normals are expressed in the mesh local spac
  81271. * @returns an array of Vector3
  81272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81273. */
  81274. getFacetLocalNormals(): Vector3[];
  81275. /**
  81276. * Returns the facetLocalPositions array.
  81277. * The facet positions are expressed in the mesh local space
  81278. * @returns an array of Vector3
  81279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81280. */
  81281. getFacetLocalPositions(): Vector3[];
  81282. /**
  81283. * Returns the facetLocalPartioning array
  81284. * @returns an array of array of numbers
  81285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81286. */
  81287. getFacetLocalPartitioning(): number[][];
  81288. /**
  81289. * Returns the i-th facet position in the world system.
  81290. * This method allocates a new Vector3 per call
  81291. * @param i defines the facet index
  81292. * @returns a new Vector3
  81293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81294. */
  81295. getFacetPosition(i: number): Vector3;
  81296. /**
  81297. * Sets the reference Vector3 with the i-th facet position in the world system
  81298. * @param i defines the facet index
  81299. * @param ref defines the target vector
  81300. * @returns the current mesh
  81301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81302. */
  81303. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81304. /**
  81305. * Returns the i-th facet normal in the world system.
  81306. * This method allocates a new Vector3 per call
  81307. * @param i defines the facet index
  81308. * @returns a new Vector3
  81309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81310. */
  81311. getFacetNormal(i: number): Vector3;
  81312. /**
  81313. * Sets the reference Vector3 with the i-th facet normal in the world system
  81314. * @param i defines the facet index
  81315. * @param ref defines the target vector
  81316. * @returns the current mesh
  81317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81318. */
  81319. getFacetNormalToRef(i: number, ref: Vector3): this;
  81320. /**
  81321. * 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)
  81322. * @param x defines x coordinate
  81323. * @param y defines y coordinate
  81324. * @param z defines z coordinate
  81325. * @returns the array of facet indexes
  81326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81327. */
  81328. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81329. /**
  81330. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81331. * @param projected sets as the (x,y,z) world projection on the facet
  81332. * @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
  81333. * @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
  81334. * @param x defines x coordinate
  81335. * @param y defines y coordinate
  81336. * @param z defines z coordinate
  81337. * @returns the face index if found (or null instead)
  81338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81339. */
  81340. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81341. /**
  81342. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81343. * @param projected sets as the (x,y,z) local projection on the facet
  81344. * @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
  81345. * @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
  81346. * @param x defines x coordinate
  81347. * @param y defines y coordinate
  81348. * @param z defines z coordinate
  81349. * @returns the face index if found (or null instead)
  81350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81351. */
  81352. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81353. /**
  81354. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81355. * @returns the parameters
  81356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81357. */
  81358. getFacetDataParameters(): any;
  81359. /**
  81360. * Disables the feature FacetData and frees the related memory
  81361. * @returns the current mesh
  81362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81363. */
  81364. disableFacetData(): AbstractMesh;
  81365. /**
  81366. * Updates the AbstractMesh indices array
  81367. * @param indices defines the data source
  81368. * @returns the current mesh
  81369. */
  81370. updateIndices(indices: IndicesArray): AbstractMesh;
  81371. /**
  81372. * Creates new normals data for the mesh
  81373. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81374. * @returns the current mesh
  81375. */
  81376. createNormals(updatable: boolean): AbstractMesh;
  81377. /**
  81378. * Align the mesh with a normal
  81379. * @param normal defines the normal to use
  81380. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81381. * @returns the current mesh
  81382. */
  81383. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81384. /** @hidden */
  81385. _checkOcclusionQuery(): boolean;
  81386. }
  81387. }
  81388. declare module BABYLON {
  81389. /**
  81390. * Interface used to define ActionEvent
  81391. */
  81392. export interface IActionEvent {
  81393. /** The mesh or sprite that triggered the action */
  81394. source: any;
  81395. /** The X mouse cursor position at the time of the event */
  81396. pointerX: number;
  81397. /** The Y mouse cursor position at the time of the event */
  81398. pointerY: number;
  81399. /** The mesh that is currently pointed at (can be null) */
  81400. meshUnderPointer: Nullable<AbstractMesh>;
  81401. /** the original (browser) event that triggered the ActionEvent */
  81402. sourceEvent?: any;
  81403. /** additional data for the event */
  81404. additionalData?: any;
  81405. }
  81406. /**
  81407. * ActionEvent is the event being sent when an action is triggered.
  81408. */
  81409. export class ActionEvent implements IActionEvent {
  81410. /** The mesh or sprite that triggered the action */
  81411. source: any;
  81412. /** The X mouse cursor position at the time of the event */
  81413. pointerX: number;
  81414. /** The Y mouse cursor position at the time of the event */
  81415. pointerY: number;
  81416. /** The mesh that is currently pointed at (can be null) */
  81417. meshUnderPointer: Nullable<AbstractMesh>;
  81418. /** the original (browser) event that triggered the ActionEvent */
  81419. sourceEvent?: any;
  81420. /** additional data for the event */
  81421. additionalData?: any;
  81422. /**
  81423. * Creates a new ActionEvent
  81424. * @param source The mesh or sprite that triggered the action
  81425. * @param pointerX The X mouse cursor position at the time of the event
  81426. * @param pointerY The Y mouse cursor position at the time of the event
  81427. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81428. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81429. * @param additionalData additional data for the event
  81430. */
  81431. constructor(
  81432. /** The mesh or sprite that triggered the action */
  81433. source: any,
  81434. /** The X mouse cursor position at the time of the event */
  81435. pointerX: number,
  81436. /** The Y mouse cursor position at the time of the event */
  81437. pointerY: number,
  81438. /** The mesh that is currently pointed at (can be null) */
  81439. meshUnderPointer: Nullable<AbstractMesh>,
  81440. /** the original (browser) event that triggered the ActionEvent */
  81441. sourceEvent?: any,
  81442. /** additional data for the event */
  81443. additionalData?: any);
  81444. /**
  81445. * Helper function to auto-create an ActionEvent from a source mesh.
  81446. * @param source The source mesh that triggered the event
  81447. * @param evt The original (browser) event
  81448. * @param additionalData additional data for the event
  81449. * @returns the new ActionEvent
  81450. */
  81451. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81452. /**
  81453. * Helper function to auto-create an ActionEvent from a source sprite
  81454. * @param source The source sprite that triggered the event
  81455. * @param scene Scene associated with the sprite
  81456. * @param evt The original (browser) event
  81457. * @param additionalData additional data for the event
  81458. * @returns the new ActionEvent
  81459. */
  81460. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81461. /**
  81462. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81463. * @param scene the scene where the event occurred
  81464. * @param evt The original (browser) event
  81465. * @returns the new ActionEvent
  81466. */
  81467. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81468. /**
  81469. * Helper function to auto-create an ActionEvent from a primitive
  81470. * @param prim defines the target primitive
  81471. * @param pointerPos defines the pointer position
  81472. * @param evt The original (browser) event
  81473. * @param additionalData additional data for the event
  81474. * @returns the new ActionEvent
  81475. */
  81476. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81477. }
  81478. }
  81479. declare module BABYLON {
  81480. /**
  81481. * Abstract class used to decouple action Manager from scene and meshes.
  81482. * Do not instantiate.
  81483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81484. */
  81485. export abstract class AbstractActionManager implements IDisposable {
  81486. /** Gets the list of active triggers */
  81487. static Triggers: {
  81488. [key: string]: number;
  81489. };
  81490. /** Gets the cursor to use when hovering items */
  81491. hoverCursor: string;
  81492. /** Gets the list of actions */
  81493. actions: IAction[];
  81494. /**
  81495. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81496. */
  81497. isRecursive: boolean;
  81498. /**
  81499. * Releases all associated resources
  81500. */
  81501. abstract dispose(): void;
  81502. /**
  81503. * Does this action manager has pointer triggers
  81504. */
  81505. abstract readonly hasPointerTriggers: boolean;
  81506. /**
  81507. * Does this action manager has pick triggers
  81508. */
  81509. abstract readonly hasPickTriggers: boolean;
  81510. /**
  81511. * Process a specific trigger
  81512. * @param trigger defines the trigger to process
  81513. * @param evt defines the event details to be processed
  81514. */
  81515. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81516. /**
  81517. * Does this action manager handles actions of any of the given triggers
  81518. * @param triggers defines the triggers to be tested
  81519. * @return a boolean indicating whether one (or more) of the triggers is handled
  81520. */
  81521. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81522. /**
  81523. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81524. * speed.
  81525. * @param triggerA defines the trigger to be tested
  81526. * @param triggerB defines the trigger to be tested
  81527. * @return a boolean indicating whether one (or more) of the triggers is handled
  81528. */
  81529. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81530. /**
  81531. * Does this action manager handles actions of a given trigger
  81532. * @param trigger defines the trigger to be tested
  81533. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81534. * @return whether the trigger is handled
  81535. */
  81536. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81537. /**
  81538. * Serialize this manager to a JSON object
  81539. * @param name defines the property name to store this manager
  81540. * @returns a JSON representation of this manager
  81541. */
  81542. abstract serialize(name: string): any;
  81543. /**
  81544. * Registers an action to this action manager
  81545. * @param action defines the action to be registered
  81546. * @return the action amended (prepared) after registration
  81547. */
  81548. abstract registerAction(action: IAction): Nullable<IAction>;
  81549. /**
  81550. * Unregisters an action to this action manager
  81551. * @param action defines the action to be unregistered
  81552. * @return a boolean indicating whether the action has been unregistered
  81553. */
  81554. abstract unregisterAction(action: IAction): Boolean;
  81555. /**
  81556. * Does exist one action manager with at least one trigger
  81557. **/
  81558. static readonly HasTriggers: boolean;
  81559. /**
  81560. * Does exist one action manager with at least one pick trigger
  81561. **/
  81562. static readonly HasPickTriggers: boolean;
  81563. /**
  81564. * Does exist one action manager that handles actions of a given trigger
  81565. * @param trigger defines the trigger to be tested
  81566. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81567. **/
  81568. static HasSpecificTrigger(trigger: number): boolean;
  81569. }
  81570. }
  81571. declare module BABYLON {
  81572. /**
  81573. * Defines how a node can be built from a string name.
  81574. */
  81575. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81576. /**
  81577. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81578. */
  81579. export class Node implements IBehaviorAware<Node> {
  81580. /** @hidden */
  81581. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81582. private static _NodeConstructors;
  81583. /**
  81584. * Add a new node constructor
  81585. * @param type defines the type name of the node to construct
  81586. * @param constructorFunc defines the constructor function
  81587. */
  81588. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81589. /**
  81590. * Returns a node constructor based on type name
  81591. * @param type defines the type name
  81592. * @param name defines the new node name
  81593. * @param scene defines the hosting scene
  81594. * @param options defines optional options to transmit to constructors
  81595. * @returns the new constructor or null
  81596. */
  81597. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81598. /**
  81599. * Gets or sets the name of the node
  81600. */
  81601. name: string;
  81602. /**
  81603. * Gets or sets the id of the node
  81604. */
  81605. id: string;
  81606. /**
  81607. * Gets or sets the unique id of the node
  81608. */
  81609. uniqueId: number;
  81610. /**
  81611. * Gets or sets a string used to store user defined state for the node
  81612. */
  81613. state: string;
  81614. /**
  81615. * Gets or sets an object used to store user defined information for the node
  81616. */
  81617. metadata: any;
  81618. /**
  81619. * For internal use only. Please do not use.
  81620. */
  81621. reservedDataStore: any;
  81622. /**
  81623. * Gets or sets a boolean used to define if the node must be serialized
  81624. */
  81625. doNotSerialize: boolean;
  81626. /** @hidden */
  81627. _isDisposed: boolean;
  81628. /**
  81629. * Gets a list of Animations associated with the node
  81630. */
  81631. animations: Animation[];
  81632. protected _ranges: {
  81633. [name: string]: Nullable<AnimationRange>;
  81634. };
  81635. /**
  81636. * Callback raised when the node is ready to be used
  81637. */
  81638. onReady: (node: Node) => void;
  81639. private _isEnabled;
  81640. private _isParentEnabled;
  81641. private _isReady;
  81642. /** @hidden */
  81643. _currentRenderId: number;
  81644. private _parentRenderId;
  81645. protected _childRenderId: number;
  81646. /** @hidden */
  81647. _waitingParentId: Nullable<string>;
  81648. /** @hidden */
  81649. _scene: Scene;
  81650. /** @hidden */
  81651. _cache: any;
  81652. private _parentNode;
  81653. private _children;
  81654. /** @hidden */
  81655. _worldMatrix: Matrix;
  81656. /** @hidden */
  81657. _worldMatrixDeterminant: number;
  81658. /** @hidden */
  81659. private _sceneRootNodesIndex;
  81660. /**
  81661. * Gets a boolean indicating if the node has been disposed
  81662. * @returns true if the node was disposed
  81663. */
  81664. isDisposed(): boolean;
  81665. /**
  81666. * Gets or sets the parent of the node
  81667. */
  81668. parent: Nullable<Node>;
  81669. private addToSceneRootNodes;
  81670. private removeFromSceneRootNodes;
  81671. private _animationPropertiesOverride;
  81672. /**
  81673. * Gets or sets the animation properties override
  81674. */
  81675. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81676. /**
  81677. * Gets a string idenfifying the name of the class
  81678. * @returns "Node" string
  81679. */
  81680. getClassName(): string;
  81681. /** @hidden */
  81682. readonly _isNode: boolean;
  81683. /**
  81684. * An event triggered when the mesh is disposed
  81685. */
  81686. onDisposeObservable: Observable<Node>;
  81687. private _onDisposeObserver;
  81688. /**
  81689. * Sets a callback that will be raised when the node will be disposed
  81690. */
  81691. onDispose: () => void;
  81692. /**
  81693. * Creates a new Node
  81694. * @param name the name and id to be given to this node
  81695. * @param scene the scene this node will be added to
  81696. * @param addToRootNodes the node will be added to scene.rootNodes
  81697. */
  81698. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81699. /**
  81700. * Gets the scene of the node
  81701. * @returns a scene
  81702. */
  81703. getScene(): Scene;
  81704. /**
  81705. * Gets the engine of the node
  81706. * @returns a Engine
  81707. */
  81708. getEngine(): Engine;
  81709. private _behaviors;
  81710. /**
  81711. * Attach a behavior to the node
  81712. * @see http://doc.babylonjs.com/features/behaviour
  81713. * @param behavior defines the behavior to attach
  81714. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81715. * @returns the current Node
  81716. */
  81717. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81718. /**
  81719. * Remove an attached behavior
  81720. * @see http://doc.babylonjs.com/features/behaviour
  81721. * @param behavior defines the behavior to attach
  81722. * @returns the current Node
  81723. */
  81724. removeBehavior(behavior: Behavior<Node>): Node;
  81725. /**
  81726. * Gets the list of attached behaviors
  81727. * @see http://doc.babylonjs.com/features/behaviour
  81728. */
  81729. readonly behaviors: Behavior<Node>[];
  81730. /**
  81731. * Gets an attached behavior by name
  81732. * @param name defines the name of the behavior to look for
  81733. * @see http://doc.babylonjs.com/features/behaviour
  81734. * @returns null if behavior was not found else the requested behavior
  81735. */
  81736. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81737. /**
  81738. * Returns the latest update of the World matrix
  81739. * @returns a Matrix
  81740. */
  81741. getWorldMatrix(): Matrix;
  81742. /** @hidden */
  81743. _getWorldMatrixDeterminant(): number;
  81744. /**
  81745. * Returns directly the latest state of the mesh World matrix.
  81746. * A Matrix is returned.
  81747. */
  81748. readonly worldMatrixFromCache: Matrix;
  81749. /** @hidden */
  81750. _initCache(): void;
  81751. /** @hidden */
  81752. updateCache(force?: boolean): void;
  81753. /** @hidden */
  81754. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81755. /** @hidden */
  81756. _updateCache(ignoreParentClass?: boolean): void;
  81757. /** @hidden */
  81758. _isSynchronized(): boolean;
  81759. /** @hidden */
  81760. _markSyncedWithParent(): void;
  81761. /** @hidden */
  81762. isSynchronizedWithParent(): boolean;
  81763. /** @hidden */
  81764. isSynchronized(): boolean;
  81765. /**
  81766. * Is this node ready to be used/rendered
  81767. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81768. * @return true if the node is ready
  81769. */
  81770. isReady(completeCheck?: boolean): boolean;
  81771. /**
  81772. * Is this node enabled?
  81773. * 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
  81774. * @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
  81775. * @return whether this node (and its parent) is enabled
  81776. */
  81777. isEnabled(checkAncestors?: boolean): boolean;
  81778. /** @hidden */
  81779. protected _syncParentEnabledState(): void;
  81780. /**
  81781. * Set the enabled state of this node
  81782. * @param value defines the new enabled state
  81783. */
  81784. setEnabled(value: boolean): void;
  81785. /**
  81786. * Is this node a descendant of the given node?
  81787. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81788. * @param ancestor defines the parent node to inspect
  81789. * @returns a boolean indicating if this node is a descendant of the given node
  81790. */
  81791. isDescendantOf(ancestor: Node): boolean;
  81792. /** @hidden */
  81793. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81794. /**
  81795. * Will return all nodes that have this node as ascendant
  81796. * @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
  81797. * @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
  81798. * @return all children nodes of all types
  81799. */
  81800. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81801. /**
  81802. * Get all child-meshes of this node
  81803. * @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)
  81804. * @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
  81805. * @returns an array of AbstractMesh
  81806. */
  81807. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81808. /**
  81809. * Get all direct children of this node
  81810. * @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
  81811. * @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)
  81812. * @returns an array of Node
  81813. */
  81814. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81815. /** @hidden */
  81816. _setReady(state: boolean): void;
  81817. /**
  81818. * Get an animation by name
  81819. * @param name defines the name of the animation to look for
  81820. * @returns null if not found else the requested animation
  81821. */
  81822. getAnimationByName(name: string): Nullable<Animation>;
  81823. /**
  81824. * Creates an animation range for this node
  81825. * @param name defines the name of the range
  81826. * @param from defines the starting key
  81827. * @param to defines the end key
  81828. */
  81829. createAnimationRange(name: string, from: number, to: number): void;
  81830. /**
  81831. * Delete a specific animation range
  81832. * @param name defines the name of the range to delete
  81833. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81834. */
  81835. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81836. /**
  81837. * Get an animation range by name
  81838. * @param name defines the name of the animation range to look for
  81839. * @returns null if not found else the requested animation range
  81840. */
  81841. getAnimationRange(name: string): Nullable<AnimationRange>;
  81842. /**
  81843. * Gets the list of all animation ranges defined on this node
  81844. * @returns an array
  81845. */
  81846. getAnimationRanges(): Nullable<AnimationRange>[];
  81847. /**
  81848. * Will start the animation sequence
  81849. * @param name defines the range frames for animation sequence
  81850. * @param loop defines if the animation should loop (false by default)
  81851. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81852. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81853. * @returns the object created for this animation. If range does not exist, it will return null
  81854. */
  81855. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81856. /**
  81857. * Serialize animation ranges into a JSON compatible object
  81858. * @returns serialization object
  81859. */
  81860. serializeAnimationRanges(): any;
  81861. /**
  81862. * Computes the world matrix of the node
  81863. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81864. * @returns the world matrix
  81865. */
  81866. computeWorldMatrix(force?: boolean): Matrix;
  81867. /**
  81868. * Releases resources associated with this node.
  81869. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81870. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81871. */
  81872. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81873. /**
  81874. * Parse animation range data from a serialization object and store them into a given node
  81875. * @param node defines where to store the animation ranges
  81876. * @param parsedNode defines the serialization object to read data from
  81877. * @param scene defines the hosting scene
  81878. */
  81879. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81880. }
  81881. }
  81882. declare module BABYLON {
  81883. /**
  81884. * Class used to store any kind of animation
  81885. */
  81886. export class Animation {
  81887. /**Name of the animation */
  81888. name: string;
  81889. /**Property to animate */
  81890. targetProperty: string;
  81891. /**The frames per second of the animation */
  81892. framePerSecond: number;
  81893. /**The data type of the animation */
  81894. dataType: number;
  81895. /**The loop mode of the animation */
  81896. loopMode?: number | undefined;
  81897. /**Specifies if blending should be enabled */
  81898. enableBlending?: boolean | undefined;
  81899. /**
  81900. * Use matrix interpolation instead of using direct key value when animating matrices
  81901. */
  81902. static AllowMatricesInterpolation: boolean;
  81903. /**
  81904. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81905. */
  81906. static AllowMatrixDecomposeForInterpolation: boolean;
  81907. /**
  81908. * Stores the key frames of the animation
  81909. */
  81910. private _keys;
  81911. /**
  81912. * Stores the easing function of the animation
  81913. */
  81914. private _easingFunction;
  81915. /**
  81916. * @hidden Internal use only
  81917. */
  81918. _runtimeAnimations: RuntimeAnimation[];
  81919. /**
  81920. * The set of event that will be linked to this animation
  81921. */
  81922. private _events;
  81923. /**
  81924. * Stores an array of target property paths
  81925. */
  81926. targetPropertyPath: string[];
  81927. /**
  81928. * Stores the blending speed of the animation
  81929. */
  81930. blendingSpeed: number;
  81931. /**
  81932. * Stores the animation ranges for the animation
  81933. */
  81934. private _ranges;
  81935. /**
  81936. * @hidden Internal use
  81937. */
  81938. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81939. /**
  81940. * Sets up an animation
  81941. * @param property The property to animate
  81942. * @param animationType The animation type to apply
  81943. * @param framePerSecond The frames per second of the animation
  81944. * @param easingFunction The easing function used in the animation
  81945. * @returns The created animation
  81946. */
  81947. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81948. /**
  81949. * Create and start an animation on a node
  81950. * @param name defines the name of the global animation that will be run on all nodes
  81951. * @param node defines the root node where the animation will take place
  81952. * @param targetProperty defines property to animate
  81953. * @param framePerSecond defines the number of frame per second yo use
  81954. * @param totalFrame defines the number of frames in total
  81955. * @param from defines the initial value
  81956. * @param to defines the final value
  81957. * @param loopMode defines which loop mode you want to use (off by default)
  81958. * @param easingFunction defines the easing function to use (linear by default)
  81959. * @param onAnimationEnd defines the callback to call when animation end
  81960. * @returns the animatable created for this animation
  81961. */
  81962. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81963. /**
  81964. * Create and start an animation on a node and its descendants
  81965. * @param name defines the name of the global animation that will be run on all nodes
  81966. * @param node defines the root node where the animation will take place
  81967. * @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
  81968. * @param targetProperty defines property to animate
  81969. * @param framePerSecond defines the number of frame per second to use
  81970. * @param totalFrame defines the number of frames in total
  81971. * @param from defines the initial value
  81972. * @param to defines the final value
  81973. * @param loopMode defines which loop mode you want to use (off by default)
  81974. * @param easingFunction defines the easing function to use (linear by default)
  81975. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81976. * @returns the list of animatables created for all nodes
  81977. * @example https://www.babylonjs-playground.com/#MH0VLI
  81978. */
  81979. 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[]>;
  81980. /**
  81981. * Creates a new animation, merges it with the existing animations and starts it
  81982. * @param name Name of the animation
  81983. * @param node Node which contains the scene that begins the animations
  81984. * @param targetProperty Specifies which property to animate
  81985. * @param framePerSecond The frames per second of the animation
  81986. * @param totalFrame The total number of frames
  81987. * @param from The frame at the beginning of the animation
  81988. * @param to The frame at the end of the animation
  81989. * @param loopMode Specifies the loop mode of the animation
  81990. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81991. * @param onAnimationEnd Callback to run once the animation is complete
  81992. * @returns Nullable animation
  81993. */
  81994. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81995. /**
  81996. * Transition property of an host to the target Value
  81997. * @param property The property to transition
  81998. * @param targetValue The target Value of the property
  81999. * @param host The object where the property to animate belongs
  82000. * @param scene Scene used to run the animation
  82001. * @param frameRate Framerate (in frame/s) to use
  82002. * @param transition The transition type we want to use
  82003. * @param duration The duration of the animation, in milliseconds
  82004. * @param onAnimationEnd Callback trigger at the end of the animation
  82005. * @returns Nullable animation
  82006. */
  82007. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82008. /**
  82009. * Return the array of runtime animations currently using this animation
  82010. */
  82011. readonly runtimeAnimations: RuntimeAnimation[];
  82012. /**
  82013. * Specifies if any of the runtime animations are currently running
  82014. */
  82015. readonly hasRunningRuntimeAnimations: boolean;
  82016. /**
  82017. * Initializes the animation
  82018. * @param name Name of the animation
  82019. * @param targetProperty Property to animate
  82020. * @param framePerSecond The frames per second of the animation
  82021. * @param dataType The data type of the animation
  82022. * @param loopMode The loop mode of the animation
  82023. * @param enableBlending Specifies if blending should be enabled
  82024. */
  82025. constructor(
  82026. /**Name of the animation */
  82027. name: string,
  82028. /**Property to animate */
  82029. targetProperty: string,
  82030. /**The frames per second of the animation */
  82031. framePerSecond: number,
  82032. /**The data type of the animation */
  82033. dataType: number,
  82034. /**The loop mode of the animation */
  82035. loopMode?: number | undefined,
  82036. /**Specifies if blending should be enabled */
  82037. enableBlending?: boolean | undefined);
  82038. /**
  82039. * Converts the animation to a string
  82040. * @param fullDetails support for multiple levels of logging within scene loading
  82041. * @returns String form of the animation
  82042. */
  82043. toString(fullDetails?: boolean): string;
  82044. /**
  82045. * Add an event to this animation
  82046. * @param event Event to add
  82047. */
  82048. addEvent(event: AnimationEvent): void;
  82049. /**
  82050. * Remove all events found at the given frame
  82051. * @param frame The frame to remove events from
  82052. */
  82053. removeEvents(frame: number): void;
  82054. /**
  82055. * Retrieves all the events from the animation
  82056. * @returns Events from the animation
  82057. */
  82058. getEvents(): AnimationEvent[];
  82059. /**
  82060. * Creates an animation range
  82061. * @param name Name of the animation range
  82062. * @param from Starting frame of the animation range
  82063. * @param to Ending frame of the animation
  82064. */
  82065. createRange(name: string, from: number, to: number): void;
  82066. /**
  82067. * Deletes an animation range by name
  82068. * @param name Name of the animation range to delete
  82069. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82070. */
  82071. deleteRange(name: string, deleteFrames?: boolean): void;
  82072. /**
  82073. * Gets the animation range by name, or null if not defined
  82074. * @param name Name of the animation range
  82075. * @returns Nullable animation range
  82076. */
  82077. getRange(name: string): Nullable<AnimationRange>;
  82078. /**
  82079. * Gets the key frames from the animation
  82080. * @returns The key frames of the animation
  82081. */
  82082. getKeys(): Array<IAnimationKey>;
  82083. /**
  82084. * Gets the highest frame rate of the animation
  82085. * @returns Highest frame rate of the animation
  82086. */
  82087. getHighestFrame(): number;
  82088. /**
  82089. * Gets the easing function of the animation
  82090. * @returns Easing function of the animation
  82091. */
  82092. getEasingFunction(): IEasingFunction;
  82093. /**
  82094. * Sets the easing function of the animation
  82095. * @param easingFunction A custom mathematical formula for animation
  82096. */
  82097. setEasingFunction(easingFunction: EasingFunction): void;
  82098. /**
  82099. * Interpolates a scalar linearly
  82100. * @param startValue Start value of the animation curve
  82101. * @param endValue End value of the animation curve
  82102. * @param gradient Scalar amount to interpolate
  82103. * @returns Interpolated scalar value
  82104. */
  82105. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82106. /**
  82107. * Interpolates a scalar cubically
  82108. * @param startValue Start value of the animation curve
  82109. * @param outTangent End tangent of the animation
  82110. * @param endValue End value of the animation curve
  82111. * @param inTangent Start tangent of the animation curve
  82112. * @param gradient Scalar amount to interpolate
  82113. * @returns Interpolated scalar value
  82114. */
  82115. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82116. /**
  82117. * Interpolates a quaternion using a spherical linear interpolation
  82118. * @param startValue Start value of the animation curve
  82119. * @param endValue End value of the animation curve
  82120. * @param gradient Scalar amount to interpolate
  82121. * @returns Interpolated quaternion value
  82122. */
  82123. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82124. /**
  82125. * Interpolates a quaternion cubically
  82126. * @param startValue Start value of the animation curve
  82127. * @param outTangent End tangent of the animation curve
  82128. * @param endValue End value of the animation curve
  82129. * @param inTangent Start tangent of the animation curve
  82130. * @param gradient Scalar amount to interpolate
  82131. * @returns Interpolated quaternion value
  82132. */
  82133. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82134. /**
  82135. * Interpolates a Vector3 linearl
  82136. * @param startValue Start value of the animation curve
  82137. * @param endValue End value of the animation curve
  82138. * @param gradient Scalar amount to interpolate
  82139. * @returns Interpolated scalar value
  82140. */
  82141. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82142. /**
  82143. * Interpolates a Vector3 cubically
  82144. * @param startValue Start value of the animation curve
  82145. * @param outTangent End tangent of the animation
  82146. * @param endValue End value of the animation curve
  82147. * @param inTangent Start tangent of the animation curve
  82148. * @param gradient Scalar amount to interpolate
  82149. * @returns InterpolatedVector3 value
  82150. */
  82151. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82152. /**
  82153. * Interpolates a Vector2 linearly
  82154. * @param startValue Start value of the animation curve
  82155. * @param endValue End value of the animation curve
  82156. * @param gradient Scalar amount to interpolate
  82157. * @returns Interpolated Vector2 value
  82158. */
  82159. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82160. /**
  82161. * Interpolates a Vector2 cubically
  82162. * @param startValue Start value of the animation curve
  82163. * @param outTangent End tangent of the animation
  82164. * @param endValue End value of the animation curve
  82165. * @param inTangent Start tangent of the animation curve
  82166. * @param gradient Scalar amount to interpolate
  82167. * @returns Interpolated Vector2 value
  82168. */
  82169. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82170. /**
  82171. * Interpolates a size linearly
  82172. * @param startValue Start value of the animation curve
  82173. * @param endValue End value of the animation curve
  82174. * @param gradient Scalar amount to interpolate
  82175. * @returns Interpolated Size value
  82176. */
  82177. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82178. /**
  82179. * Interpolates a Color3 linearly
  82180. * @param startValue Start value of the animation curve
  82181. * @param endValue End value of the animation curve
  82182. * @param gradient Scalar amount to interpolate
  82183. * @returns Interpolated Color3 value
  82184. */
  82185. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82186. /**
  82187. * @hidden Internal use only
  82188. */
  82189. _getKeyValue(value: any): any;
  82190. /**
  82191. * @hidden Internal use only
  82192. */
  82193. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82194. /**
  82195. * Defines the function to use to interpolate matrices
  82196. * @param startValue defines the start matrix
  82197. * @param endValue defines the end matrix
  82198. * @param gradient defines the gradient between both matrices
  82199. * @param result defines an optional target matrix where to store the interpolation
  82200. * @returns the interpolated matrix
  82201. */
  82202. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82203. /**
  82204. * Makes a copy of the animation
  82205. * @returns Cloned animation
  82206. */
  82207. clone(): Animation;
  82208. /**
  82209. * Sets the key frames of the animation
  82210. * @param values The animation key frames to set
  82211. */
  82212. setKeys(values: Array<IAnimationKey>): void;
  82213. /**
  82214. * Serializes the animation to an object
  82215. * @returns Serialized object
  82216. */
  82217. serialize(): any;
  82218. /**
  82219. * Float animation type
  82220. */
  82221. private static _ANIMATIONTYPE_FLOAT;
  82222. /**
  82223. * Vector3 animation type
  82224. */
  82225. private static _ANIMATIONTYPE_VECTOR3;
  82226. /**
  82227. * Quaternion animation type
  82228. */
  82229. private static _ANIMATIONTYPE_QUATERNION;
  82230. /**
  82231. * Matrix animation type
  82232. */
  82233. private static _ANIMATIONTYPE_MATRIX;
  82234. /**
  82235. * Color3 animation type
  82236. */
  82237. private static _ANIMATIONTYPE_COLOR3;
  82238. /**
  82239. * Vector2 animation type
  82240. */
  82241. private static _ANIMATIONTYPE_VECTOR2;
  82242. /**
  82243. * Size animation type
  82244. */
  82245. private static _ANIMATIONTYPE_SIZE;
  82246. /**
  82247. * Relative Loop Mode
  82248. */
  82249. private static _ANIMATIONLOOPMODE_RELATIVE;
  82250. /**
  82251. * Cycle Loop Mode
  82252. */
  82253. private static _ANIMATIONLOOPMODE_CYCLE;
  82254. /**
  82255. * Constant Loop Mode
  82256. */
  82257. private static _ANIMATIONLOOPMODE_CONSTANT;
  82258. /**
  82259. * Get the float animation type
  82260. */
  82261. static readonly ANIMATIONTYPE_FLOAT: number;
  82262. /**
  82263. * Get the Vector3 animation type
  82264. */
  82265. static readonly ANIMATIONTYPE_VECTOR3: number;
  82266. /**
  82267. * Get the Vector2 animation type
  82268. */
  82269. static readonly ANIMATIONTYPE_VECTOR2: number;
  82270. /**
  82271. * Get the Size animation type
  82272. */
  82273. static readonly ANIMATIONTYPE_SIZE: number;
  82274. /**
  82275. * Get the Quaternion animation type
  82276. */
  82277. static readonly ANIMATIONTYPE_QUATERNION: number;
  82278. /**
  82279. * Get the Matrix animation type
  82280. */
  82281. static readonly ANIMATIONTYPE_MATRIX: number;
  82282. /**
  82283. * Get the Color3 animation type
  82284. */
  82285. static readonly ANIMATIONTYPE_COLOR3: number;
  82286. /**
  82287. * Get the Relative Loop Mode
  82288. */
  82289. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82290. /**
  82291. * Get the Cycle Loop Mode
  82292. */
  82293. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82294. /**
  82295. * Get the Constant Loop Mode
  82296. */
  82297. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82298. /** @hidden */
  82299. static _UniversalLerp(left: any, right: any, amount: number): any;
  82300. /**
  82301. * Parses an animation object and creates an animation
  82302. * @param parsedAnimation Parsed animation object
  82303. * @returns Animation object
  82304. */
  82305. static Parse(parsedAnimation: any): Animation;
  82306. /**
  82307. * Appends the serialized animations from the source animations
  82308. * @param source Source containing the animations
  82309. * @param destination Target to store the animations
  82310. */
  82311. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82312. }
  82313. }
  82314. declare module BABYLON {
  82315. /**
  82316. * Base class of all the textures in babylon.
  82317. * It groups all the common properties the materials, post process, lights... might need
  82318. * in order to make a correct use of the texture.
  82319. */
  82320. export class BaseTexture implements IAnimatable {
  82321. /**
  82322. * Default anisotropic filtering level for the application.
  82323. * It is set to 4 as a good tradeoff between perf and quality.
  82324. */
  82325. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82326. /**
  82327. * Gets or sets the unique id of the texture
  82328. */
  82329. uniqueId: number;
  82330. /**
  82331. * Define the name of the texture.
  82332. */
  82333. name: string;
  82334. /**
  82335. * Gets or sets an object used to store user defined information.
  82336. */
  82337. metadata: any;
  82338. /**
  82339. * For internal use only. Please do not use.
  82340. */
  82341. reservedDataStore: any;
  82342. private _hasAlpha;
  82343. /**
  82344. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82345. */
  82346. hasAlpha: boolean;
  82347. /**
  82348. * Defines if the alpha value should be determined via the rgb values.
  82349. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82350. */
  82351. getAlphaFromRGB: boolean;
  82352. /**
  82353. * Intensity or strength of the texture.
  82354. * It is commonly used by materials to fine tune the intensity of the texture
  82355. */
  82356. level: number;
  82357. /**
  82358. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82359. * This is part of the texture as textures usually maps to one uv set.
  82360. */
  82361. coordinatesIndex: number;
  82362. private _coordinatesMode;
  82363. /**
  82364. * How a texture is mapped.
  82365. *
  82366. * | Value | Type | Description |
  82367. * | ----- | ----------------------------------- | ----------- |
  82368. * | 0 | EXPLICIT_MODE | |
  82369. * | 1 | SPHERICAL_MODE | |
  82370. * | 2 | PLANAR_MODE | |
  82371. * | 3 | CUBIC_MODE | |
  82372. * | 4 | PROJECTION_MODE | |
  82373. * | 5 | SKYBOX_MODE | |
  82374. * | 6 | INVCUBIC_MODE | |
  82375. * | 7 | EQUIRECTANGULAR_MODE | |
  82376. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82377. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82378. */
  82379. coordinatesMode: number;
  82380. /**
  82381. * | Value | Type | Description |
  82382. * | ----- | ------------------ | ----------- |
  82383. * | 0 | CLAMP_ADDRESSMODE | |
  82384. * | 1 | WRAP_ADDRESSMODE | |
  82385. * | 2 | MIRROR_ADDRESSMODE | |
  82386. */
  82387. wrapU: number;
  82388. /**
  82389. * | Value | Type | Description |
  82390. * | ----- | ------------------ | ----------- |
  82391. * | 0 | CLAMP_ADDRESSMODE | |
  82392. * | 1 | WRAP_ADDRESSMODE | |
  82393. * | 2 | MIRROR_ADDRESSMODE | |
  82394. */
  82395. wrapV: number;
  82396. /**
  82397. * | Value | Type | Description |
  82398. * | ----- | ------------------ | ----------- |
  82399. * | 0 | CLAMP_ADDRESSMODE | |
  82400. * | 1 | WRAP_ADDRESSMODE | |
  82401. * | 2 | MIRROR_ADDRESSMODE | |
  82402. */
  82403. wrapR: number;
  82404. /**
  82405. * With compliant hardware and browser (supporting anisotropic filtering)
  82406. * this defines the level of anisotropic filtering in the texture.
  82407. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82408. */
  82409. anisotropicFilteringLevel: number;
  82410. /**
  82411. * Define if the texture is a cube texture or if false a 2d texture.
  82412. */
  82413. isCube: boolean;
  82414. /**
  82415. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82416. */
  82417. is3D: boolean;
  82418. /**
  82419. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82420. * HDR texture are usually stored in linear space.
  82421. * This only impacts the PBR and Background materials
  82422. */
  82423. gammaSpace: boolean;
  82424. /**
  82425. * Gets whether or not the texture contains RGBD data.
  82426. */
  82427. readonly isRGBD: boolean;
  82428. /**
  82429. * Is Z inverted in the texture (useful in a cube texture).
  82430. */
  82431. invertZ: boolean;
  82432. /**
  82433. * Are mip maps generated for this texture or not.
  82434. */
  82435. readonly noMipmap: boolean;
  82436. /**
  82437. * @hidden
  82438. */
  82439. lodLevelInAlpha: boolean;
  82440. /**
  82441. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82442. */
  82443. lodGenerationOffset: number;
  82444. /**
  82445. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82446. */
  82447. lodGenerationScale: number;
  82448. /**
  82449. * Define if the texture is a render target.
  82450. */
  82451. isRenderTarget: boolean;
  82452. /**
  82453. * Define the unique id of the texture in the scene.
  82454. */
  82455. readonly uid: string;
  82456. /**
  82457. * Return a string representation of the texture.
  82458. * @returns the texture as a string
  82459. */
  82460. toString(): string;
  82461. /**
  82462. * Get the class name of the texture.
  82463. * @returns "BaseTexture"
  82464. */
  82465. getClassName(): string;
  82466. /**
  82467. * Define the list of animation attached to the texture.
  82468. */
  82469. animations: Animation[];
  82470. /**
  82471. * An event triggered when the texture is disposed.
  82472. */
  82473. onDisposeObservable: Observable<BaseTexture>;
  82474. private _onDisposeObserver;
  82475. /**
  82476. * Callback triggered when the texture has been disposed.
  82477. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82478. */
  82479. onDispose: () => void;
  82480. /**
  82481. * Define the current state of the loading sequence when in delayed load mode.
  82482. */
  82483. delayLoadState: number;
  82484. private _scene;
  82485. /** @hidden */
  82486. _texture: Nullable<InternalTexture>;
  82487. private _uid;
  82488. /**
  82489. * Define if the texture is preventinga material to render or not.
  82490. * If not and the texture is not ready, the engine will use a default black texture instead.
  82491. */
  82492. readonly isBlocking: boolean;
  82493. /**
  82494. * Instantiates a new BaseTexture.
  82495. * Base class of all the textures in babylon.
  82496. * It groups all the common properties the materials, post process, lights... might need
  82497. * in order to make a correct use of the texture.
  82498. * @param scene Define the scene the texture blongs to
  82499. */
  82500. constructor(scene: Nullable<Scene>);
  82501. /**
  82502. * Get the scene the texture belongs to.
  82503. * @returns the scene or null if undefined
  82504. */
  82505. getScene(): Nullable<Scene>;
  82506. /**
  82507. * Get the texture transform matrix used to offset tile the texture for istance.
  82508. * @returns the transformation matrix
  82509. */
  82510. getTextureMatrix(): Matrix;
  82511. /**
  82512. * Get the texture reflection matrix used to rotate/transform the reflection.
  82513. * @returns the reflection matrix
  82514. */
  82515. getReflectionTextureMatrix(): Matrix;
  82516. /**
  82517. * Get the underlying lower level texture from Babylon.
  82518. * @returns the insternal texture
  82519. */
  82520. getInternalTexture(): Nullable<InternalTexture>;
  82521. /**
  82522. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82523. * @returns true if ready or not blocking
  82524. */
  82525. isReadyOrNotBlocking(): boolean;
  82526. /**
  82527. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82528. * @returns true if fully ready
  82529. */
  82530. isReady(): boolean;
  82531. private _cachedSize;
  82532. /**
  82533. * Get the size of the texture.
  82534. * @returns the texture size.
  82535. */
  82536. getSize(): ISize;
  82537. /**
  82538. * Get the base size of the texture.
  82539. * It can be different from the size if the texture has been resized for POT for instance
  82540. * @returns the base size
  82541. */
  82542. getBaseSize(): ISize;
  82543. /**
  82544. * Update the sampling mode of the texture.
  82545. * Default is Trilinear mode.
  82546. *
  82547. * | Value | Type | Description |
  82548. * | ----- | ------------------ | ----------- |
  82549. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82550. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82551. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82552. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82553. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82554. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82555. * | 7 | NEAREST_LINEAR | |
  82556. * | 8 | NEAREST_NEAREST | |
  82557. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82558. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82559. * | 11 | LINEAR_LINEAR | |
  82560. * | 12 | LINEAR_NEAREST | |
  82561. *
  82562. * > _mag_: magnification filter (close to the viewer)
  82563. * > _min_: minification filter (far from the viewer)
  82564. * > _mip_: filter used between mip map levels
  82565. *@param samplingMode Define the new sampling mode of the texture
  82566. */
  82567. updateSamplingMode(samplingMode: number): void;
  82568. /**
  82569. * Scales the texture if is `canRescale()`
  82570. * @param ratio the resize factor we want to use to rescale
  82571. */
  82572. scale(ratio: number): void;
  82573. /**
  82574. * Get if the texture can rescale.
  82575. */
  82576. readonly canRescale: boolean;
  82577. /** @hidden */
  82578. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82579. /** @hidden */
  82580. _rebuild(): void;
  82581. /**
  82582. * Triggers the load sequence in delayed load mode.
  82583. */
  82584. delayLoad(): void;
  82585. /**
  82586. * Clones the texture.
  82587. * @returns the cloned texture
  82588. */
  82589. clone(): Nullable<BaseTexture>;
  82590. /**
  82591. * Get the texture underlying type (INT, FLOAT...)
  82592. */
  82593. readonly textureType: number;
  82594. /**
  82595. * Get the texture underlying format (RGB, RGBA...)
  82596. */
  82597. readonly textureFormat: number;
  82598. /**
  82599. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82600. * This will returns an RGBA array buffer containing either in values (0-255) or
  82601. * float values (0-1) depending of the underlying buffer type.
  82602. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82603. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82604. * @param buffer defines a user defined buffer to fill with data (can be null)
  82605. * @returns The Array buffer containing the pixels data.
  82606. */
  82607. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82608. /**
  82609. * Release and destroy the underlying lower level texture aka internalTexture.
  82610. */
  82611. releaseInternalTexture(): void;
  82612. /**
  82613. * Get the polynomial representation of the texture data.
  82614. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82615. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82616. */
  82617. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82618. /** @hidden */
  82619. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82620. /** @hidden */
  82621. readonly _lodTextureMid: Nullable<BaseTexture>;
  82622. /** @hidden */
  82623. readonly _lodTextureLow: Nullable<BaseTexture>;
  82624. /**
  82625. * Dispose the texture and release its associated resources.
  82626. */
  82627. dispose(): void;
  82628. /**
  82629. * Serialize the texture into a JSON representation that can be parsed later on.
  82630. * @returns the JSON representation of the texture
  82631. */
  82632. serialize(): any;
  82633. /**
  82634. * Helper function to be called back once a list of texture contains only ready textures.
  82635. * @param textures Define the list of textures to wait for
  82636. * @param callback Define the callback triggered once the entire list will be ready
  82637. */
  82638. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82639. }
  82640. }
  82641. declare module BABYLON {
  82642. /**
  82643. * Uniform buffer objects.
  82644. *
  82645. * Handles blocks of uniform on the GPU.
  82646. *
  82647. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82648. *
  82649. * For more information, please refer to :
  82650. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82651. */
  82652. export class UniformBuffer {
  82653. private _engine;
  82654. private _buffer;
  82655. private _data;
  82656. private _bufferData;
  82657. private _dynamic?;
  82658. private _uniformLocations;
  82659. private _uniformSizes;
  82660. private _uniformLocationPointer;
  82661. private _needSync;
  82662. private _noUBO;
  82663. private _currentEffect;
  82664. private static _MAX_UNIFORM_SIZE;
  82665. private static _tempBuffer;
  82666. /**
  82667. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82668. * This is dynamic to allow compat with webgl 1 and 2.
  82669. * You will need to pass the name of the uniform as well as the value.
  82670. */
  82671. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82672. /**
  82673. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82674. * This is dynamic to allow compat with webgl 1 and 2.
  82675. * You will need to pass the name of the uniform as well as the value.
  82676. */
  82677. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82678. /**
  82679. * Lambda to Update a single float in a uniform buffer.
  82680. * This is dynamic to allow compat with webgl 1 and 2.
  82681. * You will need to pass the name of the uniform as well as the value.
  82682. */
  82683. updateFloat: (name: string, x: number) => void;
  82684. /**
  82685. * Lambda to Update a vec2 of float in a uniform buffer.
  82686. * This is dynamic to allow compat with webgl 1 and 2.
  82687. * You will need to pass the name of the uniform as well as the value.
  82688. */
  82689. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82690. /**
  82691. * Lambda to Update a vec3 of float in a uniform buffer.
  82692. * This is dynamic to allow compat with webgl 1 and 2.
  82693. * You will need to pass the name of the uniform as well as the value.
  82694. */
  82695. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82696. /**
  82697. * Lambda to Update a vec4 of float in a uniform buffer.
  82698. * This is dynamic to allow compat with webgl 1 and 2.
  82699. * You will need to pass the name of the uniform as well as the value.
  82700. */
  82701. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82702. /**
  82703. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82704. * This is dynamic to allow compat with webgl 1 and 2.
  82705. * You will need to pass the name of the uniform as well as the value.
  82706. */
  82707. updateMatrix: (name: string, mat: Matrix) => void;
  82708. /**
  82709. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82710. * This is dynamic to allow compat with webgl 1 and 2.
  82711. * You will need to pass the name of the uniform as well as the value.
  82712. */
  82713. updateVector3: (name: string, vector: Vector3) => void;
  82714. /**
  82715. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82716. * This is dynamic to allow compat with webgl 1 and 2.
  82717. * You will need to pass the name of the uniform as well as the value.
  82718. */
  82719. updateVector4: (name: string, vector: Vector4) => void;
  82720. /**
  82721. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82722. * This is dynamic to allow compat with webgl 1 and 2.
  82723. * You will need to pass the name of the uniform as well as the value.
  82724. */
  82725. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82726. /**
  82727. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82728. * This is dynamic to allow compat with webgl 1 and 2.
  82729. * You will need to pass the name of the uniform as well as the value.
  82730. */
  82731. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82732. /**
  82733. * Instantiates a new Uniform buffer objects.
  82734. *
  82735. * Handles blocks of uniform on the GPU.
  82736. *
  82737. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82738. *
  82739. * For more information, please refer to :
  82740. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82741. * @param engine Define the engine the buffer is associated with
  82742. * @param data Define the data contained in the buffer
  82743. * @param dynamic Define if the buffer is updatable
  82744. */
  82745. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82746. /**
  82747. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82748. * or just falling back on setUniformXXX calls.
  82749. */
  82750. readonly useUbo: boolean;
  82751. /**
  82752. * Indicates if the WebGL underlying uniform buffer is in sync
  82753. * with the javascript cache data.
  82754. */
  82755. readonly isSync: boolean;
  82756. /**
  82757. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82758. * Also, a dynamic UniformBuffer will disable cache verification and always
  82759. * update the underlying WebGL uniform buffer to the GPU.
  82760. * @returns if Dynamic, otherwise false
  82761. */
  82762. isDynamic(): boolean;
  82763. /**
  82764. * The data cache on JS side.
  82765. * @returns the underlying data as a float array
  82766. */
  82767. getData(): Float32Array;
  82768. /**
  82769. * The underlying WebGL Uniform buffer.
  82770. * @returns the webgl buffer
  82771. */
  82772. getBuffer(): Nullable<WebGLBuffer>;
  82773. /**
  82774. * std140 layout specifies how to align data within an UBO structure.
  82775. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82776. * for specs.
  82777. */
  82778. private _fillAlignment;
  82779. /**
  82780. * Adds an uniform in the buffer.
  82781. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82782. * for the layout to be correct !
  82783. * @param name Name of the uniform, as used in the uniform block in the shader.
  82784. * @param size Data size, or data directly.
  82785. */
  82786. addUniform(name: string, size: number | number[]): void;
  82787. /**
  82788. * Adds a Matrix 4x4 to the uniform buffer.
  82789. * @param name Name of the uniform, as used in the uniform block in the shader.
  82790. * @param mat A 4x4 matrix.
  82791. */
  82792. addMatrix(name: string, mat: Matrix): void;
  82793. /**
  82794. * Adds a vec2 to the uniform buffer.
  82795. * @param name Name of the uniform, as used in the uniform block in the shader.
  82796. * @param x Define the x component value of the vec2
  82797. * @param y Define the y component value of the vec2
  82798. */
  82799. addFloat2(name: string, x: number, y: number): void;
  82800. /**
  82801. * Adds a vec3 to the uniform buffer.
  82802. * @param name Name of the uniform, as used in the uniform block in the shader.
  82803. * @param x Define the x component value of the vec3
  82804. * @param y Define the y component value of the vec3
  82805. * @param z Define the z component value of the vec3
  82806. */
  82807. addFloat3(name: string, x: number, y: number, z: number): void;
  82808. /**
  82809. * Adds a vec3 to the uniform buffer.
  82810. * @param name Name of the uniform, as used in the uniform block in the shader.
  82811. * @param color Define the vec3 from a Color
  82812. */
  82813. addColor3(name: string, color: Color3): void;
  82814. /**
  82815. * Adds a vec4 to the uniform buffer.
  82816. * @param name Name of the uniform, as used in the uniform block in the shader.
  82817. * @param color Define the rgb components from a Color
  82818. * @param alpha Define the a component of the vec4
  82819. */
  82820. addColor4(name: string, color: Color3, alpha: number): void;
  82821. /**
  82822. * Adds a vec3 to the uniform buffer.
  82823. * @param name Name of the uniform, as used in the uniform block in the shader.
  82824. * @param vector Define the vec3 components from a Vector
  82825. */
  82826. addVector3(name: string, vector: Vector3): void;
  82827. /**
  82828. * Adds a Matrix 3x3 to the uniform buffer.
  82829. * @param name Name of the uniform, as used in the uniform block in the shader.
  82830. */
  82831. addMatrix3x3(name: string): void;
  82832. /**
  82833. * Adds a Matrix 2x2 to the uniform buffer.
  82834. * @param name Name of the uniform, as used in the uniform block in the shader.
  82835. */
  82836. addMatrix2x2(name: string): void;
  82837. /**
  82838. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82839. */
  82840. create(): void;
  82841. /** @hidden */
  82842. _rebuild(): void;
  82843. /**
  82844. * Updates the WebGL Uniform Buffer on the GPU.
  82845. * If the `dynamic` flag is set to true, no cache comparison is done.
  82846. * Otherwise, the buffer will be updated only if the cache differs.
  82847. */
  82848. update(): void;
  82849. /**
  82850. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82851. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82852. * @param data Define the flattened data
  82853. * @param size Define the size of the data.
  82854. */
  82855. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82856. private _updateMatrix3x3ForUniform;
  82857. private _updateMatrix3x3ForEffect;
  82858. private _updateMatrix2x2ForEffect;
  82859. private _updateMatrix2x2ForUniform;
  82860. private _updateFloatForEffect;
  82861. private _updateFloatForUniform;
  82862. private _updateFloat2ForEffect;
  82863. private _updateFloat2ForUniform;
  82864. private _updateFloat3ForEffect;
  82865. private _updateFloat3ForUniform;
  82866. private _updateFloat4ForEffect;
  82867. private _updateFloat4ForUniform;
  82868. private _updateMatrixForEffect;
  82869. private _updateMatrixForUniform;
  82870. private _updateVector3ForEffect;
  82871. private _updateVector3ForUniform;
  82872. private _updateVector4ForEffect;
  82873. private _updateVector4ForUniform;
  82874. private _updateColor3ForEffect;
  82875. private _updateColor3ForUniform;
  82876. private _updateColor4ForEffect;
  82877. private _updateColor4ForUniform;
  82878. /**
  82879. * Sets a sampler uniform on the effect.
  82880. * @param name Define the name of the sampler.
  82881. * @param texture Define the texture to set in the sampler
  82882. */
  82883. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82884. /**
  82885. * Directly updates the value of the uniform in the cache AND on the GPU.
  82886. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82887. * @param data Define the flattened data
  82888. */
  82889. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82890. /**
  82891. * Binds this uniform buffer to an effect.
  82892. * @param effect Define the effect to bind the buffer to
  82893. * @param name Name of the uniform block in the shader.
  82894. */
  82895. bindToEffect(effect: Effect, name: string): void;
  82896. /**
  82897. * Disposes the uniform buffer.
  82898. */
  82899. dispose(): void;
  82900. }
  82901. }
  82902. declare module BABYLON {
  82903. /**
  82904. * This represents the required contract to create a new type of texture loader.
  82905. */
  82906. export interface IInternalTextureLoader {
  82907. /**
  82908. * Defines wether the loader supports cascade loading the different faces.
  82909. */
  82910. supportCascades: boolean;
  82911. /**
  82912. * This returns if the loader support the current file information.
  82913. * @param extension defines the file extension of the file being loaded
  82914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82915. * @param fallback defines the fallback internal texture if any
  82916. * @param isBase64 defines whether the texture is encoded as a base64
  82917. * @param isBuffer defines whether the texture data are stored as a buffer
  82918. * @returns true if the loader can load the specified file
  82919. */
  82920. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82921. /**
  82922. * Transform the url before loading if required.
  82923. * @param rootUrl the url of the texture
  82924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82925. * @returns the transformed texture
  82926. */
  82927. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82928. /**
  82929. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82930. * @param rootUrl the url of the texture
  82931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82932. * @returns the fallback texture
  82933. */
  82934. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82935. /**
  82936. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82937. * @param data contains the texture data
  82938. * @param texture defines the BabylonJS internal texture
  82939. * @param createPolynomials will be true if polynomials have been requested
  82940. * @param onLoad defines the callback to trigger once the texture is ready
  82941. * @param onError defines the callback to trigger in case of error
  82942. */
  82943. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82944. /**
  82945. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82946. * @param data contains the texture data
  82947. * @param texture defines the BabylonJS internal texture
  82948. * @param callback defines the method to call once ready to upload
  82949. */
  82950. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82951. }
  82952. }
  82953. declare module BABYLON {
  82954. /**
  82955. * Creation options of the multi render target texture.
  82956. */
  82957. export interface IMultiRenderTargetOptions {
  82958. /**
  82959. * Define if the texture needs to create mip maps after render.
  82960. */
  82961. generateMipMaps?: boolean;
  82962. /**
  82963. * Define the types of all the draw buffers we want to create
  82964. */
  82965. types?: number[];
  82966. /**
  82967. * Define the sampling modes of all the draw buffers we want to create
  82968. */
  82969. samplingModes?: number[];
  82970. /**
  82971. * Define if a depth buffer is required
  82972. */
  82973. generateDepthBuffer?: boolean;
  82974. /**
  82975. * Define if a stencil buffer is required
  82976. */
  82977. generateStencilBuffer?: boolean;
  82978. /**
  82979. * Define if a depth texture is required instead of a depth buffer
  82980. */
  82981. generateDepthTexture?: boolean;
  82982. /**
  82983. * Define the number of desired draw buffers
  82984. */
  82985. textureCount?: number;
  82986. /**
  82987. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82988. */
  82989. doNotChangeAspectRatio?: boolean;
  82990. /**
  82991. * Define the default type of the buffers we are creating
  82992. */
  82993. defaultType?: number;
  82994. }
  82995. /**
  82996. * A multi render target, like a render target provides the ability to render to a texture.
  82997. * Unlike the render target, it can render to several draw buffers in one draw.
  82998. * This is specially interesting in deferred rendering or for any effects requiring more than
  82999. * just one color from a single pass.
  83000. */
  83001. export class MultiRenderTarget extends RenderTargetTexture {
  83002. private _internalTextures;
  83003. private _textures;
  83004. private _multiRenderTargetOptions;
  83005. /**
  83006. * Get if draw buffers are currently supported by the used hardware and browser.
  83007. */
  83008. readonly isSupported: boolean;
  83009. /**
  83010. * Get the list of textures generated by the multi render target.
  83011. */
  83012. readonly textures: Texture[];
  83013. /**
  83014. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83015. */
  83016. readonly depthTexture: Texture;
  83017. /**
  83018. * Set the wrapping mode on U of all the textures we are rendering to.
  83019. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83020. */
  83021. wrapU: number;
  83022. /**
  83023. * Set the wrapping mode on V of all the textures we are rendering to.
  83024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83025. */
  83026. wrapV: number;
  83027. /**
  83028. * Instantiate a new multi render target texture.
  83029. * A multi render target, like a render target provides the ability to render to a texture.
  83030. * Unlike the render target, it can render to several draw buffers in one draw.
  83031. * This is specially interesting in deferred rendering or for any effects requiring more than
  83032. * just one color from a single pass.
  83033. * @param name Define the name of the texture
  83034. * @param size Define the size of the buffers to render to
  83035. * @param count Define the number of target we are rendering into
  83036. * @param scene Define the scene the texture belongs to
  83037. * @param options Define the options used to create the multi render target
  83038. */
  83039. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83040. /** @hidden */
  83041. _rebuild(): void;
  83042. private _createInternalTextures;
  83043. private _createTextures;
  83044. /**
  83045. * Define the number of samples used if MSAA is enabled.
  83046. */
  83047. samples: number;
  83048. /**
  83049. * Resize all the textures in the multi render target.
  83050. * Be carrefull as it will recreate all the data in the new texture.
  83051. * @param size Define the new size
  83052. */
  83053. resize(size: any): void;
  83054. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83055. /**
  83056. * Dispose the render targets and their associated resources
  83057. */
  83058. dispose(): void;
  83059. /**
  83060. * Release all the underlying texture used as draw buffers.
  83061. */
  83062. releaseInternalTextures(): void;
  83063. }
  83064. }
  83065. declare module BABYLON {
  83066. /**
  83067. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83069. */
  83070. export class Analyser {
  83071. /**
  83072. * Gets or sets the smoothing
  83073. * @ignorenaming
  83074. */
  83075. SMOOTHING: number;
  83076. /**
  83077. * Gets or sets the FFT table size
  83078. * @ignorenaming
  83079. */
  83080. FFT_SIZE: number;
  83081. /**
  83082. * Gets or sets the bar graph amplitude
  83083. * @ignorenaming
  83084. */
  83085. BARGRAPHAMPLITUDE: number;
  83086. /**
  83087. * Gets or sets the position of the debug canvas
  83088. * @ignorenaming
  83089. */
  83090. DEBUGCANVASPOS: {
  83091. x: number;
  83092. y: number;
  83093. };
  83094. /**
  83095. * Gets or sets the debug canvas size
  83096. * @ignorenaming
  83097. */
  83098. DEBUGCANVASSIZE: {
  83099. width: number;
  83100. height: number;
  83101. };
  83102. private _byteFreqs;
  83103. private _byteTime;
  83104. private _floatFreqs;
  83105. private _webAudioAnalyser;
  83106. private _debugCanvas;
  83107. private _debugCanvasContext;
  83108. private _scene;
  83109. private _registerFunc;
  83110. private _audioEngine;
  83111. /**
  83112. * Creates a new analyser
  83113. * @param scene defines hosting scene
  83114. */
  83115. constructor(scene: Scene);
  83116. /**
  83117. * Get the number of data values you will have to play with for the visualization
  83118. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83119. * @returns a number
  83120. */
  83121. getFrequencyBinCount(): number;
  83122. /**
  83123. * Gets the current frequency data as a byte array
  83124. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83125. * @returns a Uint8Array
  83126. */
  83127. getByteFrequencyData(): Uint8Array;
  83128. /**
  83129. * Gets the current waveform as a byte array
  83130. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83131. * @returns a Uint8Array
  83132. */
  83133. getByteTimeDomainData(): Uint8Array;
  83134. /**
  83135. * Gets the current frequency data as a float array
  83136. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83137. * @returns a Float32Array
  83138. */
  83139. getFloatFrequencyData(): Float32Array;
  83140. /**
  83141. * Renders the debug canvas
  83142. */
  83143. drawDebugCanvas(): void;
  83144. /**
  83145. * Stops rendering the debug canvas and removes it
  83146. */
  83147. stopDebugCanvas(): void;
  83148. /**
  83149. * Connects two audio nodes
  83150. * @param inputAudioNode defines first node to connect
  83151. * @param outputAudioNode defines second node to connect
  83152. */
  83153. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83154. /**
  83155. * Releases all associated resources
  83156. */
  83157. dispose(): void;
  83158. }
  83159. }
  83160. declare module BABYLON {
  83161. /**
  83162. * This represents an audio engine and it is responsible
  83163. * to play, synchronize and analyse sounds throughout the application.
  83164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83165. */
  83166. export interface IAudioEngine extends IDisposable {
  83167. /**
  83168. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83169. */
  83170. readonly canUseWebAudio: boolean;
  83171. /**
  83172. * Gets the current AudioContext if available.
  83173. */
  83174. readonly audioContext: Nullable<AudioContext>;
  83175. /**
  83176. * The master gain node defines the global audio volume of your audio engine.
  83177. */
  83178. readonly masterGain: GainNode;
  83179. /**
  83180. * Gets whether or not mp3 are supported by your browser.
  83181. */
  83182. readonly isMP3supported: boolean;
  83183. /**
  83184. * Gets whether or not ogg are supported by your browser.
  83185. */
  83186. readonly isOGGsupported: boolean;
  83187. /**
  83188. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83189. * @ignoreNaming
  83190. */
  83191. WarnedWebAudioUnsupported: boolean;
  83192. /**
  83193. * Defines if the audio engine relies on a custom unlocked button.
  83194. * In this case, the embedded button will not be displayed.
  83195. */
  83196. useCustomUnlockedButton: boolean;
  83197. /**
  83198. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83199. */
  83200. readonly unlocked: boolean;
  83201. /**
  83202. * Event raised when audio has been unlocked on the browser.
  83203. */
  83204. onAudioUnlockedObservable: Observable<AudioEngine>;
  83205. /**
  83206. * Event raised when audio has been locked on the browser.
  83207. */
  83208. onAudioLockedObservable: Observable<AudioEngine>;
  83209. /**
  83210. * Flags the audio engine in Locked state.
  83211. * This happens due to new browser policies preventing audio to autoplay.
  83212. */
  83213. lock(): void;
  83214. /**
  83215. * Unlocks the audio engine once a user action has been done on the dom.
  83216. * This is helpful to resume play once browser policies have been satisfied.
  83217. */
  83218. unlock(): void;
  83219. }
  83220. /**
  83221. * This represents the default audio engine used in babylon.
  83222. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83224. */
  83225. export class AudioEngine implements IAudioEngine {
  83226. private _audioContext;
  83227. private _audioContextInitialized;
  83228. private _muteButton;
  83229. private _hostElement;
  83230. /**
  83231. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83232. */
  83233. canUseWebAudio: boolean;
  83234. /**
  83235. * The master gain node defines the global audio volume of your audio engine.
  83236. */
  83237. masterGain: GainNode;
  83238. /**
  83239. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83240. * @ignoreNaming
  83241. */
  83242. WarnedWebAudioUnsupported: boolean;
  83243. /**
  83244. * Gets whether or not mp3 are supported by your browser.
  83245. */
  83246. isMP3supported: boolean;
  83247. /**
  83248. * Gets whether or not ogg are supported by your browser.
  83249. */
  83250. isOGGsupported: boolean;
  83251. /**
  83252. * Gets whether audio has been unlocked on the device.
  83253. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83254. * a user interaction has happened.
  83255. */
  83256. unlocked: boolean;
  83257. /**
  83258. * Defines if the audio engine relies on a custom unlocked button.
  83259. * In this case, the embedded button will not be displayed.
  83260. */
  83261. useCustomUnlockedButton: boolean;
  83262. /**
  83263. * Event raised when audio has been unlocked on the browser.
  83264. */
  83265. onAudioUnlockedObservable: Observable<AudioEngine>;
  83266. /**
  83267. * Event raised when audio has been locked on the browser.
  83268. */
  83269. onAudioLockedObservable: Observable<AudioEngine>;
  83270. /**
  83271. * Gets the current AudioContext if available.
  83272. */
  83273. readonly audioContext: Nullable<AudioContext>;
  83274. private _connectedAnalyser;
  83275. /**
  83276. * Instantiates a new audio engine.
  83277. *
  83278. * There should be only one per page as some browsers restrict the number
  83279. * of audio contexts you can create.
  83280. * @param hostElement defines the host element where to display the mute icon if necessary
  83281. */
  83282. constructor(hostElement?: Nullable<HTMLElement>);
  83283. /**
  83284. * Flags the audio engine in Locked state.
  83285. * This happens due to new browser policies preventing audio to autoplay.
  83286. */
  83287. lock(): void;
  83288. /**
  83289. * Unlocks the audio engine once a user action has been done on the dom.
  83290. * This is helpful to resume play once browser policies have been satisfied.
  83291. */
  83292. unlock(): void;
  83293. private _resumeAudioContext;
  83294. private _initializeAudioContext;
  83295. private _tryToRun;
  83296. private _triggerRunningState;
  83297. private _triggerSuspendedState;
  83298. private _displayMuteButton;
  83299. private _moveButtonToTopLeft;
  83300. private _onResize;
  83301. private _hideMuteButton;
  83302. /**
  83303. * Destroy and release the resources associated with the audio ccontext.
  83304. */
  83305. dispose(): void;
  83306. /**
  83307. * Gets the global volume sets on the master gain.
  83308. * @returns the global volume if set or -1 otherwise
  83309. */
  83310. getGlobalVolume(): number;
  83311. /**
  83312. * Sets the global volume of your experience (sets on the master gain).
  83313. * @param newVolume Defines the new global volume of the application
  83314. */
  83315. setGlobalVolume(newVolume: number): void;
  83316. /**
  83317. * Connect the audio engine to an audio analyser allowing some amazing
  83318. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83320. * @param analyser The analyser to connect to the engine
  83321. */
  83322. connectToAnalyser(analyser: Analyser): void;
  83323. }
  83324. }
  83325. declare module BABYLON {
  83326. /**
  83327. * Interface used to present a loading screen while loading a scene
  83328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83329. */
  83330. export interface ILoadingScreen {
  83331. /**
  83332. * Function called to display the loading screen
  83333. */
  83334. displayLoadingUI: () => void;
  83335. /**
  83336. * Function called to hide the loading screen
  83337. */
  83338. hideLoadingUI: () => void;
  83339. /**
  83340. * Gets or sets the color to use for the background
  83341. */
  83342. loadingUIBackgroundColor: string;
  83343. /**
  83344. * Gets or sets the text to display while loading
  83345. */
  83346. loadingUIText: string;
  83347. }
  83348. /**
  83349. * Class used for the default loading screen
  83350. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83351. */
  83352. export class DefaultLoadingScreen implements ILoadingScreen {
  83353. private _renderingCanvas;
  83354. private _loadingText;
  83355. private _loadingDivBackgroundColor;
  83356. private _loadingDiv;
  83357. private _loadingTextDiv;
  83358. /**
  83359. * Creates a new default loading screen
  83360. * @param _renderingCanvas defines the canvas used to render the scene
  83361. * @param _loadingText defines the default text to display
  83362. * @param _loadingDivBackgroundColor defines the default background color
  83363. */
  83364. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83365. /**
  83366. * Function called to display the loading screen
  83367. */
  83368. displayLoadingUI(): void;
  83369. /**
  83370. * Function called to hide the loading screen
  83371. */
  83372. hideLoadingUI(): void;
  83373. /**
  83374. * Gets or sets the text to display while loading
  83375. */
  83376. loadingUIText: string;
  83377. /**
  83378. * Gets or sets the color to use for the background
  83379. */
  83380. loadingUIBackgroundColor: string;
  83381. private _resizeLoadingUI;
  83382. }
  83383. }
  83384. declare module BABYLON {
  83385. /**
  83386. * Settings for finer control over video usage
  83387. */
  83388. export interface VideoTextureSettings {
  83389. /**
  83390. * Applies `autoplay` to video, if specified
  83391. */
  83392. autoPlay?: boolean;
  83393. /**
  83394. * Applies `loop` to video, if specified
  83395. */
  83396. loop?: boolean;
  83397. /**
  83398. * Automatically updates internal texture from video at every frame in the render loop
  83399. */
  83400. autoUpdateTexture: boolean;
  83401. /**
  83402. * Image src displayed during the video loading or until the user interacts with the video.
  83403. */
  83404. poster?: string;
  83405. }
  83406. /**
  83407. * If you want to display a video in your scene, this is the special texture for that.
  83408. * This special texture works similar to other textures, with the exception of a few parameters.
  83409. * @see https://doc.babylonjs.com/how_to/video_texture
  83410. */
  83411. export class VideoTexture extends Texture {
  83412. /**
  83413. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83414. */
  83415. readonly autoUpdateTexture: boolean;
  83416. /**
  83417. * The video instance used by the texture internally
  83418. */
  83419. readonly video: HTMLVideoElement;
  83420. private _onUserActionRequestedObservable;
  83421. /**
  83422. * Event triggerd when a dom action is required by the user to play the video.
  83423. * This happens due to recent changes in browser policies preventing video to auto start.
  83424. */
  83425. readonly onUserActionRequestedObservable: Observable<Texture>;
  83426. private _generateMipMaps;
  83427. private _engine;
  83428. private _stillImageCaptured;
  83429. private _displayingPosterTexture;
  83430. private _settings;
  83431. private _createInternalTextureOnEvent;
  83432. /**
  83433. * Creates a video texture.
  83434. * If you want to display a video in your scene, this is the special texture for that.
  83435. * This special texture works similar to other textures, with the exception of a few parameters.
  83436. * @see https://doc.babylonjs.com/how_to/video_texture
  83437. * @param name optional name, will detect from video source, if not defined
  83438. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83439. * @param scene is obviously the current scene.
  83440. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83441. * @param invertY is false by default but can be used to invert video on Y axis
  83442. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83443. * @param settings allows finer control over video usage
  83444. */
  83445. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83446. private _getName;
  83447. private _getVideo;
  83448. private _createInternalTexture;
  83449. private reset;
  83450. /**
  83451. * @hidden Internal method to initiate `update`.
  83452. */
  83453. _rebuild(): void;
  83454. /**
  83455. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83456. */
  83457. update(): void;
  83458. /**
  83459. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83460. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83461. */
  83462. updateTexture(isVisible: boolean): void;
  83463. protected _updateInternalTexture: () => void;
  83464. /**
  83465. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83466. * @param url New url.
  83467. */
  83468. updateURL(url: string): void;
  83469. /**
  83470. * Dispose the texture and release its associated resources.
  83471. */
  83472. dispose(): void;
  83473. /**
  83474. * Creates a video texture straight from a stream.
  83475. * @param scene Define the scene the texture should be created in
  83476. * @param stream Define the stream the texture should be created from
  83477. * @returns The created video texture as a promise
  83478. */
  83479. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83480. /**
  83481. * Creates a video texture straight from your WebCam video feed.
  83482. * @param scene Define the scene the texture should be created in
  83483. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83484. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83485. * @returns The created video texture as a promise
  83486. */
  83487. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83488. minWidth: number;
  83489. maxWidth: number;
  83490. minHeight: number;
  83491. maxHeight: number;
  83492. deviceId: string;
  83493. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83494. /**
  83495. * Creates a video texture straight from your WebCam video feed.
  83496. * @param scene Define the scene the texture should be created in
  83497. * @param onReady Define a callback to triggered once the texture will be ready
  83498. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83499. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83500. */
  83501. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83502. minWidth: number;
  83503. maxWidth: number;
  83504. minHeight: number;
  83505. maxHeight: number;
  83506. deviceId: string;
  83507. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83508. }
  83509. }
  83510. declare module BABYLON {
  83511. /**
  83512. * Interface for attribute information associated with buffer instanciation
  83513. */
  83514. export class InstancingAttributeInfo {
  83515. /**
  83516. * Index/offset of the attribute in the vertex shader
  83517. */
  83518. index: number;
  83519. /**
  83520. * size of the attribute, 1, 2, 3 or 4
  83521. */
  83522. attributeSize: number;
  83523. /**
  83524. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83525. * default is FLOAT
  83526. */
  83527. attribyteType: number;
  83528. /**
  83529. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83530. */
  83531. normalized: boolean;
  83532. /**
  83533. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83534. */
  83535. offset: number;
  83536. /**
  83537. * Name of the GLSL attribute, for debugging purpose only
  83538. */
  83539. attributeName: string;
  83540. }
  83541. /**
  83542. * Define options used to create a depth texture
  83543. */
  83544. export class DepthTextureCreationOptions {
  83545. /** Specifies whether or not a stencil should be allocated in the texture */
  83546. generateStencil?: boolean;
  83547. /** Specifies whether or not bilinear filtering is enable on the texture */
  83548. bilinearFiltering?: boolean;
  83549. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83550. comparisonFunction?: number;
  83551. /** Specifies if the created texture is a cube texture */
  83552. isCube?: boolean;
  83553. }
  83554. /**
  83555. * Class used to describe the capabilities of the engine relatively to the current browser
  83556. */
  83557. export class EngineCapabilities {
  83558. /** Maximum textures units per fragment shader */
  83559. maxTexturesImageUnits: number;
  83560. /** Maximum texture units per vertex shader */
  83561. maxVertexTextureImageUnits: number;
  83562. /** Maximum textures units in the entire pipeline */
  83563. maxCombinedTexturesImageUnits: number;
  83564. /** Maximum texture size */
  83565. maxTextureSize: number;
  83566. /** Maximum cube texture size */
  83567. maxCubemapTextureSize: number;
  83568. /** Maximum render texture size */
  83569. maxRenderTextureSize: number;
  83570. /** Maximum number of vertex attributes */
  83571. maxVertexAttribs: number;
  83572. /** Maximum number of varyings */
  83573. maxVaryingVectors: number;
  83574. /** Maximum number of uniforms per vertex shader */
  83575. maxVertexUniformVectors: number;
  83576. /** Maximum number of uniforms per fragment shader */
  83577. maxFragmentUniformVectors: number;
  83578. /** Defines if standard derivates (dx/dy) are supported */
  83579. standardDerivatives: boolean;
  83580. /** Defines if s3tc texture compression is supported */
  83581. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83582. /** Defines if pvrtc texture compression is supported */
  83583. pvrtc: any;
  83584. /** Defines if etc1 texture compression is supported */
  83585. etc1: any;
  83586. /** Defines if etc2 texture compression is supported */
  83587. etc2: any;
  83588. /** Defines if astc texture compression is supported */
  83589. astc: any;
  83590. /** Defines if float textures are supported */
  83591. textureFloat: boolean;
  83592. /** Defines if vertex array objects are supported */
  83593. vertexArrayObject: boolean;
  83594. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83595. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83596. /** Gets the maximum level of anisotropy supported */
  83597. maxAnisotropy: number;
  83598. /** Defines if instancing is supported */
  83599. instancedArrays: boolean;
  83600. /** Defines if 32 bits indices are supported */
  83601. uintIndices: boolean;
  83602. /** Defines if high precision shaders are supported */
  83603. highPrecisionShaderSupported: boolean;
  83604. /** Defines if depth reading in the fragment shader is supported */
  83605. fragmentDepthSupported: boolean;
  83606. /** Defines if float texture linear filtering is supported*/
  83607. textureFloatLinearFiltering: boolean;
  83608. /** Defines if rendering to float textures is supported */
  83609. textureFloatRender: boolean;
  83610. /** Defines if half float textures are supported*/
  83611. textureHalfFloat: boolean;
  83612. /** Defines if half float texture linear filtering is supported*/
  83613. textureHalfFloatLinearFiltering: boolean;
  83614. /** Defines if rendering to half float textures is supported */
  83615. textureHalfFloatRender: boolean;
  83616. /** Defines if textureLOD shader command is supported */
  83617. textureLOD: boolean;
  83618. /** Defines if draw buffers extension is supported */
  83619. drawBuffersExtension: boolean;
  83620. /** Defines if depth textures are supported */
  83621. depthTextureExtension: boolean;
  83622. /** Defines if float color buffer are supported */
  83623. colorBufferFloat: boolean;
  83624. /** Gets disjoint timer query extension (null if not supported) */
  83625. timerQuery: EXT_disjoint_timer_query;
  83626. /** Defines if timestamp can be used with timer query */
  83627. canUseTimestampForTimerQuery: boolean;
  83628. /** Function used to let the system compiles shaders in background */
  83629. parallelShaderCompile: {
  83630. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83631. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83632. COMPLETION_STATUS_KHR: number;
  83633. };
  83634. }
  83635. /** Interface defining initialization parameters for Engine class */
  83636. export interface EngineOptions extends WebGLContextAttributes {
  83637. /**
  83638. * Defines if the engine should no exceed a specified device ratio
  83639. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83640. */
  83641. limitDeviceRatio?: number;
  83642. /**
  83643. * Defines if webvr should be enabled automatically
  83644. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83645. */
  83646. autoEnableWebVR?: boolean;
  83647. /**
  83648. * Defines if webgl2 should be turned off even if supported
  83649. * @see http://doc.babylonjs.com/features/webgl2
  83650. */
  83651. disableWebGL2Support?: boolean;
  83652. /**
  83653. * Defines if webaudio should be initialized as well
  83654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83655. */
  83656. audioEngine?: boolean;
  83657. /**
  83658. * Defines if animations should run using a deterministic lock step
  83659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83660. */
  83661. deterministicLockstep?: boolean;
  83662. /** Defines the maximum steps to use with deterministic lock step mode */
  83663. lockstepMaxSteps?: number;
  83664. /**
  83665. * Defines that engine should ignore context lost events
  83666. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83667. */
  83668. doNotHandleContextLost?: boolean;
  83669. /**
  83670. * Defines that engine should ignore modifying touch action attribute and style
  83671. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83672. */
  83673. doNotHandleTouchAction?: boolean;
  83674. }
  83675. /**
  83676. * Defines the interface used by display changed events
  83677. */
  83678. export interface IDisplayChangedEventArgs {
  83679. /** Gets the vrDisplay object (if any) */
  83680. vrDisplay: Nullable<any>;
  83681. /** Gets a boolean indicating if webVR is supported */
  83682. vrSupported: boolean;
  83683. }
  83684. /**
  83685. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83686. */
  83687. export class Engine {
  83688. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83689. static ExceptionList: ({
  83690. key: string;
  83691. capture: string;
  83692. captureConstraint: number;
  83693. targets: string[];
  83694. } | {
  83695. key: string;
  83696. capture: null;
  83697. captureConstraint: null;
  83698. targets: string[];
  83699. })[];
  83700. /** Gets the list of created engines */
  83701. static readonly Instances: Engine[];
  83702. /**
  83703. * Gets the latest created engine
  83704. */
  83705. static readonly LastCreatedEngine: Nullable<Engine>;
  83706. /**
  83707. * Gets the latest created scene
  83708. */
  83709. static readonly LastCreatedScene: Nullable<Scene>;
  83710. /**
  83711. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83712. * @param flag defines which part of the materials must be marked as dirty
  83713. * @param predicate defines a predicate used to filter which materials should be affected
  83714. */
  83715. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83716. /**
  83717. * Hidden
  83718. */
  83719. static _TextureLoaders: IInternalTextureLoader[];
  83720. /** Defines that alpha blending is disabled */
  83721. static readonly ALPHA_DISABLE: number;
  83722. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83723. static readonly ALPHA_ADD: number;
  83724. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83725. static readonly ALPHA_COMBINE: number;
  83726. /** Defines that alpha blending to DEST - SRC * DEST */
  83727. static readonly ALPHA_SUBTRACT: number;
  83728. /** Defines that alpha blending to SRC * DEST */
  83729. static readonly ALPHA_MULTIPLY: number;
  83730. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83731. static readonly ALPHA_MAXIMIZED: number;
  83732. /** Defines that alpha blending to SRC + DEST */
  83733. static readonly ALPHA_ONEONE: number;
  83734. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83735. static readonly ALPHA_PREMULTIPLIED: number;
  83736. /**
  83737. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83738. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83739. */
  83740. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83741. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83742. static readonly ALPHA_INTERPOLATE: number;
  83743. /**
  83744. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83745. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83746. */
  83747. static readonly ALPHA_SCREENMODE: number;
  83748. /** Defines that the ressource is not delayed*/
  83749. static readonly DELAYLOADSTATE_NONE: number;
  83750. /** Defines that the ressource was successfully delay loaded */
  83751. static readonly DELAYLOADSTATE_LOADED: number;
  83752. /** Defines that the ressource is currently delay loading */
  83753. static readonly DELAYLOADSTATE_LOADING: number;
  83754. /** Defines that the ressource is delayed and has not started loading */
  83755. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83757. static readonly NEVER: number;
  83758. /** 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 */
  83759. static readonly ALWAYS: number;
  83760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83761. static readonly LESS: number;
  83762. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83763. static readonly EQUAL: number;
  83764. /** 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 */
  83765. static readonly LEQUAL: number;
  83766. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83767. static readonly GREATER: number;
  83768. /** 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 */
  83769. static readonly GEQUAL: number;
  83770. /** 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 */
  83771. static readonly NOTEQUAL: number;
  83772. /** Passed to stencilOperation to specify that stencil value must be kept */
  83773. static readonly KEEP: number;
  83774. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83775. static readonly REPLACE: number;
  83776. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83777. static readonly INCR: number;
  83778. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83779. static readonly DECR: number;
  83780. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83781. static readonly INVERT: number;
  83782. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83783. static readonly INCR_WRAP: number;
  83784. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83785. static readonly DECR_WRAP: number;
  83786. /** Texture is not repeating outside of 0..1 UVs */
  83787. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83788. /** Texture is repeating outside of 0..1 UVs */
  83789. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83790. /** Texture is repeating and mirrored */
  83791. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83792. /** ALPHA */
  83793. static readonly TEXTUREFORMAT_ALPHA: number;
  83794. /** LUMINANCE */
  83795. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83796. /** LUMINANCE_ALPHA */
  83797. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83798. /** RGB */
  83799. static readonly TEXTUREFORMAT_RGB: number;
  83800. /** RGBA */
  83801. static readonly TEXTUREFORMAT_RGBA: number;
  83802. /** RED */
  83803. static readonly TEXTUREFORMAT_RED: number;
  83804. /** RED (2nd reference) */
  83805. static readonly TEXTUREFORMAT_R: number;
  83806. /** RG */
  83807. static readonly TEXTUREFORMAT_RG: number;
  83808. /** RED_INTEGER */
  83809. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83810. /** RED_INTEGER (2nd reference) */
  83811. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83812. /** RG_INTEGER */
  83813. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83814. /** RGB_INTEGER */
  83815. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83816. /** RGBA_INTEGER */
  83817. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83818. /** UNSIGNED_BYTE */
  83819. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83820. /** UNSIGNED_BYTE (2nd reference) */
  83821. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83822. /** FLOAT */
  83823. static readonly TEXTURETYPE_FLOAT: number;
  83824. /** HALF_FLOAT */
  83825. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83826. /** BYTE */
  83827. static readonly TEXTURETYPE_BYTE: number;
  83828. /** SHORT */
  83829. static readonly TEXTURETYPE_SHORT: number;
  83830. /** UNSIGNED_SHORT */
  83831. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83832. /** INT */
  83833. static readonly TEXTURETYPE_INT: number;
  83834. /** UNSIGNED_INT */
  83835. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83836. /** UNSIGNED_SHORT_4_4_4_4 */
  83837. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83838. /** UNSIGNED_SHORT_5_5_5_1 */
  83839. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83840. /** UNSIGNED_SHORT_5_6_5 */
  83841. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83842. /** UNSIGNED_INT_2_10_10_10_REV */
  83843. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83844. /** UNSIGNED_INT_24_8 */
  83845. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83846. /** UNSIGNED_INT_10F_11F_11F_REV */
  83847. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83848. /** UNSIGNED_INT_5_9_9_9_REV */
  83849. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83850. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83851. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83852. /** nearest is mag = nearest and min = nearest and mip = linear */
  83853. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83854. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83855. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83856. /** Trilinear is mag = linear and min = linear and mip = linear */
  83857. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83858. /** nearest is mag = nearest and min = nearest and mip = linear */
  83859. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83860. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83861. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83862. /** Trilinear is mag = linear and min = linear and mip = linear */
  83863. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83864. /** mag = nearest and min = nearest and mip = nearest */
  83865. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83866. /** mag = nearest and min = linear and mip = nearest */
  83867. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83868. /** mag = nearest and min = linear and mip = linear */
  83869. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83870. /** mag = nearest and min = linear and mip = none */
  83871. static readonly TEXTURE_NEAREST_LINEAR: number;
  83872. /** mag = nearest and min = nearest and mip = none */
  83873. static readonly TEXTURE_NEAREST_NEAREST: number;
  83874. /** mag = linear and min = nearest and mip = nearest */
  83875. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83876. /** mag = linear and min = nearest and mip = linear */
  83877. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83878. /** mag = linear and min = linear and mip = none */
  83879. static readonly TEXTURE_LINEAR_LINEAR: number;
  83880. /** mag = linear and min = nearest and mip = none */
  83881. static readonly TEXTURE_LINEAR_NEAREST: number;
  83882. /** Explicit coordinates mode */
  83883. static readonly TEXTURE_EXPLICIT_MODE: number;
  83884. /** Spherical coordinates mode */
  83885. static readonly TEXTURE_SPHERICAL_MODE: number;
  83886. /** Planar coordinates mode */
  83887. static readonly TEXTURE_PLANAR_MODE: number;
  83888. /** Cubic coordinates mode */
  83889. static readonly TEXTURE_CUBIC_MODE: number;
  83890. /** Projection coordinates mode */
  83891. static readonly TEXTURE_PROJECTION_MODE: number;
  83892. /** Skybox coordinates mode */
  83893. static readonly TEXTURE_SKYBOX_MODE: number;
  83894. /** Inverse Cubic coordinates mode */
  83895. static readonly TEXTURE_INVCUBIC_MODE: number;
  83896. /** Equirectangular coordinates mode */
  83897. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83898. /** Equirectangular Fixed coordinates mode */
  83899. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83900. /** Equirectangular Fixed Mirrored coordinates mode */
  83901. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83902. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83903. static readonly SCALEMODE_FLOOR: number;
  83904. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83905. static readonly SCALEMODE_NEAREST: number;
  83906. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83907. static readonly SCALEMODE_CEILING: number;
  83908. /**
  83909. * Returns the current version of the framework
  83910. */
  83911. static readonly Version: string;
  83912. /**
  83913. * Returns a string describing the current engine
  83914. */
  83915. readonly description: string;
  83916. /**
  83917. * Gets or sets the epsilon value used by collision engine
  83918. */
  83919. static CollisionsEpsilon: number;
  83920. /**
  83921. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83922. */
  83923. static ShadersRepository: string;
  83924. /**
  83925. * Method called to create the default loading screen.
  83926. * This can be overriden in your own app.
  83927. * @param canvas The rendering canvas element
  83928. * @returns The loading screen
  83929. */
  83930. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83931. /**
  83932. * Method called to create the default rescale post process on each engine.
  83933. */
  83934. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83935. /**
  83936. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83937. */
  83938. forcePOTTextures: boolean;
  83939. /**
  83940. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83941. */
  83942. isFullscreen: boolean;
  83943. /**
  83944. * Gets a boolean indicating if the pointer is currently locked
  83945. */
  83946. isPointerLock: boolean;
  83947. /**
  83948. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83949. */
  83950. cullBackFaces: boolean;
  83951. /**
  83952. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83953. */
  83954. renderEvenInBackground: boolean;
  83955. /**
  83956. * Gets or sets a boolean indicating that cache can be kept between frames
  83957. */
  83958. preventCacheWipeBetweenFrames: boolean;
  83959. /**
  83960. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83961. **/
  83962. enableOfflineSupport: boolean;
  83963. /**
  83964. * 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)
  83965. **/
  83966. disableManifestCheck: boolean;
  83967. /**
  83968. * Gets the list of created scenes
  83969. */
  83970. scenes: Scene[];
  83971. /**
  83972. * Event raised when a new scene is created
  83973. */
  83974. onNewSceneAddedObservable: Observable<Scene>;
  83975. /**
  83976. * Gets the list of created postprocesses
  83977. */
  83978. postProcesses: PostProcess[];
  83979. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83980. validateShaderPrograms: boolean;
  83981. /**
  83982. * Observable event triggered each time the rendering canvas is resized
  83983. */
  83984. onResizeObservable: Observable<Engine>;
  83985. /**
  83986. * Observable event triggered each time the canvas loses focus
  83987. */
  83988. onCanvasBlurObservable: Observable<Engine>;
  83989. /**
  83990. * Observable event triggered each time the canvas gains focus
  83991. */
  83992. onCanvasFocusObservable: Observable<Engine>;
  83993. /**
  83994. * Observable event triggered each time the canvas receives pointerout event
  83995. */
  83996. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83997. /**
  83998. * Observable event triggered before each texture is initialized
  83999. */
  84000. onBeforeTextureInitObservable: Observable<Texture>;
  84001. private _vrDisplay;
  84002. private _vrSupported;
  84003. private _oldSize;
  84004. private _oldHardwareScaleFactor;
  84005. private _vrExclusivePointerMode;
  84006. private _webVRInitPromise;
  84007. /**
  84008. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84009. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84010. */
  84011. readonly isInVRExclusivePointerMode: boolean;
  84012. /**
  84013. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84014. */
  84015. disableUniformBuffers: boolean;
  84016. /** @hidden */
  84017. _uniformBuffers: UniformBuffer[];
  84018. /**
  84019. * Gets a boolean indicating that the engine supports uniform buffers
  84020. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84021. */
  84022. readonly supportsUniformBuffers: boolean;
  84023. /**
  84024. * Observable raised when the engine begins a new frame
  84025. */
  84026. onBeginFrameObservable: Observable<Engine>;
  84027. /**
  84028. * If set, will be used to request the next animation frame for the render loop
  84029. */
  84030. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84031. /**
  84032. * Observable raised when the engine ends the current frame
  84033. */
  84034. onEndFrameObservable: Observable<Engine>;
  84035. /**
  84036. * Observable raised when the engine is about to compile a shader
  84037. */
  84038. onBeforeShaderCompilationObservable: Observable<Engine>;
  84039. /**
  84040. * Observable raised when the engine has jsut compiled a shader
  84041. */
  84042. onAfterShaderCompilationObservable: Observable<Engine>;
  84043. /** @hidden */
  84044. _gl: WebGLRenderingContext;
  84045. private _renderingCanvas;
  84046. private _windowIsBackground;
  84047. private _webGLVersion;
  84048. /**
  84049. * Gets a boolean indicating that only power of 2 textures are supported
  84050. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84051. */
  84052. readonly needPOTTextures: boolean;
  84053. /** @hidden */
  84054. _badOS: boolean;
  84055. /** @hidden */
  84056. _badDesktopOS: boolean;
  84057. /**
  84058. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84059. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84060. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84061. */
  84062. disableTextureBindingOptimization: boolean;
  84063. /**
  84064. * Gets the audio engine
  84065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84066. * @ignorenaming
  84067. */
  84068. static audioEngine: IAudioEngine;
  84069. /**
  84070. * Default AudioEngine factory responsible of creating the Audio Engine.
  84071. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84072. */
  84073. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84074. /**
  84075. * Default offline support factory responsible of creating a tool used to store data locally.
  84076. * By default, this will create a Database object if the workload has been embedded.
  84077. */
  84078. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84079. private _onFocus;
  84080. private _onBlur;
  84081. private _onCanvasPointerOut;
  84082. private _onCanvasBlur;
  84083. private _onCanvasFocus;
  84084. private _onFullscreenChange;
  84085. private _onPointerLockChange;
  84086. private _onVRDisplayPointerRestricted;
  84087. private _onVRDisplayPointerUnrestricted;
  84088. private _onVrDisplayConnect;
  84089. private _onVrDisplayDisconnect;
  84090. private _onVrDisplayPresentChange;
  84091. /**
  84092. * Observable signaled when VR display mode changes
  84093. */
  84094. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84095. /**
  84096. * Observable signaled when VR request present is complete
  84097. */
  84098. onVRRequestPresentComplete: Observable<boolean>;
  84099. /**
  84100. * Observable signaled when VR request present starts
  84101. */
  84102. onVRRequestPresentStart: Observable<Engine>;
  84103. private _hardwareScalingLevel;
  84104. /** @hidden */
  84105. protected _caps: EngineCapabilities;
  84106. private _pointerLockRequested;
  84107. private _isStencilEnable;
  84108. private _colorWrite;
  84109. private _loadingScreen;
  84110. /** @hidden */
  84111. _drawCalls: PerfCounter;
  84112. /** @hidden */
  84113. _textureCollisions: PerfCounter;
  84114. private _glVersion;
  84115. private _glRenderer;
  84116. private _glVendor;
  84117. private _videoTextureSupported;
  84118. private _renderingQueueLaunched;
  84119. private _activeRenderLoops;
  84120. private _deterministicLockstep;
  84121. private _lockstepMaxSteps;
  84122. /**
  84123. * Observable signaled when a context lost event is raised
  84124. */
  84125. onContextLostObservable: Observable<Engine>;
  84126. /**
  84127. * Observable signaled when a context restored event is raised
  84128. */
  84129. onContextRestoredObservable: Observable<Engine>;
  84130. private _onContextLost;
  84131. private _onContextRestored;
  84132. private _contextWasLost;
  84133. private _doNotHandleContextLost;
  84134. /**
  84135. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84137. */
  84138. doNotHandleContextLost: boolean;
  84139. private _performanceMonitor;
  84140. private _fps;
  84141. private _deltaTime;
  84142. /**
  84143. * Turn this value on if you want to pause FPS computation when in background
  84144. */
  84145. disablePerformanceMonitorInBackground: boolean;
  84146. /**
  84147. * Gets the performance monitor attached to this engine
  84148. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84149. */
  84150. readonly performanceMonitor: PerformanceMonitor;
  84151. /** @hidden */
  84152. protected _depthCullingState: _DepthCullingState;
  84153. /** @hidden */
  84154. protected _stencilState: _StencilState;
  84155. /** @hidden */
  84156. protected _alphaState: _AlphaState;
  84157. /** @hidden */
  84158. protected _alphaMode: number;
  84159. protected _internalTexturesCache: InternalTexture[];
  84160. /** @hidden */
  84161. protected _activeChannel: number;
  84162. private _currentTextureChannel;
  84163. /** @hidden */
  84164. protected _boundTexturesCache: {
  84165. [key: string]: Nullable<InternalTexture>;
  84166. };
  84167. /** @hidden */
  84168. protected _currentEffect: Nullable<Effect>;
  84169. /** @hidden */
  84170. protected _currentProgram: Nullable<WebGLProgram>;
  84171. private _compiledEffects;
  84172. private _vertexAttribArraysEnabled;
  84173. /** @hidden */
  84174. protected _cachedViewport: Nullable<Viewport>;
  84175. private _cachedVertexArrayObject;
  84176. /** @hidden */
  84177. protected _cachedVertexBuffers: any;
  84178. /** @hidden */
  84179. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84180. /** @hidden */
  84181. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84182. /** @hidden */
  84183. protected _currentRenderTarget: Nullable<InternalTexture>;
  84184. private _uintIndicesCurrentlySet;
  84185. private _currentBoundBuffer;
  84186. /** @hidden */
  84187. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84188. private _currentBufferPointers;
  84189. private _currentInstanceLocations;
  84190. private _currentInstanceBuffers;
  84191. private _textureUnits;
  84192. private _firstBoundInternalTextureTracker;
  84193. private _lastBoundInternalTextureTracker;
  84194. private _workingCanvas;
  84195. private _workingContext;
  84196. private _rescalePostProcess;
  84197. private _dummyFramebuffer;
  84198. private _externalData;
  84199. private _bindedRenderFunction;
  84200. private _vaoRecordInProgress;
  84201. private _mustWipeVertexAttributes;
  84202. private _emptyTexture;
  84203. private _emptyCubeTexture;
  84204. private _emptyTexture3D;
  84205. /** @hidden */
  84206. _frameHandler: number;
  84207. private _nextFreeTextureSlots;
  84208. private _maxSimultaneousTextures;
  84209. private _activeRequests;
  84210. private _texturesSupported;
  84211. private _textureFormatInUse;
  84212. /**
  84213. * Gets the list of texture formats supported
  84214. */
  84215. readonly texturesSupported: Array<string>;
  84216. /**
  84217. * Gets the list of texture formats in use
  84218. */
  84219. readonly textureFormatInUse: Nullable<string>;
  84220. /**
  84221. * Gets the current viewport
  84222. */
  84223. readonly currentViewport: Nullable<Viewport>;
  84224. /**
  84225. * Gets the default empty texture
  84226. */
  84227. readonly emptyTexture: InternalTexture;
  84228. /**
  84229. * Gets the default empty 3D texture
  84230. */
  84231. readonly emptyTexture3D: InternalTexture;
  84232. /**
  84233. * Gets the default empty cube texture
  84234. */
  84235. readonly emptyCubeTexture: InternalTexture;
  84236. /**
  84237. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84238. */
  84239. readonly premultipliedAlpha: boolean;
  84240. /**
  84241. * Creates a new engine
  84242. * @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
  84243. * @param antialias defines enable antialiasing (default: false)
  84244. * @param options defines further options to be sent to the getContext() function
  84245. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84246. */
  84247. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84248. private _disableTouchAction;
  84249. private _rebuildInternalTextures;
  84250. private _rebuildEffects;
  84251. /**
  84252. * Gets a boolean indicating if all created effects are ready
  84253. * @returns true if all effects are ready
  84254. */
  84255. areAllEffectsReady(): boolean;
  84256. private _rebuildBuffers;
  84257. private _initGLContext;
  84258. /**
  84259. * Gets version of the current webGL context
  84260. */
  84261. readonly webGLVersion: number;
  84262. /**
  84263. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84264. */
  84265. readonly isStencilEnable: boolean;
  84266. private _prepareWorkingCanvas;
  84267. /**
  84268. * Reset the texture cache to empty state
  84269. */
  84270. resetTextureCache(): void;
  84271. /**
  84272. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84273. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84274. * @returns true if engine is in deterministic lock step mode
  84275. */
  84276. isDeterministicLockStep(): boolean;
  84277. /**
  84278. * Gets the max steps when engine is running in deterministic lock step
  84279. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84280. * @returns the max steps
  84281. */
  84282. getLockstepMaxSteps(): number;
  84283. /**
  84284. * Gets an object containing information about the current webGL context
  84285. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84286. */
  84287. getGlInfo(): {
  84288. vendor: string;
  84289. renderer: string;
  84290. version: string;
  84291. };
  84292. /**
  84293. * Gets current aspect ratio
  84294. * @param camera defines the camera to use to get the aspect ratio
  84295. * @param useScreen defines if screen size must be used (or the current render target if any)
  84296. * @returns a number defining the aspect ratio
  84297. */
  84298. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84299. /**
  84300. * Gets current screen aspect ratio
  84301. * @returns a number defining the aspect ratio
  84302. */
  84303. getScreenAspectRatio(): number;
  84304. /**
  84305. * Gets the current render width
  84306. * @param useScreen defines if screen size must be used (or the current render target if any)
  84307. * @returns a number defining the current render width
  84308. */
  84309. getRenderWidth(useScreen?: boolean): number;
  84310. /**
  84311. * Gets the current render height
  84312. * @param useScreen defines if screen size must be used (or the current render target if any)
  84313. * @returns a number defining the current render height
  84314. */
  84315. getRenderHeight(useScreen?: boolean): number;
  84316. /**
  84317. * Gets the HTML canvas attached with the current webGL context
  84318. * @returns a HTML canvas
  84319. */
  84320. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84321. /**
  84322. * Gets the client rect of the HTML canvas attached with the current webGL context
  84323. * @returns a client rectanglee
  84324. */
  84325. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84326. /**
  84327. * Defines the hardware scaling level.
  84328. * By default the hardware scaling level is computed from the window device ratio.
  84329. * 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.
  84330. * @param level defines the level to use
  84331. */
  84332. setHardwareScalingLevel(level: number): void;
  84333. /**
  84334. * Gets the current hardware scaling level.
  84335. * By default the hardware scaling level is computed from the window device ratio.
  84336. * 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.
  84337. * @returns a number indicating the current hardware scaling level
  84338. */
  84339. getHardwareScalingLevel(): number;
  84340. /**
  84341. * Gets the list of loaded textures
  84342. * @returns an array containing all loaded textures
  84343. */
  84344. getLoadedTexturesCache(): InternalTexture[];
  84345. /**
  84346. * Gets the object containing all engine capabilities
  84347. * @returns the EngineCapabilities object
  84348. */
  84349. getCaps(): EngineCapabilities;
  84350. /**
  84351. * Gets the current depth function
  84352. * @returns a number defining the depth function
  84353. */
  84354. getDepthFunction(): Nullable<number>;
  84355. /**
  84356. * Sets the current depth function
  84357. * @param depthFunc defines the function to use
  84358. */
  84359. setDepthFunction(depthFunc: number): void;
  84360. /**
  84361. * Sets the current depth function to GREATER
  84362. */
  84363. setDepthFunctionToGreater(): void;
  84364. /**
  84365. * Sets the current depth function to GEQUAL
  84366. */
  84367. setDepthFunctionToGreaterOrEqual(): void;
  84368. /**
  84369. * Sets the current depth function to LESS
  84370. */
  84371. setDepthFunctionToLess(): void;
  84372. /**
  84373. * Sets the current depth function to LEQUAL
  84374. */
  84375. setDepthFunctionToLessOrEqual(): void;
  84376. /**
  84377. * Gets a boolean indicating if stencil buffer is enabled
  84378. * @returns the current stencil buffer state
  84379. */
  84380. getStencilBuffer(): boolean;
  84381. /**
  84382. * Enable or disable the stencil buffer
  84383. * @param enable defines if the stencil buffer must be enabled or disabled
  84384. */
  84385. setStencilBuffer(enable: boolean): void;
  84386. /**
  84387. * Gets the current stencil mask
  84388. * @returns a number defining the new stencil mask to use
  84389. */
  84390. getStencilMask(): number;
  84391. /**
  84392. * Sets the current stencil mask
  84393. * @param mask defines the new stencil mask to use
  84394. */
  84395. setStencilMask(mask: number): void;
  84396. /**
  84397. * Gets the current stencil function
  84398. * @returns a number defining the stencil function to use
  84399. */
  84400. getStencilFunction(): number;
  84401. /**
  84402. * Gets the current stencil reference value
  84403. * @returns a number defining the stencil reference value to use
  84404. */
  84405. getStencilFunctionReference(): number;
  84406. /**
  84407. * Gets the current stencil mask
  84408. * @returns a number defining the stencil mask to use
  84409. */
  84410. getStencilFunctionMask(): number;
  84411. /**
  84412. * Sets the current stencil function
  84413. * @param stencilFunc defines the new stencil function to use
  84414. */
  84415. setStencilFunction(stencilFunc: number): void;
  84416. /**
  84417. * Sets the current stencil reference
  84418. * @param reference defines the new stencil reference to use
  84419. */
  84420. setStencilFunctionReference(reference: number): void;
  84421. /**
  84422. * Sets the current stencil mask
  84423. * @param mask defines the new stencil mask to use
  84424. */
  84425. setStencilFunctionMask(mask: number): void;
  84426. /**
  84427. * Gets the current stencil operation when stencil fails
  84428. * @returns a number defining stencil operation to use when stencil fails
  84429. */
  84430. getStencilOperationFail(): number;
  84431. /**
  84432. * Gets the current stencil operation when depth fails
  84433. * @returns a number defining stencil operation to use when depth fails
  84434. */
  84435. getStencilOperationDepthFail(): number;
  84436. /**
  84437. * Gets the current stencil operation when stencil passes
  84438. * @returns a number defining stencil operation to use when stencil passes
  84439. */
  84440. getStencilOperationPass(): number;
  84441. /**
  84442. * Sets the stencil operation to use when stencil fails
  84443. * @param operation defines the stencil operation to use when stencil fails
  84444. */
  84445. setStencilOperationFail(operation: number): void;
  84446. /**
  84447. * Sets the stencil operation to use when depth fails
  84448. * @param operation defines the stencil operation to use when depth fails
  84449. */
  84450. setStencilOperationDepthFail(operation: number): void;
  84451. /**
  84452. * Sets the stencil operation to use when stencil passes
  84453. * @param operation defines the stencil operation to use when stencil passes
  84454. */
  84455. setStencilOperationPass(operation: number): void;
  84456. /**
  84457. * Sets a boolean indicating if the dithering state is enabled or disabled
  84458. * @param value defines the dithering state
  84459. */
  84460. setDitheringState(value: boolean): void;
  84461. /**
  84462. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84463. * @param value defines the rasterizer state
  84464. */
  84465. setRasterizerState(value: boolean): void;
  84466. /**
  84467. * stop executing a render loop function and remove it from the execution array
  84468. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84469. */
  84470. stopRenderLoop(renderFunction?: () => void): void;
  84471. /** @hidden */
  84472. _renderLoop(): void;
  84473. /**
  84474. * Register and execute a render loop. The engine can have more than one render function
  84475. * @param renderFunction defines the function to continuously execute
  84476. */
  84477. runRenderLoop(renderFunction: () => void): void;
  84478. /**
  84479. * Toggle full screen mode
  84480. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84481. */
  84482. switchFullscreen(requestPointerLock: boolean): void;
  84483. /**
  84484. * Enters full screen mode
  84485. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84486. */
  84487. enterFullscreen(requestPointerLock: boolean): void;
  84488. /**
  84489. * Exits full screen mode
  84490. */
  84491. exitFullscreen(): void;
  84492. /**
  84493. * Clear the current render buffer or the current render target (if any is set up)
  84494. * @param color defines the color to use
  84495. * @param backBuffer defines if the back buffer must be cleared
  84496. * @param depth defines if the depth buffer must be cleared
  84497. * @param stencil defines if the stencil buffer must be cleared
  84498. */
  84499. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84500. /**
  84501. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84502. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84503. * @param y defines the y-coordinate of the corner of the clear rectangle
  84504. * @param width defines the width of the clear rectangle
  84505. * @param height defines the height of the clear rectangle
  84506. * @param clearColor defines the clear color
  84507. */
  84508. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84509. /**
  84510. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84511. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84512. * @param y defines the y-coordinate of the corner of the clear rectangle
  84513. * @param width defines the width of the clear rectangle
  84514. * @param height defines the height of the clear rectangle
  84515. */
  84516. enableScissor(x: number, y: number, width: number, height: number): void;
  84517. /**
  84518. * Disable previously set scissor test rectangle
  84519. */
  84520. disableScissor(): void;
  84521. private _viewportCached;
  84522. /** @hidden */
  84523. _viewport(x: number, y: number, width: number, height: number): void;
  84524. /**
  84525. * Set the WebGL's viewport
  84526. * @param viewport defines the viewport element to be used
  84527. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84528. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84529. */
  84530. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84531. /**
  84532. * Directly set the WebGL Viewport
  84533. * @param x defines the x coordinate of the viewport (in screen space)
  84534. * @param y defines the y coordinate of the viewport (in screen space)
  84535. * @param width defines the width of the viewport (in screen space)
  84536. * @param height defines the height of the viewport (in screen space)
  84537. * @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
  84538. */
  84539. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84540. /**
  84541. * Begin a new frame
  84542. */
  84543. beginFrame(): void;
  84544. /**
  84545. * Enf the current frame
  84546. */
  84547. endFrame(): void;
  84548. /**
  84549. * Resize the view according to the canvas' size
  84550. */
  84551. resize(): void;
  84552. /**
  84553. * Force a specific size of the canvas
  84554. * @param width defines the new canvas' width
  84555. * @param height defines the new canvas' height
  84556. */
  84557. setSize(width: number, height: number): void;
  84558. /**
  84559. * Gets a boolean indicating if a webVR device was detected
  84560. * @returns true if a webVR device was detected
  84561. */
  84562. isVRDevicePresent(): boolean;
  84563. /**
  84564. * Gets the current webVR device
  84565. * @returns the current webVR device (or null)
  84566. */
  84567. getVRDevice(): any;
  84568. /**
  84569. * Initializes a webVR display and starts listening to display change events
  84570. * The onVRDisplayChangedObservable will be notified upon these changes
  84571. * @returns The onVRDisplayChangedObservable
  84572. */
  84573. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84574. /**
  84575. * Initializes a webVR display and starts listening to display change events
  84576. * The onVRDisplayChangedObservable will be notified upon these changes
  84577. * @returns A promise containing a VRDisplay and if vr is supported
  84578. */
  84579. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84580. /**
  84581. * Call this function to switch to webVR mode
  84582. * Will do nothing if webVR is not supported or if there is no webVR device
  84583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84584. */
  84585. enableVR(): void;
  84586. /**
  84587. * Call this function to leave webVR mode
  84588. * Will do nothing if webVR is not supported or if there is no webVR device
  84589. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84590. */
  84591. disableVR(): void;
  84592. private _onVRFullScreenTriggered;
  84593. private _getVRDisplaysAsync;
  84594. /**
  84595. * Binds the frame buffer to the specified texture.
  84596. * @param texture The texture to render to or null for the default canvas
  84597. * @param faceIndex The face of the texture to render to in case of cube texture
  84598. * @param requiredWidth The width of the target to render to
  84599. * @param requiredHeight The height of the target to render to
  84600. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84601. * @param depthStencilTexture The depth stencil texture to use to render
  84602. * @param lodLevel defines le lod level to bind to the frame buffer
  84603. */
  84604. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84605. private bindUnboundFramebuffer;
  84606. /**
  84607. * Unbind the current render target texture from the webGL context
  84608. * @param texture defines the render target texture to unbind
  84609. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84610. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84611. */
  84612. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84613. /**
  84614. * Unbind a list of render target textures from the webGL context
  84615. * This is used only when drawBuffer extension or webGL2 are active
  84616. * @param textures defines the render target textures to unbind
  84617. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84618. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84619. */
  84620. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84621. /**
  84622. * Force the mipmap generation for the given render target texture
  84623. * @param texture defines the render target texture to use
  84624. */
  84625. generateMipMapsForCubemap(texture: InternalTexture): void;
  84626. /**
  84627. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84628. */
  84629. flushFramebuffer(): void;
  84630. /**
  84631. * Unbind the current render target and bind the default framebuffer
  84632. */
  84633. restoreDefaultFramebuffer(): void;
  84634. /**
  84635. * Create an uniform buffer
  84636. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84637. * @param elements defines the content of the uniform buffer
  84638. * @returns the webGL uniform buffer
  84639. */
  84640. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84641. /**
  84642. * Create a dynamic uniform buffer
  84643. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84644. * @param elements defines the content of the uniform buffer
  84645. * @returns the webGL uniform buffer
  84646. */
  84647. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84648. /**
  84649. * Update an existing uniform buffer
  84650. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84651. * @param uniformBuffer defines the target uniform buffer
  84652. * @param elements defines the content to update
  84653. * @param offset defines the offset in the uniform buffer where update should start
  84654. * @param count defines the size of the data to update
  84655. */
  84656. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84657. private _resetVertexBufferBinding;
  84658. /**
  84659. * Creates a vertex buffer
  84660. * @param data the data for the vertex buffer
  84661. * @returns the new WebGL static buffer
  84662. */
  84663. createVertexBuffer(data: DataArray): WebGLBuffer;
  84664. /**
  84665. * Creates a dynamic vertex buffer
  84666. * @param data the data for the dynamic vertex buffer
  84667. * @returns the new WebGL dynamic buffer
  84668. */
  84669. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84670. /**
  84671. * Update a dynamic index buffer
  84672. * @param indexBuffer defines the target index buffer
  84673. * @param indices defines the data to update
  84674. * @param offset defines the offset in the target index buffer where update should start
  84675. */
  84676. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84677. /**
  84678. * Updates a dynamic vertex buffer.
  84679. * @param vertexBuffer the vertex buffer to update
  84680. * @param data the data used to update the vertex buffer
  84681. * @param byteOffset the byte offset of the data
  84682. * @param byteLength the byte length of the data
  84683. */
  84684. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84685. private _resetIndexBufferBinding;
  84686. /**
  84687. * Creates a new index buffer
  84688. * @param indices defines the content of the index buffer
  84689. * @param updatable defines if the index buffer must be updatable
  84690. * @returns a new webGL buffer
  84691. */
  84692. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84693. /**
  84694. * Bind a webGL buffer to the webGL context
  84695. * @param buffer defines the buffer to bind
  84696. */
  84697. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84698. /**
  84699. * Bind an uniform buffer to the current webGL context
  84700. * @param buffer defines the buffer to bind
  84701. */
  84702. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84703. /**
  84704. * Bind a buffer to the current webGL context at a given location
  84705. * @param buffer defines the buffer to bind
  84706. * @param location defines the index where to bind the buffer
  84707. */
  84708. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84709. /**
  84710. * Bind a specific block at a given index in a specific shader program
  84711. * @param shaderProgram defines the shader program
  84712. * @param blockName defines the block name
  84713. * @param index defines the index where to bind the block
  84714. */
  84715. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84716. private bindIndexBuffer;
  84717. private bindBuffer;
  84718. /**
  84719. * update the bound buffer with the given data
  84720. * @param data defines the data to update
  84721. */
  84722. updateArrayBuffer(data: Float32Array): void;
  84723. private _vertexAttribPointer;
  84724. private _bindIndexBufferWithCache;
  84725. private _bindVertexBuffersAttributes;
  84726. /**
  84727. * Records a vertex array object
  84728. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84729. * @param vertexBuffers defines the list of vertex buffers to store
  84730. * @param indexBuffer defines the index buffer to store
  84731. * @param effect defines the effect to store
  84732. * @returns the new vertex array object
  84733. */
  84734. recordVertexArrayObject(vertexBuffers: {
  84735. [key: string]: VertexBuffer;
  84736. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84737. /**
  84738. * Bind a specific vertex array object
  84739. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84740. * @param vertexArrayObject defines the vertex array object to bind
  84741. * @param indexBuffer defines the index buffer to bind
  84742. */
  84743. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84744. /**
  84745. * Bind webGl buffers directly to the webGL context
  84746. * @param vertexBuffer defines the vertex buffer to bind
  84747. * @param indexBuffer defines the index buffer to bind
  84748. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84749. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84750. * @param effect defines the effect associated with the vertex buffer
  84751. */
  84752. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84753. private _unbindVertexArrayObject;
  84754. /**
  84755. * Bind a list of vertex buffers to the webGL context
  84756. * @param vertexBuffers defines the list of vertex buffers to bind
  84757. * @param indexBuffer defines the index buffer to bind
  84758. * @param effect defines the effect associated with the vertex buffers
  84759. */
  84760. bindBuffers(vertexBuffers: {
  84761. [key: string]: Nullable<VertexBuffer>;
  84762. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84763. /**
  84764. * Unbind all instance attributes
  84765. */
  84766. unbindInstanceAttributes(): void;
  84767. /**
  84768. * Release and free the memory of a vertex array object
  84769. * @param vao defines the vertex array object to delete
  84770. */
  84771. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84772. /** @hidden */
  84773. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84774. /**
  84775. * Creates a webGL buffer to use with instanciation
  84776. * @param capacity defines the size of the buffer
  84777. * @returns the webGL buffer
  84778. */
  84779. createInstancesBuffer(capacity: number): WebGLBuffer;
  84780. /**
  84781. * Delete a webGL buffer used with instanciation
  84782. * @param buffer defines the webGL buffer to delete
  84783. */
  84784. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84785. /**
  84786. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84787. * @param instancesBuffer defines the webGL buffer to update and bind
  84788. * @param data defines the data to store in the buffer
  84789. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84790. */
  84791. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84792. /**
  84793. * Apply all cached states (depth, culling, stencil and alpha)
  84794. */
  84795. applyStates(): void;
  84796. /**
  84797. * Send a draw order
  84798. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84799. * @param indexStart defines the starting index
  84800. * @param indexCount defines the number of index to draw
  84801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84802. */
  84803. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84804. /**
  84805. * Draw a list of points
  84806. * @param verticesStart defines the index of first vertex to draw
  84807. * @param verticesCount defines the count of vertices to draw
  84808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84809. */
  84810. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84811. /**
  84812. * Draw a list of unindexed primitives
  84813. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84814. * @param verticesStart defines the index of first vertex to draw
  84815. * @param verticesCount defines the count of vertices to draw
  84816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84817. */
  84818. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84819. /**
  84820. * Draw a list of indexed primitives
  84821. * @param fillMode defines the primitive to use
  84822. * @param indexStart defines the starting index
  84823. * @param indexCount defines the number of index to draw
  84824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84825. */
  84826. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84827. /**
  84828. * Draw a list of unindexed primitives
  84829. * @param fillMode defines the primitive to use
  84830. * @param verticesStart defines the index of first vertex to draw
  84831. * @param verticesCount defines the count of vertices to draw
  84832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84833. */
  84834. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84835. private _drawMode;
  84836. /** @hidden */
  84837. _releaseEffect(effect: Effect): void;
  84838. /** @hidden */
  84839. _deleteProgram(program: WebGLProgram): void;
  84840. /**
  84841. * Create a new effect (used to store vertex/fragment shaders)
  84842. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84843. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84844. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84845. * @param samplers defines an array of string used to represent textures
  84846. * @param defines defines the string containing the defines to use to compile the shaders
  84847. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84848. * @param onCompiled defines a function to call when the effect creation is successful
  84849. * @param onError defines a function to call when the effect creation has failed
  84850. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84851. * @returns the new Effect
  84852. */
  84853. 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;
  84854. private _compileShader;
  84855. private _compileRawShader;
  84856. /**
  84857. * Directly creates a webGL program
  84858. * @param vertexCode defines the vertex shader code to use
  84859. * @param fragmentCode defines the fragment shader code to use
  84860. * @param context defines the webGL context to use (if not set, the current one will be used)
  84861. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84862. * @returns the new webGL program
  84863. */
  84864. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84865. /**
  84866. * Creates a webGL program
  84867. * @param vertexCode defines the vertex shader code to use
  84868. * @param fragmentCode defines the fragment shader code to use
  84869. * @param defines defines the string containing the defines to use to compile the shaders
  84870. * @param context defines the webGL context to use (if not set, the current one will be used)
  84871. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84872. * @returns the new webGL program
  84873. */
  84874. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84875. private _createShaderProgram;
  84876. private _finalizeProgram;
  84877. /** @hidden */
  84878. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84879. /** @hidden */
  84880. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84881. /**
  84882. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84883. * @param shaderProgram defines the webGL program to use
  84884. * @param uniformsNames defines the list of uniform names
  84885. * @returns an array of webGL uniform locations
  84886. */
  84887. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84888. /**
  84889. * Gets the lsit of active attributes for a given webGL program
  84890. * @param shaderProgram defines the webGL program to use
  84891. * @param attributesNames defines the list of attribute names to get
  84892. * @returns an array of indices indicating the offset of each attribute
  84893. */
  84894. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84895. /**
  84896. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84897. * @param effect defines the effect to activate
  84898. */
  84899. enableEffect(effect: Nullable<Effect>): void;
  84900. /**
  84901. * Set the value of an uniform to an array of int32
  84902. * @param uniform defines the webGL uniform location where to store the value
  84903. * @param array defines the array of int32 to store
  84904. */
  84905. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84906. /**
  84907. * Set the value of an uniform to an array of int32 (stored as vec2)
  84908. * @param uniform defines the webGL uniform location where to store the value
  84909. * @param array defines the array of int32 to store
  84910. */
  84911. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84912. /**
  84913. * Set the value of an uniform to an array of int32 (stored as vec3)
  84914. * @param uniform defines the webGL uniform location where to store the value
  84915. * @param array defines the array of int32 to store
  84916. */
  84917. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84918. /**
  84919. * Set the value of an uniform to an array of int32 (stored as vec4)
  84920. * @param uniform defines the webGL uniform location where to store the value
  84921. * @param array defines the array of int32 to store
  84922. */
  84923. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84924. /**
  84925. * Set the value of an uniform to an array of float32
  84926. * @param uniform defines the webGL uniform location where to store the value
  84927. * @param array defines the array of float32 to store
  84928. */
  84929. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84930. /**
  84931. * Set the value of an uniform to an array of float32 (stored as vec2)
  84932. * @param uniform defines the webGL uniform location where to store the value
  84933. * @param array defines the array of float32 to store
  84934. */
  84935. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84936. /**
  84937. * Set the value of an uniform to an array of float32 (stored as vec3)
  84938. * @param uniform defines the webGL uniform location where to store the value
  84939. * @param array defines the array of float32 to store
  84940. */
  84941. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84942. /**
  84943. * Set the value of an uniform to an array of float32 (stored as vec4)
  84944. * @param uniform defines the webGL uniform location where to store the value
  84945. * @param array defines the array of float32 to store
  84946. */
  84947. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84948. /**
  84949. * Set the value of an uniform to an array of number
  84950. * @param uniform defines the webGL uniform location where to store the value
  84951. * @param array defines the array of number to store
  84952. */
  84953. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84954. /**
  84955. * Set the value of an uniform to an array of number (stored as vec2)
  84956. * @param uniform defines the webGL uniform location where to store the value
  84957. * @param array defines the array of number to store
  84958. */
  84959. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84960. /**
  84961. * Set the value of an uniform to an array of number (stored as vec3)
  84962. * @param uniform defines the webGL uniform location where to store the value
  84963. * @param array defines the array of number to store
  84964. */
  84965. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84966. /**
  84967. * Set the value of an uniform to an array of number (stored as vec4)
  84968. * @param uniform defines the webGL uniform location where to store the value
  84969. * @param array defines the array of number to store
  84970. */
  84971. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84972. /**
  84973. * Set the value of an uniform to an array of float32 (stored as matrices)
  84974. * @param uniform defines the webGL uniform location where to store the value
  84975. * @param matrices defines the array of float32 to store
  84976. */
  84977. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84978. /**
  84979. * Set the value of an uniform to a matrix
  84980. * @param uniform defines the webGL uniform location where to store the value
  84981. * @param matrix defines the matrix to store
  84982. */
  84983. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84984. /**
  84985. * Set the value of an uniform to a matrix (3x3)
  84986. * @param uniform defines the webGL uniform location where to store the value
  84987. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84988. */
  84989. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84990. /**
  84991. * Set the value of an uniform to a matrix (2x2)
  84992. * @param uniform defines the webGL uniform location where to store the value
  84993. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84994. */
  84995. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84996. /**
  84997. * Set the value of an uniform to a number (int)
  84998. * @param uniform defines the webGL uniform location where to store the value
  84999. * @param value defines the int number to store
  85000. */
  85001. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85002. /**
  85003. * Set the value of an uniform to a number (float)
  85004. * @param uniform defines the webGL uniform location where to store the value
  85005. * @param value defines the float number to store
  85006. */
  85007. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85008. /**
  85009. * Set the value of an uniform to a vec2
  85010. * @param uniform defines the webGL uniform location where to store the value
  85011. * @param x defines the 1st component of the value
  85012. * @param y defines the 2nd component of the value
  85013. */
  85014. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85015. /**
  85016. * Set the value of an uniform to a vec3
  85017. * @param uniform defines the webGL uniform location where to store the value
  85018. * @param x defines the 1st component of the value
  85019. * @param y defines the 2nd component of the value
  85020. * @param z defines the 3rd component of the value
  85021. */
  85022. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85023. /**
  85024. * Set the value of an uniform to a boolean
  85025. * @param uniform defines the webGL uniform location where to store the value
  85026. * @param bool defines the boolean to store
  85027. */
  85028. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85029. /**
  85030. * Set the value of an uniform to a vec4
  85031. * @param uniform defines the webGL uniform location where to store the value
  85032. * @param x defines the 1st component of the value
  85033. * @param y defines the 2nd component of the value
  85034. * @param z defines the 3rd component of the value
  85035. * @param w defines the 4th component of the value
  85036. */
  85037. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85038. /**
  85039. * Set the value of an uniform to a Color3
  85040. * @param uniform defines the webGL uniform location where to store the value
  85041. * @param color3 defines the color to store
  85042. */
  85043. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85044. /**
  85045. * Set the value of an uniform to a Color3 and an alpha value
  85046. * @param uniform defines the webGL uniform location where to store the value
  85047. * @param color3 defines the color to store
  85048. * @param alpha defines the alpha component to store
  85049. */
  85050. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85051. /**
  85052. * Sets a Color4 on a uniform variable
  85053. * @param uniform defines the uniform location
  85054. * @param color4 defines the value to be set
  85055. */
  85056. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85057. /**
  85058. * Set various states to the webGL context
  85059. * @param culling defines backface culling state
  85060. * @param zOffset defines the value to apply to zOffset (0 by default)
  85061. * @param force defines if states must be applied even if cache is up to date
  85062. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85063. */
  85064. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85065. /**
  85066. * Set the z offset to apply to current rendering
  85067. * @param value defines the offset to apply
  85068. */
  85069. setZOffset(value: number): void;
  85070. /**
  85071. * Gets the current value of the zOffset
  85072. * @returns the current zOffset state
  85073. */
  85074. getZOffset(): number;
  85075. /**
  85076. * Enable or disable depth buffering
  85077. * @param enable defines the state to set
  85078. */
  85079. setDepthBuffer(enable: boolean): void;
  85080. /**
  85081. * Gets a boolean indicating if depth writing is enabled
  85082. * @returns the current depth writing state
  85083. */
  85084. getDepthWrite(): boolean;
  85085. /**
  85086. * Enable or disable depth writing
  85087. * @param enable defines the state to set
  85088. */
  85089. setDepthWrite(enable: boolean): void;
  85090. /**
  85091. * Enable or disable color writing
  85092. * @param enable defines the state to set
  85093. */
  85094. setColorWrite(enable: boolean): void;
  85095. /**
  85096. * Gets a boolean indicating if color writing is enabled
  85097. * @returns the current color writing state
  85098. */
  85099. getColorWrite(): boolean;
  85100. /**
  85101. * Sets alpha constants used by some alpha blending modes
  85102. * @param r defines the red component
  85103. * @param g defines the green component
  85104. * @param b defines the blue component
  85105. * @param a defines the alpha component
  85106. */
  85107. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85108. /**
  85109. * Sets the current alpha mode
  85110. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85111. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85112. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85113. */
  85114. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85115. /**
  85116. * Gets the current alpha mode
  85117. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85118. * @returns the current alpha mode
  85119. */
  85120. getAlphaMode(): number;
  85121. /**
  85122. * Clears the list of texture accessible through engine.
  85123. * This can help preventing texture load conflict due to name collision.
  85124. */
  85125. clearInternalTexturesCache(): void;
  85126. /**
  85127. * Force the entire cache to be cleared
  85128. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85129. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85130. */
  85131. wipeCaches(bruteForce?: boolean): void;
  85132. /**
  85133. * Set the compressed texture format to use, based on the formats you have, and the formats
  85134. * supported by the hardware / browser.
  85135. *
  85136. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85137. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85138. * to API arguments needed to compressed textures. This puts the burden on the container
  85139. * generator to house the arcane code for determining these for current & future formats.
  85140. *
  85141. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85142. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85143. *
  85144. * Note: The result of this call is not taken into account when a texture is base64.
  85145. *
  85146. * @param formatsAvailable defines the list of those format families you have created
  85147. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85148. *
  85149. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85150. * @returns The extension selected.
  85151. */
  85152. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85153. private _getSamplingParameters;
  85154. private _partialLoadImg;
  85155. private _cascadeLoadImgs;
  85156. /** @hidden */
  85157. _createTexture(): WebGLTexture;
  85158. /**
  85159. * Usually called from Texture.ts.
  85160. * Passed information to create a WebGLTexture
  85161. * @param urlArg defines a value which contains one of the following:
  85162. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85163. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85164. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85165. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85166. * @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)
  85167. * @param scene needed for loading to the correct scene
  85168. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85169. * @param onLoad optional callback to be called upon successful completion
  85170. * @param onError optional callback to be called upon failure
  85171. * @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
  85172. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85173. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85174. * @param forcedExtension defines the extension to use to pick the right loader
  85175. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85176. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85177. */
  85178. 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;
  85179. private _rescaleTexture;
  85180. /**
  85181. * Update a raw texture
  85182. * @param texture defines the texture to update
  85183. * @param data defines the data to store in the texture
  85184. * @param format defines the format of the data
  85185. * @param invertY defines if data must be stored with Y axis inverted
  85186. * @param compression defines the compression used (null by default)
  85187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85188. */
  85189. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85190. /**
  85191. * Creates a raw texture
  85192. * @param data defines the data to store in the texture
  85193. * @param width defines the width of the texture
  85194. * @param height defines the height of the texture
  85195. * @param format defines the format of the data
  85196. * @param generateMipMaps defines if the engine should generate the mip levels
  85197. * @param invertY defines if data must be stored with Y axis inverted
  85198. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85199. * @param compression defines the compression used (null by default)
  85200. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85201. * @returns the raw texture inside an InternalTexture
  85202. */
  85203. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85204. private _unpackFlipYCached;
  85205. /**
  85206. * In case you are sharing the context with other applications, it might
  85207. * be interested to not cache the unpack flip y state to ensure a consistent
  85208. * value would be set.
  85209. */
  85210. enableUnpackFlipYCached: boolean;
  85211. /** @hidden */
  85212. _unpackFlipY(value: boolean): void;
  85213. /** @hidden */
  85214. _getUnpackAlignement(): number;
  85215. /**
  85216. * Creates a dynamic texture
  85217. * @param width defines the width of the texture
  85218. * @param height defines the height of the texture
  85219. * @param generateMipMaps defines if the engine should generate the mip levels
  85220. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85221. * @returns the dynamic texture inside an InternalTexture
  85222. */
  85223. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85224. /**
  85225. * Update the sampling mode of a given texture
  85226. * @param samplingMode defines the required sampling mode
  85227. * @param texture defines the texture to update
  85228. */
  85229. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85230. /**
  85231. * Update the content of a dynamic texture
  85232. * @param texture defines the texture to update
  85233. * @param canvas defines the canvas containing the source
  85234. * @param invertY defines if data must be stored with Y axis inverted
  85235. * @param premulAlpha defines if alpha is stored as premultiplied
  85236. * @param format defines the format of the data
  85237. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85238. */
  85239. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85240. /**
  85241. * Update a video texture
  85242. * @param texture defines the texture to update
  85243. * @param video defines the video element to use
  85244. * @param invertY defines if data must be stored with Y axis inverted
  85245. */
  85246. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85247. /**
  85248. * Updates a depth texture Comparison Mode and Function.
  85249. * If the comparison Function is equal to 0, the mode will be set to none.
  85250. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85251. * @param texture The texture to set the comparison function for
  85252. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85253. */
  85254. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85255. private _setupDepthStencilTexture;
  85256. /**
  85257. * Creates a depth stencil texture.
  85258. * This is only available in WebGL 2 or with the depth texture extension available.
  85259. * @param size The size of face edge in the texture.
  85260. * @param options The options defining the texture.
  85261. * @returns The texture
  85262. */
  85263. createDepthStencilTexture(size: number | {
  85264. width: number;
  85265. height: number;
  85266. }, options: DepthTextureCreationOptions): InternalTexture;
  85267. /**
  85268. * Creates a depth stencil texture.
  85269. * This is only available in WebGL 2 or with the depth texture extension available.
  85270. * @param size The size of face edge in the texture.
  85271. * @param options The options defining the texture.
  85272. * @returns The texture
  85273. */
  85274. private _createDepthStencilTexture;
  85275. /**
  85276. * Creates a depth stencil cube texture.
  85277. * This is only available in WebGL 2.
  85278. * @param size The size of face edge in the cube texture.
  85279. * @param options The options defining the cube texture.
  85280. * @returns The cube texture
  85281. */
  85282. private _createDepthStencilCubeTexture;
  85283. /**
  85284. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85285. * @param renderTarget The render target to set the frame buffer for
  85286. */
  85287. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85288. /**
  85289. * Creates a new render target texture
  85290. * @param size defines the size of the texture
  85291. * @param options defines the options used to create the texture
  85292. * @returns a new render target texture stored in an InternalTexture
  85293. */
  85294. createRenderTargetTexture(size: number | {
  85295. width: number;
  85296. height: number;
  85297. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85298. /**
  85299. * Create a multi render target texture
  85300. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85301. * @param size defines the size of the texture
  85302. * @param options defines the creation options
  85303. * @returns the cube texture as an InternalTexture
  85304. */
  85305. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85306. private _setupFramebufferDepthAttachments;
  85307. /**
  85308. * Updates the sample count of a render target texture
  85309. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85310. * @param texture defines the texture to update
  85311. * @param samples defines the sample count to set
  85312. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85313. */
  85314. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85315. /**
  85316. * Update the sample count for a given multiple render target texture
  85317. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85318. * @param textures defines the textures to update
  85319. * @param samples defines the sample count to set
  85320. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85321. */
  85322. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85323. /** @hidden */
  85324. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85325. /** @hidden */
  85326. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85327. /** @hidden */
  85328. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85329. /** @hidden */
  85330. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85331. /**
  85332. * Creates a new render target cube texture
  85333. * @param size defines the size of the texture
  85334. * @param options defines the options used to create the texture
  85335. * @returns a new render target cube texture stored in an InternalTexture
  85336. */
  85337. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85338. /**
  85339. * Creates a cube texture
  85340. * @param rootUrl defines the url where the files to load is located
  85341. * @param scene defines the current scene
  85342. * @param files defines the list of files to load (1 per face)
  85343. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85344. * @param onLoad defines an optional callback raised when the texture is loaded
  85345. * @param onError defines an optional callback raised if there is an issue to load the texture
  85346. * @param format defines the format of the data
  85347. * @param forcedExtension defines the extension to use to pick the right loader
  85348. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85349. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85350. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85351. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85352. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85353. * @returns the cube texture as an InternalTexture
  85354. */
  85355. 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;
  85356. /**
  85357. * @hidden
  85358. */
  85359. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85360. /**
  85361. * Update a raw cube texture
  85362. * @param texture defines the texture to udpdate
  85363. * @param data defines the data to store
  85364. * @param format defines the data format
  85365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85366. * @param invertY defines if data must be stored with Y axis inverted
  85367. * @param compression defines the compression used (null by default)
  85368. * @param level defines which level of the texture to update
  85369. */
  85370. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85371. /**
  85372. * Creates a new raw cube texture
  85373. * @param data defines the array of data to use to create each face
  85374. * @param size defines the size of the textures
  85375. * @param format defines the format of the data
  85376. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85377. * @param generateMipMaps defines if the engine should generate the mip levels
  85378. * @param invertY defines if data must be stored with Y axis inverted
  85379. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85380. * @param compression defines the compression used (null by default)
  85381. * @returns the cube texture as an InternalTexture
  85382. */
  85383. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85384. /**
  85385. * Creates a new raw cube texture from a specified url
  85386. * @param url defines the url where the data is located
  85387. * @param scene defines the current scene
  85388. * @param size defines the size of the textures
  85389. * @param format defines the format of the data
  85390. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85391. * @param noMipmap defines if the engine should avoid generating the mip levels
  85392. * @param callback defines a callback used to extract texture data from loaded data
  85393. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85394. * @param onLoad defines a callback called when texture is loaded
  85395. * @param onError defines a callback called if there is an error
  85396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85397. * @param invertY defines if data must be stored with Y axis inverted
  85398. * @returns the cube texture as an InternalTexture
  85399. */
  85400. 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;
  85401. /**
  85402. * Update a raw 3D texture
  85403. * @param texture defines the texture to update
  85404. * @param data defines the data to store
  85405. * @param format defines the data format
  85406. * @param invertY defines if data must be stored with Y axis inverted
  85407. * @param compression defines the used compression (can be null)
  85408. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85409. */
  85410. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85411. /**
  85412. * Creates a new raw 3D texture
  85413. * @param data defines the data used to create the texture
  85414. * @param width defines the width of the texture
  85415. * @param height defines the height of the texture
  85416. * @param depth defines the depth of the texture
  85417. * @param format defines the format of the texture
  85418. * @param generateMipMaps defines if the engine must generate mip levels
  85419. * @param invertY defines if data must be stored with Y axis inverted
  85420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85421. * @param compression defines the compressed used (can be null)
  85422. * @param textureType defines the compressed used (can be null)
  85423. * @returns a new raw 3D texture (stored in an InternalTexture)
  85424. */
  85425. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85426. private _prepareWebGLTextureContinuation;
  85427. private _prepareWebGLTexture;
  85428. private _convertRGBtoRGBATextureData;
  85429. /** @hidden */
  85430. _releaseFramebufferObjects(texture: InternalTexture): void;
  85431. /** @hidden */
  85432. _releaseTexture(texture: InternalTexture): void;
  85433. private setProgram;
  85434. private _boundUniforms;
  85435. /**
  85436. * Binds an effect to the webGL context
  85437. * @param effect defines the effect to bind
  85438. */
  85439. bindSamplers(effect: Effect): void;
  85440. private _moveBoundTextureOnTop;
  85441. private _getCorrectTextureChannel;
  85442. private _linkTrackers;
  85443. private _removeDesignatedSlot;
  85444. private _activateCurrentTexture;
  85445. /** @hidden */
  85446. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85447. /** @hidden */
  85448. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85449. /**
  85450. * Sets a texture to the webGL context from a postprocess
  85451. * @param channel defines the channel to use
  85452. * @param postProcess defines the source postprocess
  85453. */
  85454. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85455. /**
  85456. * Binds the output of the passed in post process to the texture channel specified
  85457. * @param channel The channel the texture should be bound to
  85458. * @param postProcess The post process which's output should be bound
  85459. */
  85460. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85461. /**
  85462. * Unbind all textures from the webGL context
  85463. */
  85464. unbindAllTextures(): void;
  85465. /**
  85466. * Sets a texture to the according uniform.
  85467. * @param channel The texture channel
  85468. * @param uniform The uniform to set
  85469. * @param texture The texture to apply
  85470. */
  85471. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85472. /**
  85473. * Sets a depth stencil texture from a render target to the according uniform.
  85474. * @param channel The texture channel
  85475. * @param uniform The uniform to set
  85476. * @param texture The render target texture containing the depth stencil texture to apply
  85477. */
  85478. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85479. private _bindSamplerUniformToChannel;
  85480. private _getTextureWrapMode;
  85481. private _setTexture;
  85482. /**
  85483. * Sets an array of texture to the webGL context
  85484. * @param channel defines the channel where the texture array must be set
  85485. * @param uniform defines the associated uniform location
  85486. * @param textures defines the array of textures to bind
  85487. */
  85488. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85489. /** @hidden */
  85490. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85491. private _setTextureParameterFloat;
  85492. private _setTextureParameterInteger;
  85493. /**
  85494. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85495. * @param x defines the x coordinate of the rectangle where pixels must be read
  85496. * @param y defines the y coordinate of the rectangle where pixels must be read
  85497. * @param width defines the width of the rectangle where pixels must be read
  85498. * @param height defines the height of the rectangle where pixels must be read
  85499. * @returns a Uint8Array containing RGBA colors
  85500. */
  85501. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85502. /**
  85503. * Add an externaly attached data from its key.
  85504. * This method call will fail and return false, if such key already exists.
  85505. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85506. * @param key the unique key that identifies the data
  85507. * @param data the data object to associate to the key for this Engine instance
  85508. * @return true if no such key were already present and the data was added successfully, false otherwise
  85509. */
  85510. addExternalData<T>(key: string, data: T): boolean;
  85511. /**
  85512. * Get an externaly attached data from its key
  85513. * @param key the unique key that identifies the data
  85514. * @return the associated data, if present (can be null), or undefined if not present
  85515. */
  85516. getExternalData<T>(key: string): T;
  85517. /**
  85518. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85519. * @param key the unique key that identifies the data
  85520. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85521. * @return the associated data, can be null if the factory returned null.
  85522. */
  85523. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85524. /**
  85525. * Remove an externaly attached data from the Engine instance
  85526. * @param key the unique key that identifies the data
  85527. * @return true if the data was successfully removed, false if it doesn't exist
  85528. */
  85529. removeExternalData(key: string): boolean;
  85530. /**
  85531. * Unbind all vertex attributes from the webGL context
  85532. */
  85533. unbindAllAttributes(): void;
  85534. /**
  85535. * 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
  85536. */
  85537. releaseEffects(): void;
  85538. /**
  85539. * Dispose and release all associated resources
  85540. */
  85541. dispose(): void;
  85542. /**
  85543. * Display the loading screen
  85544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85545. */
  85546. displayLoadingUI(): void;
  85547. /**
  85548. * Hide the loading screen
  85549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85550. */
  85551. hideLoadingUI(): void;
  85552. /**
  85553. * Gets the current loading screen object
  85554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85555. */
  85556. /**
  85557. * Sets the current loading screen object
  85558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85559. */
  85560. loadingScreen: ILoadingScreen;
  85561. /**
  85562. * Sets the current loading screen text
  85563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85564. */
  85565. loadingUIText: string;
  85566. /**
  85567. * Sets the current loading screen background color
  85568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85569. */
  85570. loadingUIBackgroundColor: string;
  85571. /**
  85572. * Attach a new callback raised when context lost event is fired
  85573. * @param callback defines the callback to call
  85574. */
  85575. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85576. /**
  85577. * Attach a new callback raised when context restored event is fired
  85578. * @param callback defines the callback to call
  85579. */
  85580. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85581. /**
  85582. * Gets the source code of the vertex shader associated with a specific webGL program
  85583. * @param program defines the program to use
  85584. * @returns a string containing the source code of the vertex shader associated with the program
  85585. */
  85586. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85587. /**
  85588. * Gets the source code of the fragment shader associated with a specific webGL program
  85589. * @param program defines the program to use
  85590. * @returns a string containing the source code of the fragment shader associated with the program
  85591. */
  85592. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85593. /**
  85594. * Get the current error code of the webGL context
  85595. * @returns the error code
  85596. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85597. */
  85598. getError(): number;
  85599. /**
  85600. * Gets the current framerate
  85601. * @returns a number representing the framerate
  85602. */
  85603. getFps(): number;
  85604. /**
  85605. * Gets the time spent between current and previous frame
  85606. * @returns a number representing the delta time in ms
  85607. */
  85608. getDeltaTime(): number;
  85609. private _measureFps;
  85610. /** @hidden */
  85611. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85612. private _canRenderToFloatFramebuffer;
  85613. private _canRenderToHalfFloatFramebuffer;
  85614. private _canRenderToFramebuffer;
  85615. /** @hidden */
  85616. _getWebGLTextureType(type: number): number;
  85617. private _getInternalFormat;
  85618. /** @hidden */
  85619. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85620. /** @hidden */
  85621. _getRGBAMultiSampleBufferFormat(type: number): number;
  85622. /** @hidden */
  85623. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  85624. /** @hidden */
  85625. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85626. private _partialLoadFile;
  85627. private _cascadeLoadFiles;
  85628. /**
  85629. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85630. * @returns true if the engine can be created
  85631. * @ignorenaming
  85632. */
  85633. static isSupported(): boolean;
  85634. }
  85635. }
  85636. declare module BABYLON {
  85637. /**
  85638. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85639. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85640. */
  85641. export class EffectFallbacks {
  85642. private _defines;
  85643. private _currentRank;
  85644. private _maxRank;
  85645. private _mesh;
  85646. /**
  85647. * Removes the fallback from the bound mesh.
  85648. */
  85649. unBindMesh(): void;
  85650. /**
  85651. * Adds a fallback on the specified property.
  85652. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85653. * @param define The name of the define in the shader
  85654. */
  85655. addFallback(rank: number, define: string): void;
  85656. /**
  85657. * Sets the mesh to use CPU skinning when needing to fallback.
  85658. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85659. * @param mesh The mesh to use the fallbacks.
  85660. */
  85661. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85662. /**
  85663. * Checks to see if more fallbacks are still availible.
  85664. */
  85665. readonly isMoreFallbacks: boolean;
  85666. /**
  85667. * Removes the defines that shoould be removed when falling back.
  85668. * @param currentDefines defines the current define statements for the shader.
  85669. * @param effect defines the current effect we try to compile
  85670. * @returns The resulting defines with defines of the current rank removed.
  85671. */
  85672. reduce(currentDefines: string, effect: Effect): string;
  85673. }
  85674. /**
  85675. * Options to be used when creating an effect.
  85676. */
  85677. export class EffectCreationOptions {
  85678. /**
  85679. * Atrributes that will be used in the shader.
  85680. */
  85681. attributes: string[];
  85682. /**
  85683. * Uniform varible names that will be set in the shader.
  85684. */
  85685. uniformsNames: string[];
  85686. /**
  85687. * Uniform buffer varible names that will be set in the shader.
  85688. */
  85689. uniformBuffersNames: string[];
  85690. /**
  85691. * Sampler texture variable names that will be set in the shader.
  85692. */
  85693. samplers: string[];
  85694. /**
  85695. * Define statements that will be set in the shader.
  85696. */
  85697. defines: any;
  85698. /**
  85699. * Possible fallbacks for this effect to improve performance when needed.
  85700. */
  85701. fallbacks: Nullable<EffectFallbacks>;
  85702. /**
  85703. * Callback that will be called when the shader is compiled.
  85704. */
  85705. onCompiled: Nullable<(effect: Effect) => void>;
  85706. /**
  85707. * Callback that will be called if an error occurs during shader compilation.
  85708. */
  85709. onError: Nullable<(effect: Effect, errors: string) => void>;
  85710. /**
  85711. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85712. */
  85713. indexParameters: any;
  85714. /**
  85715. * Max number of lights that can be used in the shader.
  85716. */
  85717. maxSimultaneousLights: number;
  85718. /**
  85719. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85720. */
  85721. transformFeedbackVaryings: Nullable<string[]>;
  85722. }
  85723. /**
  85724. * Effect containing vertex and fragment shader that can be executed on an object.
  85725. */
  85726. export class Effect {
  85727. /**
  85728. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85729. */
  85730. static ShadersRepository: string;
  85731. /**
  85732. * Name of the effect.
  85733. */
  85734. name: any;
  85735. /**
  85736. * String container all the define statements that should be set on the shader.
  85737. */
  85738. defines: string;
  85739. /**
  85740. * Callback that will be called when the shader is compiled.
  85741. */
  85742. onCompiled: Nullable<(effect: Effect) => void>;
  85743. /**
  85744. * Callback that will be called if an error occurs during shader compilation.
  85745. */
  85746. onError: Nullable<(effect: Effect, errors: string) => void>;
  85747. /**
  85748. * Callback that will be called when effect is bound.
  85749. */
  85750. onBind: Nullable<(effect: Effect) => void>;
  85751. /**
  85752. * Unique ID of the effect.
  85753. */
  85754. uniqueId: number;
  85755. /**
  85756. * Observable that will be called when the shader is compiled.
  85757. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85758. */
  85759. onCompileObservable: Observable<Effect>;
  85760. /**
  85761. * Observable that will be called if an error occurs during shader compilation.
  85762. */
  85763. onErrorObservable: Observable<Effect>;
  85764. /** @hidden */
  85765. _onBindObservable: Nullable<Observable<Effect>>;
  85766. /**
  85767. * Observable that will be called when effect is bound.
  85768. */
  85769. readonly onBindObservable: Observable<Effect>;
  85770. /** @hidden */
  85771. _bonesComputationForcedToCPU: boolean;
  85772. private static _uniqueIdSeed;
  85773. private _engine;
  85774. private _uniformBuffersNames;
  85775. private _uniformsNames;
  85776. private _samplers;
  85777. private _isReady;
  85778. private _compilationError;
  85779. private _attributesNames;
  85780. private _attributes;
  85781. private _uniforms;
  85782. /**
  85783. * Key for the effect.
  85784. * @hidden
  85785. */
  85786. _key: string;
  85787. private _indexParameters;
  85788. private _fallbacks;
  85789. private _vertexSourceCode;
  85790. private _fragmentSourceCode;
  85791. private _vertexSourceCodeOverride;
  85792. private _fragmentSourceCodeOverride;
  85793. private _transformFeedbackVaryings;
  85794. /**
  85795. * Compiled shader to webGL program.
  85796. * @hidden
  85797. */
  85798. _program: WebGLProgram;
  85799. private _valueCache;
  85800. private static _baseCache;
  85801. /**
  85802. * Instantiates an effect.
  85803. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85804. * @param baseName Name of the effect.
  85805. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85806. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85807. * @param samplers List of sampler variables that will be passed to the shader.
  85808. * @param engine Engine to be used to render the effect
  85809. * @param defines Define statements to be added to the shader.
  85810. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85811. * @param onCompiled Callback that will be called when the shader is compiled.
  85812. * @param onError Callback that will be called if an error occurs during shader compilation.
  85813. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85814. */
  85815. 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);
  85816. /**
  85817. * Unique key for this effect
  85818. */
  85819. readonly key: string;
  85820. /**
  85821. * If the effect has been compiled and prepared.
  85822. * @returns if the effect is compiled and prepared.
  85823. */
  85824. isReady(): boolean;
  85825. /**
  85826. * The engine the effect was initialized with.
  85827. * @returns the engine.
  85828. */
  85829. getEngine(): Engine;
  85830. /**
  85831. * The compiled webGL program for the effect
  85832. * @returns the webGL program.
  85833. */
  85834. getProgram(): WebGLProgram;
  85835. /**
  85836. * The set of names of attribute variables for the shader.
  85837. * @returns An array of attribute names.
  85838. */
  85839. getAttributesNames(): string[];
  85840. /**
  85841. * Returns the attribute at the given index.
  85842. * @param index The index of the attribute.
  85843. * @returns The location of the attribute.
  85844. */
  85845. getAttributeLocation(index: number): number;
  85846. /**
  85847. * Returns the attribute based on the name of the variable.
  85848. * @param name of the attribute to look up.
  85849. * @returns the attribute location.
  85850. */
  85851. getAttributeLocationByName(name: string): number;
  85852. /**
  85853. * The number of attributes.
  85854. * @returns the numnber of attributes.
  85855. */
  85856. getAttributesCount(): number;
  85857. /**
  85858. * Gets the index of a uniform variable.
  85859. * @param uniformName of the uniform to look up.
  85860. * @returns the index.
  85861. */
  85862. getUniformIndex(uniformName: string): number;
  85863. /**
  85864. * Returns the attribute based on the name of the variable.
  85865. * @param uniformName of the uniform to look up.
  85866. * @returns the location of the uniform.
  85867. */
  85868. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85869. /**
  85870. * Returns an array of sampler variable names
  85871. * @returns The array of sampler variable neames.
  85872. */
  85873. getSamplers(): string[];
  85874. /**
  85875. * The error from the last compilation.
  85876. * @returns the error string.
  85877. */
  85878. getCompilationError(): string;
  85879. /**
  85880. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85881. * @param func The callback to be used.
  85882. */
  85883. executeWhenCompiled(func: (effect: Effect) => void): void;
  85884. private _checkIsReady;
  85885. /** @hidden */
  85886. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85887. /** @hidden */
  85888. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85889. /** @hidden */
  85890. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85891. private _processShaderConversion;
  85892. private _processIncludes;
  85893. private _processPrecision;
  85894. /**
  85895. * Recompiles the webGL program
  85896. * @param vertexSourceCode The source code for the vertex shader.
  85897. * @param fragmentSourceCode The source code for the fragment shader.
  85898. * @param onCompiled Callback called when completed.
  85899. * @param onError Callback called on error.
  85900. * @hidden
  85901. */
  85902. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85903. /**
  85904. * Gets the uniform locations of the the specified variable names
  85905. * @param names THe names of the variables to lookup.
  85906. * @returns Array of locations in the same order as variable names.
  85907. */
  85908. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85909. /**
  85910. * Prepares the effect
  85911. * @hidden
  85912. */
  85913. _prepareEffect(): void;
  85914. /**
  85915. * Checks if the effect is supported. (Must be called after compilation)
  85916. */
  85917. readonly isSupported: boolean;
  85918. /**
  85919. * Binds a texture to the engine to be used as output of the shader.
  85920. * @param channel Name of the output variable.
  85921. * @param texture Texture to bind.
  85922. * @hidden
  85923. */
  85924. _bindTexture(channel: string, texture: InternalTexture): void;
  85925. /**
  85926. * Sets a texture on the engine to be used in the shader.
  85927. * @param channel Name of the sampler variable.
  85928. * @param texture Texture to set.
  85929. */
  85930. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85931. /**
  85932. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85933. * @param channel Name of the sampler variable.
  85934. * @param texture Texture to set.
  85935. */
  85936. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85937. /**
  85938. * Sets an array of textures on the engine to be used in the shader.
  85939. * @param channel Name of the variable.
  85940. * @param textures Textures to set.
  85941. */
  85942. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85943. /**
  85944. * 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)
  85945. * @param channel Name of the sampler variable.
  85946. * @param postProcess Post process to get the input texture from.
  85947. */
  85948. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85949. /**
  85950. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85951. * 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)
  85952. * @param channel Name of the sampler variable.
  85953. * @param postProcess Post process to get the output texture from.
  85954. */
  85955. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85956. /** @hidden */
  85957. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85958. /** @hidden */
  85959. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85960. /** @hidden */
  85961. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85962. /** @hidden */
  85963. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85964. /**
  85965. * Binds a buffer to a uniform.
  85966. * @param buffer Buffer to bind.
  85967. * @param name Name of the uniform variable to bind to.
  85968. */
  85969. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85970. /**
  85971. * Binds block to a uniform.
  85972. * @param blockName Name of the block to bind.
  85973. * @param index Index to bind.
  85974. */
  85975. bindUniformBlock(blockName: string, index: number): void;
  85976. /**
  85977. * Sets an interger value on a uniform variable.
  85978. * @param uniformName Name of the variable.
  85979. * @param value Value to be set.
  85980. * @returns this effect.
  85981. */
  85982. setInt(uniformName: string, value: number): Effect;
  85983. /**
  85984. * Sets an int array on a uniform variable.
  85985. * @param uniformName Name of the variable.
  85986. * @param array array to be set.
  85987. * @returns this effect.
  85988. */
  85989. setIntArray(uniformName: string, array: Int32Array): Effect;
  85990. /**
  85991. * 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)
  85992. * @param uniformName Name of the variable.
  85993. * @param array array to be set.
  85994. * @returns this effect.
  85995. */
  85996. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85997. /**
  85998. * 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)
  85999. * @param uniformName Name of the variable.
  86000. * @param array array to be set.
  86001. * @returns this effect.
  86002. */
  86003. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86004. /**
  86005. * 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)
  86006. * @param uniformName Name of the variable.
  86007. * @param array array to be set.
  86008. * @returns this effect.
  86009. */
  86010. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86011. /**
  86012. * Sets an float array on a uniform variable.
  86013. * @param uniformName Name of the variable.
  86014. * @param array array to be set.
  86015. * @returns this effect.
  86016. */
  86017. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86018. /**
  86019. * 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)
  86020. * @param uniformName Name of the variable.
  86021. * @param array array to be set.
  86022. * @returns this effect.
  86023. */
  86024. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86025. /**
  86026. * 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)
  86027. * @param uniformName Name of the variable.
  86028. * @param array array to be set.
  86029. * @returns this effect.
  86030. */
  86031. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86032. /**
  86033. * 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)
  86034. * @param uniformName Name of the variable.
  86035. * @param array array to be set.
  86036. * @returns this effect.
  86037. */
  86038. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86039. /**
  86040. * Sets an array on a uniform variable.
  86041. * @param uniformName Name of the variable.
  86042. * @param array array to be set.
  86043. * @returns this effect.
  86044. */
  86045. setArray(uniformName: string, array: number[]): Effect;
  86046. /**
  86047. * 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)
  86048. * @param uniformName Name of the variable.
  86049. * @param array array to be set.
  86050. * @returns this effect.
  86051. */
  86052. setArray2(uniformName: string, array: number[]): Effect;
  86053. /**
  86054. * 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)
  86055. * @param uniformName Name of the variable.
  86056. * @param array array to be set.
  86057. * @returns this effect.
  86058. */
  86059. setArray3(uniformName: string, array: number[]): Effect;
  86060. /**
  86061. * 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)
  86062. * @param uniformName Name of the variable.
  86063. * @param array array to be set.
  86064. * @returns this effect.
  86065. */
  86066. setArray4(uniformName: string, array: number[]): Effect;
  86067. /**
  86068. * Sets matrices on a uniform variable.
  86069. * @param uniformName Name of the variable.
  86070. * @param matrices matrices to be set.
  86071. * @returns this effect.
  86072. */
  86073. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86074. /**
  86075. * Sets matrix on a uniform variable.
  86076. * @param uniformName Name of the variable.
  86077. * @param matrix matrix to be set.
  86078. * @returns this effect.
  86079. */
  86080. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86081. /**
  86082. * 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)
  86083. * @param uniformName Name of the variable.
  86084. * @param matrix matrix to be set.
  86085. * @returns this effect.
  86086. */
  86087. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86088. /**
  86089. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86090. * @param uniformName Name of the variable.
  86091. * @param matrix matrix to be set.
  86092. * @returns this effect.
  86093. */
  86094. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86095. /**
  86096. * Sets a float on a uniform variable.
  86097. * @param uniformName Name of the variable.
  86098. * @param value value to be set.
  86099. * @returns this effect.
  86100. */
  86101. setFloat(uniformName: string, value: number): Effect;
  86102. /**
  86103. * Sets a boolean on a uniform variable.
  86104. * @param uniformName Name of the variable.
  86105. * @param bool value to be set.
  86106. * @returns this effect.
  86107. */
  86108. setBool(uniformName: string, bool: boolean): Effect;
  86109. /**
  86110. * Sets a Vector2 on a uniform variable.
  86111. * @param uniformName Name of the variable.
  86112. * @param vector2 vector2 to be set.
  86113. * @returns this effect.
  86114. */
  86115. setVector2(uniformName: string, vector2: Vector2): Effect;
  86116. /**
  86117. * Sets a float2 on a uniform variable.
  86118. * @param uniformName Name of the variable.
  86119. * @param x First float in float2.
  86120. * @param y Second float in float2.
  86121. * @returns this effect.
  86122. */
  86123. setFloat2(uniformName: string, x: number, y: number): Effect;
  86124. /**
  86125. * Sets a Vector3 on a uniform variable.
  86126. * @param uniformName Name of the variable.
  86127. * @param vector3 Value to be set.
  86128. * @returns this effect.
  86129. */
  86130. setVector3(uniformName: string, vector3: Vector3): Effect;
  86131. /**
  86132. * Sets a float3 on a uniform variable.
  86133. * @param uniformName Name of the variable.
  86134. * @param x First float in float3.
  86135. * @param y Second float in float3.
  86136. * @param z Third float in float3.
  86137. * @returns this effect.
  86138. */
  86139. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86140. /**
  86141. * Sets a Vector4 on a uniform variable.
  86142. * @param uniformName Name of the variable.
  86143. * @param vector4 Value to be set.
  86144. * @returns this effect.
  86145. */
  86146. setVector4(uniformName: string, vector4: Vector4): Effect;
  86147. /**
  86148. * Sets a float4 on a uniform variable.
  86149. * @param uniformName Name of the variable.
  86150. * @param x First float in float4.
  86151. * @param y Second float in float4.
  86152. * @param z Third float in float4.
  86153. * @param w Fourth float in float4.
  86154. * @returns this effect.
  86155. */
  86156. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86157. /**
  86158. * Sets a Color3 on a uniform variable.
  86159. * @param uniformName Name of the variable.
  86160. * @param color3 Value to be set.
  86161. * @returns this effect.
  86162. */
  86163. setColor3(uniformName: string, color3: Color3): Effect;
  86164. /**
  86165. * Sets a Color4 on a uniform variable.
  86166. * @param uniformName Name of the variable.
  86167. * @param color3 Value to be set.
  86168. * @param alpha Alpha value to be set.
  86169. * @returns this effect.
  86170. */
  86171. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86172. /**
  86173. * Sets a Color4 on a uniform variable
  86174. * @param uniformName defines the name of the variable
  86175. * @param color4 defines the value to be set
  86176. * @returns this effect.
  86177. */
  86178. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86179. /**
  86180. * This function will add a new shader to the shader store
  86181. * @param name the name of the shader
  86182. * @param pixelShader optional pixel shader content
  86183. * @param vertexShader optional vertex shader content
  86184. */
  86185. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86186. /**
  86187. * Store of each shader (The can be looked up using effect.key)
  86188. */
  86189. static ShadersStore: {
  86190. [key: string]: string;
  86191. };
  86192. /**
  86193. * Store of each included file for a shader (The can be looked up using effect.key)
  86194. */
  86195. static IncludesShadersStore: {
  86196. [key: string]: string;
  86197. };
  86198. /**
  86199. * Resets the cache of effects.
  86200. */
  86201. static ResetCache(): void;
  86202. }
  86203. }
  86204. declare module BABYLON {
  86205. /**
  86206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86208. * 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;
  86209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86210. */
  86211. export class ColorCurves {
  86212. private _dirty;
  86213. private _tempColor;
  86214. private _globalCurve;
  86215. private _highlightsCurve;
  86216. private _midtonesCurve;
  86217. private _shadowsCurve;
  86218. private _positiveCurve;
  86219. private _negativeCurve;
  86220. private _globalHue;
  86221. private _globalDensity;
  86222. private _globalSaturation;
  86223. private _globalExposure;
  86224. /**
  86225. * Gets the global Hue value.
  86226. * 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).
  86227. */
  86228. /**
  86229. * Sets the global Hue value.
  86230. * 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).
  86231. */
  86232. globalHue: number;
  86233. /**
  86234. * Gets the global Density value.
  86235. * 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.
  86236. * Values less than zero provide a filter of opposite hue.
  86237. */
  86238. /**
  86239. * Sets the global Density value.
  86240. * 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.
  86241. * Values less than zero provide a filter of opposite hue.
  86242. */
  86243. globalDensity: number;
  86244. /**
  86245. * Gets the global Saturation value.
  86246. * 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.
  86247. */
  86248. /**
  86249. * Sets the global Saturation value.
  86250. * 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.
  86251. */
  86252. globalSaturation: number;
  86253. /**
  86254. * Gets the global Exposure value.
  86255. * 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.
  86256. */
  86257. /**
  86258. * Sets the global Exposure value.
  86259. * 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.
  86260. */
  86261. globalExposure: number;
  86262. private _highlightsHue;
  86263. private _highlightsDensity;
  86264. private _highlightsSaturation;
  86265. private _highlightsExposure;
  86266. /**
  86267. * Gets the highlights Hue value.
  86268. * 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).
  86269. */
  86270. /**
  86271. * Sets the highlights Hue value.
  86272. * 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).
  86273. */
  86274. highlightsHue: number;
  86275. /**
  86276. * Gets the highlights Density value.
  86277. * 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.
  86278. * Values less than zero provide a filter of opposite hue.
  86279. */
  86280. /**
  86281. * Sets the highlights Density value.
  86282. * 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.
  86283. * Values less than zero provide a filter of opposite hue.
  86284. */
  86285. highlightsDensity: number;
  86286. /**
  86287. * Gets the highlights Saturation value.
  86288. * 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.
  86289. */
  86290. /**
  86291. * Sets the highlights Saturation value.
  86292. * 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.
  86293. */
  86294. highlightsSaturation: number;
  86295. /**
  86296. * Gets the highlights Exposure value.
  86297. * 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.
  86298. */
  86299. /**
  86300. * Sets the highlights Exposure value.
  86301. * 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.
  86302. */
  86303. highlightsExposure: number;
  86304. private _midtonesHue;
  86305. private _midtonesDensity;
  86306. private _midtonesSaturation;
  86307. private _midtonesExposure;
  86308. /**
  86309. * Gets the midtones Hue value.
  86310. * 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).
  86311. */
  86312. /**
  86313. * Sets the midtones Hue value.
  86314. * 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).
  86315. */
  86316. midtonesHue: number;
  86317. /**
  86318. * Gets the midtones Density value.
  86319. * 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.
  86320. * Values less than zero provide a filter of opposite hue.
  86321. */
  86322. /**
  86323. * Sets the midtones Density value.
  86324. * 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.
  86325. * Values less than zero provide a filter of opposite hue.
  86326. */
  86327. midtonesDensity: number;
  86328. /**
  86329. * Gets the midtones Saturation value.
  86330. * 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.
  86331. */
  86332. /**
  86333. * Sets the midtones Saturation value.
  86334. * 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.
  86335. */
  86336. midtonesSaturation: number;
  86337. /**
  86338. * Gets the midtones Exposure value.
  86339. * 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.
  86340. */
  86341. /**
  86342. * Sets the midtones Exposure value.
  86343. * 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.
  86344. */
  86345. midtonesExposure: number;
  86346. private _shadowsHue;
  86347. private _shadowsDensity;
  86348. private _shadowsSaturation;
  86349. private _shadowsExposure;
  86350. /**
  86351. * Gets the shadows Hue value.
  86352. * 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).
  86353. */
  86354. /**
  86355. * Sets the shadows Hue value.
  86356. * 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).
  86357. */
  86358. shadowsHue: number;
  86359. /**
  86360. * Gets the shadows Density value.
  86361. * 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.
  86362. * Values less than zero provide a filter of opposite hue.
  86363. */
  86364. /**
  86365. * Sets the shadows Density value.
  86366. * 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.
  86367. * Values less than zero provide a filter of opposite hue.
  86368. */
  86369. shadowsDensity: number;
  86370. /**
  86371. * Gets the shadows Saturation value.
  86372. * 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.
  86373. */
  86374. /**
  86375. * Sets the shadows Saturation value.
  86376. * 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.
  86377. */
  86378. shadowsSaturation: number;
  86379. /**
  86380. * Gets the shadows Exposure value.
  86381. * 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.
  86382. */
  86383. /**
  86384. * Sets the shadows Exposure value.
  86385. * 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.
  86386. */
  86387. shadowsExposure: number;
  86388. /**
  86389. * Returns the class name
  86390. * @returns The class name
  86391. */
  86392. getClassName(): string;
  86393. /**
  86394. * Binds the color curves to the shader.
  86395. * @param colorCurves The color curve to bind
  86396. * @param effect The effect to bind to
  86397. * @param positiveUniform The positive uniform shader parameter
  86398. * @param neutralUniform The neutral uniform shader parameter
  86399. * @param negativeUniform The negative uniform shader parameter
  86400. */
  86401. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86402. /**
  86403. * Prepare the list of uniforms associated with the ColorCurves effects.
  86404. * @param uniformsList The list of uniforms used in the effect
  86405. */
  86406. static PrepareUniforms(uniformsList: string[]): void;
  86407. /**
  86408. * Returns color grading data based on a hue, density, saturation and exposure value.
  86409. * @param filterHue The hue of the color filter.
  86410. * @param filterDensity The density of the color filter.
  86411. * @param saturation The saturation.
  86412. * @param exposure The exposure.
  86413. * @param result The result data container.
  86414. */
  86415. private getColorGradingDataToRef;
  86416. /**
  86417. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86418. * @param value The input slider value in range [-100,100].
  86419. * @returns Adjusted value.
  86420. */
  86421. private static applyColorGradingSliderNonlinear;
  86422. /**
  86423. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86424. * @param hue The hue (H) input.
  86425. * @param saturation The saturation (S) input.
  86426. * @param brightness The brightness (B) input.
  86427. * @result An RGBA color represented as Vector4.
  86428. */
  86429. private static fromHSBToRef;
  86430. /**
  86431. * Returns a value clamped between min and max
  86432. * @param value The value to clamp
  86433. * @param min The minimum of value
  86434. * @param max The maximum of value
  86435. * @returns The clamped value.
  86436. */
  86437. private static clamp;
  86438. /**
  86439. * Clones the current color curve instance.
  86440. * @return The cloned curves
  86441. */
  86442. clone(): ColorCurves;
  86443. /**
  86444. * Serializes the current color curve instance to a json representation.
  86445. * @return a JSON representation
  86446. */
  86447. serialize(): any;
  86448. /**
  86449. * Parses the color curve from a json representation.
  86450. * @param source the JSON source to parse
  86451. * @return The parsed curves
  86452. */
  86453. static Parse(source: any): ColorCurves;
  86454. }
  86455. }
  86456. declare module BABYLON {
  86457. /**
  86458. * Interface to follow in your material defines to integrate easily the
  86459. * Image proccessing functions.
  86460. * @hidden
  86461. */
  86462. export interface IImageProcessingConfigurationDefines {
  86463. IMAGEPROCESSING: boolean;
  86464. VIGNETTE: boolean;
  86465. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86466. VIGNETTEBLENDMODEOPAQUE: boolean;
  86467. TONEMAPPING: boolean;
  86468. TONEMAPPING_ACES: boolean;
  86469. CONTRAST: boolean;
  86470. EXPOSURE: boolean;
  86471. COLORCURVES: boolean;
  86472. COLORGRADING: boolean;
  86473. COLORGRADING3D: boolean;
  86474. SAMPLER3DGREENDEPTH: boolean;
  86475. SAMPLER3DBGRMAP: boolean;
  86476. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86477. }
  86478. /**
  86479. * @hidden
  86480. */
  86481. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86482. IMAGEPROCESSING: boolean;
  86483. VIGNETTE: boolean;
  86484. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86485. VIGNETTEBLENDMODEOPAQUE: boolean;
  86486. TONEMAPPING: boolean;
  86487. TONEMAPPING_ACES: boolean;
  86488. CONTRAST: boolean;
  86489. COLORCURVES: boolean;
  86490. COLORGRADING: boolean;
  86491. COLORGRADING3D: boolean;
  86492. SAMPLER3DGREENDEPTH: boolean;
  86493. SAMPLER3DBGRMAP: boolean;
  86494. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86495. EXPOSURE: boolean;
  86496. constructor();
  86497. }
  86498. /**
  86499. * This groups together the common properties used for image processing either in direct forward pass
  86500. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86501. * or not.
  86502. */
  86503. export class ImageProcessingConfiguration {
  86504. /**
  86505. * Default tone mapping applied in BabylonJS.
  86506. */
  86507. static readonly TONEMAPPING_STANDARD: number;
  86508. /**
  86509. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86510. * to other engines rendering to increase portability.
  86511. */
  86512. static readonly TONEMAPPING_ACES: number;
  86513. /**
  86514. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86515. */
  86516. colorCurves: Nullable<ColorCurves>;
  86517. private _colorCurvesEnabled;
  86518. /**
  86519. * Gets wether the color curves effect is enabled.
  86520. */
  86521. /**
  86522. * Sets wether the color curves effect is enabled.
  86523. */
  86524. colorCurvesEnabled: boolean;
  86525. private _colorGradingTexture;
  86526. /**
  86527. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86528. */
  86529. /**
  86530. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86531. */
  86532. colorGradingTexture: Nullable<BaseTexture>;
  86533. private _colorGradingEnabled;
  86534. /**
  86535. * Gets wether the color grading effect is enabled.
  86536. */
  86537. /**
  86538. * Sets wether the color grading effect is enabled.
  86539. */
  86540. colorGradingEnabled: boolean;
  86541. private _colorGradingWithGreenDepth;
  86542. /**
  86543. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86544. */
  86545. /**
  86546. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86547. */
  86548. colorGradingWithGreenDepth: boolean;
  86549. private _colorGradingBGR;
  86550. /**
  86551. * Gets wether the color grading texture contains BGR values.
  86552. */
  86553. /**
  86554. * Sets wether the color grading texture contains BGR values.
  86555. */
  86556. colorGradingBGR: boolean;
  86557. /** @hidden */
  86558. _exposure: number;
  86559. /**
  86560. * Gets the Exposure used in the effect.
  86561. */
  86562. /**
  86563. * Sets the Exposure used in the effect.
  86564. */
  86565. exposure: number;
  86566. private _toneMappingEnabled;
  86567. /**
  86568. * Gets wether the tone mapping effect is enabled.
  86569. */
  86570. /**
  86571. * Sets wether the tone mapping effect is enabled.
  86572. */
  86573. toneMappingEnabled: boolean;
  86574. private _toneMappingType;
  86575. /**
  86576. * Gets the type of tone mapping effect.
  86577. */
  86578. /**
  86579. * Sets the type of tone mapping effect used in BabylonJS.
  86580. */
  86581. toneMappingType: number;
  86582. protected _contrast: number;
  86583. /**
  86584. * Gets the contrast used in the effect.
  86585. */
  86586. /**
  86587. * Sets the contrast used in the effect.
  86588. */
  86589. contrast: number;
  86590. /**
  86591. * Vignette stretch size.
  86592. */
  86593. vignetteStretch: number;
  86594. /**
  86595. * Vignette centre X Offset.
  86596. */
  86597. vignetteCentreX: number;
  86598. /**
  86599. * Vignette centre Y Offset.
  86600. */
  86601. vignetteCentreY: number;
  86602. /**
  86603. * Vignette weight or intensity of the vignette effect.
  86604. */
  86605. vignetteWeight: number;
  86606. /**
  86607. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86608. * if vignetteEnabled is set to true.
  86609. */
  86610. vignetteColor: Color4;
  86611. /**
  86612. * Camera field of view used by the Vignette effect.
  86613. */
  86614. vignetteCameraFov: number;
  86615. private _vignetteBlendMode;
  86616. /**
  86617. * Gets the vignette blend mode allowing different kind of effect.
  86618. */
  86619. /**
  86620. * Sets the vignette blend mode allowing different kind of effect.
  86621. */
  86622. vignetteBlendMode: number;
  86623. private _vignetteEnabled;
  86624. /**
  86625. * Gets wether the vignette effect is enabled.
  86626. */
  86627. /**
  86628. * Sets wether the vignette effect is enabled.
  86629. */
  86630. vignetteEnabled: boolean;
  86631. private _applyByPostProcess;
  86632. /**
  86633. * Gets wether the image processing is applied through a post process or not.
  86634. */
  86635. /**
  86636. * Sets wether the image processing is applied through a post process or not.
  86637. */
  86638. applyByPostProcess: boolean;
  86639. private _isEnabled;
  86640. /**
  86641. * Gets wether the image processing is enabled or not.
  86642. */
  86643. /**
  86644. * Sets wether the image processing is enabled or not.
  86645. */
  86646. isEnabled: boolean;
  86647. /**
  86648. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86649. */
  86650. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86651. /**
  86652. * Method called each time the image processing information changes requires to recompile the effect.
  86653. */
  86654. protected _updateParameters(): void;
  86655. /**
  86656. * Gets the current class name.
  86657. * @return "ImageProcessingConfiguration"
  86658. */
  86659. getClassName(): string;
  86660. /**
  86661. * Prepare the list of uniforms associated with the Image Processing effects.
  86662. * @param uniforms The list of uniforms used in the effect
  86663. * @param defines the list of defines currently in use
  86664. */
  86665. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86666. /**
  86667. * Prepare the list of samplers associated with the Image Processing effects.
  86668. * @param samplersList The list of uniforms used in the effect
  86669. * @param defines the list of defines currently in use
  86670. */
  86671. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86672. /**
  86673. * Prepare the list of defines associated to the shader.
  86674. * @param defines the list of defines to complete
  86675. * @param forPostProcess Define if we are currently in post process mode or not
  86676. */
  86677. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86678. /**
  86679. * Returns true if all the image processing information are ready.
  86680. * @returns True if ready, otherwise, false
  86681. */
  86682. isReady(): boolean;
  86683. /**
  86684. * Binds the image processing to the shader.
  86685. * @param effect The effect to bind to
  86686. * @param aspectRatio Define the current aspect ratio of the effect
  86687. */
  86688. bind(effect: Effect, aspectRatio?: number): void;
  86689. /**
  86690. * Clones the current image processing instance.
  86691. * @return The cloned image processing
  86692. */
  86693. clone(): ImageProcessingConfiguration;
  86694. /**
  86695. * Serializes the current image processing instance to a json representation.
  86696. * @return a JSON representation
  86697. */
  86698. serialize(): any;
  86699. /**
  86700. * Parses the image processing from a json representation.
  86701. * @param source the JSON source to parse
  86702. * @return The parsed image processing
  86703. */
  86704. static Parse(source: any): ImageProcessingConfiguration;
  86705. private static _VIGNETTEMODE_MULTIPLY;
  86706. private static _VIGNETTEMODE_OPAQUE;
  86707. /**
  86708. * Used to apply the vignette as a mix with the pixel color.
  86709. */
  86710. static readonly VIGNETTEMODE_MULTIPLY: number;
  86711. /**
  86712. * Used to apply the vignette as a replacement of the pixel color.
  86713. */
  86714. static readonly VIGNETTEMODE_OPAQUE: number;
  86715. }
  86716. }
  86717. declare module BABYLON {
  86718. /**
  86719. * This represents all the required information to add a fresnel effect on a material:
  86720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86721. */
  86722. export class FresnelParameters {
  86723. private _isEnabled;
  86724. /**
  86725. * Define if the fresnel effect is enable or not.
  86726. */
  86727. isEnabled: boolean;
  86728. /**
  86729. * Define the color used on edges (grazing angle)
  86730. */
  86731. leftColor: Color3;
  86732. /**
  86733. * Define the color used on center
  86734. */
  86735. rightColor: Color3;
  86736. /**
  86737. * Define bias applied to computed fresnel term
  86738. */
  86739. bias: number;
  86740. /**
  86741. * Defined the power exponent applied to fresnel term
  86742. */
  86743. power: number;
  86744. /**
  86745. * Clones the current fresnel and its valuues
  86746. * @returns a clone fresnel configuration
  86747. */
  86748. clone(): FresnelParameters;
  86749. /**
  86750. * Serializes the current fresnel parameters to a JSON representation.
  86751. * @return the JSON serialization
  86752. */
  86753. serialize(): any;
  86754. /**
  86755. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86756. * @param parsedFresnelParameters Define the JSON representation
  86757. * @returns the parsed parameters
  86758. */
  86759. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86760. }
  86761. }
  86762. declare module BABYLON {
  86763. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86764. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86765. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86766. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86767. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86768. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86769. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86770. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86771. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86772. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86773. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86774. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86775. /**
  86776. * Decorator used to define property that can be serialized as reference to a camera
  86777. * @param sourceName defines the name of the property to decorate
  86778. */
  86779. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86780. /**
  86781. * Class used to help serialization objects
  86782. */
  86783. export class SerializationHelper {
  86784. /** hidden */
  86785. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86786. /** hidden */
  86787. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86788. /** hidden */
  86789. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86790. /** hidden */
  86791. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86792. /**
  86793. * Appends the serialized animations from the source animations
  86794. * @param source Source containing the animations
  86795. * @param destination Target to store the animations
  86796. */
  86797. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86798. /**
  86799. * Static function used to serialized a specific entity
  86800. * @param entity defines the entity to serialize
  86801. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86802. * @returns a JSON compatible object representing the serialization of the entity
  86803. */
  86804. static Serialize<T>(entity: T, serializationObject?: any): any;
  86805. /**
  86806. * Creates a new entity from a serialization data object
  86807. * @param creationFunction defines a function used to instanciated the new entity
  86808. * @param source defines the source serialization data
  86809. * @param scene defines the hosting scene
  86810. * @param rootUrl defines the root url for resources
  86811. * @returns a new entity
  86812. */
  86813. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86814. /**
  86815. * Clones an object
  86816. * @param creationFunction defines the function used to instanciate the new object
  86817. * @param source defines the source object
  86818. * @returns the cloned object
  86819. */
  86820. static Clone<T>(creationFunction: () => T, source: T): T;
  86821. /**
  86822. * Instanciates a new object based on a source one (some data will be shared between both object)
  86823. * @param creationFunction defines the function used to instanciate the new object
  86824. * @param source defines the source object
  86825. * @returns the new object
  86826. */
  86827. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86828. }
  86829. }
  86830. declare module BABYLON {
  86831. /**
  86832. * This is the base class of all the camera used in the application.
  86833. * @see http://doc.babylonjs.com/features/cameras
  86834. */
  86835. export class Camera extends Node {
  86836. /** @hidden */
  86837. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86838. /**
  86839. * This is the default projection mode used by the cameras.
  86840. * It helps recreating a feeling of perspective and better appreciate depth.
  86841. * This is the best way to simulate real life cameras.
  86842. */
  86843. static readonly PERSPECTIVE_CAMERA: number;
  86844. /**
  86845. * This helps creating camera with an orthographic mode.
  86846. * 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.
  86847. */
  86848. static readonly ORTHOGRAPHIC_CAMERA: number;
  86849. /**
  86850. * This is the default FOV mode for perspective cameras.
  86851. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86852. */
  86853. static readonly FOVMODE_VERTICAL_FIXED: number;
  86854. /**
  86855. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86856. */
  86857. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86858. /**
  86859. * This specifies ther is no need for a camera rig.
  86860. * Basically only one eye is rendered corresponding to the camera.
  86861. */
  86862. static readonly RIG_MODE_NONE: number;
  86863. /**
  86864. * Simulates a camera Rig with one blue eye and one red eye.
  86865. * This can be use with 3d blue and red glasses.
  86866. */
  86867. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86868. /**
  86869. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86870. */
  86871. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86872. /**
  86873. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86874. */
  86875. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86876. /**
  86877. * Defines that both eyes of the camera will be rendered over under each other.
  86878. */
  86879. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86880. /**
  86881. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86882. */
  86883. static readonly RIG_MODE_VR: number;
  86884. /**
  86885. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86886. */
  86887. static readonly RIG_MODE_WEBVR: number;
  86888. /**
  86889. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86890. */
  86891. static readonly RIG_MODE_CUSTOM: number;
  86892. /**
  86893. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86894. */
  86895. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86896. /**
  86897. * @hidden
  86898. * Might be removed once multiview will be a thing
  86899. */
  86900. static UseAlternateWebVRRendering: boolean;
  86901. /**
  86902. * Define the input manager associated with the camera.
  86903. */
  86904. inputs: CameraInputsManager<Camera>;
  86905. /** @hidden */
  86906. _position: Vector3;
  86907. /**
  86908. * Define the current local position of the camera in the scene
  86909. */
  86910. position: Vector3;
  86911. /**
  86912. * The vector the camera should consider as up.
  86913. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86914. */
  86915. upVector: Vector3;
  86916. /**
  86917. * Define the current limit on the left side for an orthographic camera
  86918. * In scene unit
  86919. */
  86920. orthoLeft: Nullable<number>;
  86921. /**
  86922. * Define the current limit on the right side for an orthographic camera
  86923. * In scene unit
  86924. */
  86925. orthoRight: Nullable<number>;
  86926. /**
  86927. * Define the current limit on the bottom side for an orthographic camera
  86928. * In scene unit
  86929. */
  86930. orthoBottom: Nullable<number>;
  86931. /**
  86932. * Define the current limit on the top side for an orthographic camera
  86933. * In scene unit
  86934. */
  86935. orthoTop: Nullable<number>;
  86936. /**
  86937. * Field Of View is set in Radians. (default is 0.8)
  86938. */
  86939. fov: number;
  86940. /**
  86941. * Define the minimum distance the camera can see from.
  86942. * This is important to note that the depth buffer are not infinite and the closer it starts
  86943. * the more your scene might encounter depth fighting issue.
  86944. */
  86945. minZ: number;
  86946. /**
  86947. * Define the maximum distance the camera can see to.
  86948. * This is important to note that the depth buffer are not infinite and the further it end
  86949. * the more your scene might encounter depth fighting issue.
  86950. */
  86951. maxZ: number;
  86952. /**
  86953. * Define the default inertia of the camera.
  86954. * This helps giving a smooth feeling to the camera movement.
  86955. */
  86956. inertia: number;
  86957. /**
  86958. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86959. */
  86960. mode: number;
  86961. /**
  86962. * Define wether the camera is intermediate.
  86963. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86964. */
  86965. isIntermediate: boolean;
  86966. /**
  86967. * Define the viewport of the camera.
  86968. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86969. */
  86970. viewport: Viewport;
  86971. /**
  86972. * Restricts the camera to viewing objects with the same layerMask.
  86973. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86974. */
  86975. layerMask: number;
  86976. /**
  86977. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86978. */
  86979. fovMode: number;
  86980. /**
  86981. * Rig mode of the camera.
  86982. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86983. * This is normally controlled byt the camera themselves as internal use.
  86984. */
  86985. cameraRigMode: number;
  86986. /**
  86987. * Defines the distance between both "eyes" in case of a RIG
  86988. */
  86989. interaxialDistance: number;
  86990. /**
  86991. * Defines if stereoscopic rendering is done side by side or over under.
  86992. */
  86993. isStereoscopicSideBySide: boolean;
  86994. /**
  86995. * 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
  86996. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86997. * else in the scene.
  86998. */
  86999. customRenderTargets: RenderTargetTexture[];
  87000. /**
  87001. * When set, the camera will render to this render target instead of the default canvas
  87002. */
  87003. outputRenderTarget: Nullable<RenderTargetTexture>;
  87004. /**
  87005. * Observable triggered when the camera view matrix has changed.
  87006. */
  87007. onViewMatrixChangedObservable: Observable<Camera>;
  87008. /**
  87009. * Observable triggered when the camera Projection matrix has changed.
  87010. */
  87011. onProjectionMatrixChangedObservable: Observable<Camera>;
  87012. /**
  87013. * Observable triggered when the inputs have been processed.
  87014. */
  87015. onAfterCheckInputsObservable: Observable<Camera>;
  87016. /**
  87017. * Observable triggered when reset has been called and applied to the camera.
  87018. */
  87019. onRestoreStateObservable: Observable<Camera>;
  87020. /** @hidden */
  87021. _cameraRigParams: any;
  87022. /** @hidden */
  87023. _rigCameras: Camera[];
  87024. /** @hidden */
  87025. _rigPostProcess: Nullable<PostProcess>;
  87026. protected _webvrViewMatrix: Matrix;
  87027. /** @hidden */
  87028. _skipRendering: boolean;
  87029. /** @hidden */
  87030. _alternateCamera: Camera;
  87031. /** @hidden */
  87032. _projectionMatrix: Matrix;
  87033. /** @hidden */
  87034. _postProcesses: Nullable<PostProcess>[];
  87035. /** @hidden */
  87036. _activeMeshes: SmartArray<AbstractMesh>;
  87037. protected _globalPosition: Vector3;
  87038. /** hidden */
  87039. _computedViewMatrix: Matrix;
  87040. private _doNotComputeProjectionMatrix;
  87041. private _transformMatrix;
  87042. private _frustumPlanes;
  87043. private _refreshFrustumPlanes;
  87044. private _storedFov;
  87045. private _stateStored;
  87046. /**
  87047. * Instantiates a new camera object.
  87048. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87049. * @see http://doc.babylonjs.com/features/cameras
  87050. * @param name Defines the name of the camera in the scene
  87051. * @param position Defines the position of the camera
  87052. * @param scene Defines the scene the camera belongs too
  87053. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87054. */
  87055. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87056. /**
  87057. * Store current camera state (fov, position, etc..)
  87058. * @returns the camera
  87059. */
  87060. storeState(): Camera;
  87061. /**
  87062. * Restores the camera state values if it has been stored. You must call storeState() first
  87063. */
  87064. protected _restoreStateValues(): boolean;
  87065. /**
  87066. * Restored camera state. You must call storeState() first.
  87067. * @returns true if restored and false otherwise
  87068. */
  87069. restoreState(): boolean;
  87070. /**
  87071. * Gets the class name of the camera.
  87072. * @returns the class name
  87073. */
  87074. getClassName(): string;
  87075. /** @hidden */
  87076. readonly _isCamera: boolean;
  87077. /**
  87078. * Gets a string representation of the camera useful for debug purpose.
  87079. * @param fullDetails Defines that a more verboe level of logging is required
  87080. * @returns the string representation
  87081. */
  87082. toString(fullDetails?: boolean): string;
  87083. /**
  87084. * Gets the current world space position of the camera.
  87085. */
  87086. readonly globalPosition: Vector3;
  87087. /**
  87088. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87089. * @returns the active meshe list
  87090. */
  87091. getActiveMeshes(): SmartArray<AbstractMesh>;
  87092. /**
  87093. * Check wether a mesh is part of the current active mesh list of the camera
  87094. * @param mesh Defines the mesh to check
  87095. * @returns true if active, false otherwise
  87096. */
  87097. isActiveMesh(mesh: Mesh): boolean;
  87098. /**
  87099. * Is this camera ready to be used/rendered
  87100. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87101. * @return true if the camera is ready
  87102. */
  87103. isReady(completeCheck?: boolean): boolean;
  87104. /** @hidden */
  87105. _initCache(): void;
  87106. /** @hidden */
  87107. _updateCache(ignoreParentClass?: boolean): void;
  87108. /** @hidden */
  87109. _isSynchronized(): boolean;
  87110. /** @hidden */
  87111. _isSynchronizedViewMatrix(): boolean;
  87112. /** @hidden */
  87113. _isSynchronizedProjectionMatrix(): boolean;
  87114. /**
  87115. * Attach the input controls to a specific dom element to get the input from.
  87116. * @param element Defines the element the controls should be listened from
  87117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87118. */
  87119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87120. /**
  87121. * Detach the current controls from the specified dom element.
  87122. * @param element Defines the element to stop listening the inputs from
  87123. */
  87124. detachControl(element: HTMLElement): void;
  87125. /**
  87126. * Update the camera state according to the different inputs gathered during the frame.
  87127. */
  87128. update(): void;
  87129. /** @hidden */
  87130. _checkInputs(): void;
  87131. /** @hidden */
  87132. readonly rigCameras: Camera[];
  87133. /**
  87134. * Gets the post process used by the rig cameras
  87135. */
  87136. readonly rigPostProcess: Nullable<PostProcess>;
  87137. /**
  87138. * Internal, gets the first post proces.
  87139. * @returns the first post process to be run on this camera.
  87140. */
  87141. _getFirstPostProcess(): Nullable<PostProcess>;
  87142. private _cascadePostProcessesToRigCams;
  87143. /**
  87144. * Attach a post process to the camera.
  87145. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87146. * @param postProcess The post process to attach to the camera
  87147. * @param insertAt The position of the post process in case several of them are in use in the scene
  87148. * @returns the position the post process has been inserted at
  87149. */
  87150. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87151. /**
  87152. * Detach a post process to the camera.
  87153. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87154. * @param postProcess The post process to detach from the camera
  87155. */
  87156. detachPostProcess(postProcess: PostProcess): void;
  87157. /**
  87158. * Gets the current world matrix of the camera
  87159. */
  87160. getWorldMatrix(): Matrix;
  87161. /** @hidden */
  87162. _getViewMatrix(): Matrix;
  87163. /**
  87164. * Gets the current view matrix of the camera.
  87165. * @param force forces the camera to recompute the matrix without looking at the cached state
  87166. * @returns the view matrix
  87167. */
  87168. getViewMatrix(force?: boolean): Matrix;
  87169. /**
  87170. * Freeze the projection matrix.
  87171. * It will prevent the cache check of the camera projection compute and can speed up perf
  87172. * if no parameter of the camera are meant to change
  87173. * @param projection Defines manually a projection if necessary
  87174. */
  87175. freezeProjectionMatrix(projection?: Matrix): void;
  87176. /**
  87177. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87178. */
  87179. unfreezeProjectionMatrix(): void;
  87180. /**
  87181. * Gets the current projection matrix of the camera.
  87182. * @param force forces the camera to recompute the matrix without looking at the cached state
  87183. * @returns the projection matrix
  87184. */
  87185. getProjectionMatrix(force?: boolean): Matrix;
  87186. /**
  87187. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87188. * @returns a Matrix
  87189. */
  87190. getTransformationMatrix(): Matrix;
  87191. private _updateFrustumPlanes;
  87192. /**
  87193. * Checks if a cullable object (mesh...) is in the camera frustum
  87194. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87195. * @param target The object to check
  87196. * @returns true if the object is in frustum otherwise false
  87197. */
  87198. isInFrustum(target: ICullable): boolean;
  87199. /**
  87200. * Checks if a cullable object (mesh...) is in the camera frustum
  87201. * Unlike isInFrustum this cheks the full bounding box
  87202. * @param target The object to check
  87203. * @returns true if the object is in frustum otherwise false
  87204. */
  87205. isCompletelyInFrustum(target: ICullable): boolean;
  87206. /**
  87207. * Gets a ray in the forward direction from the camera.
  87208. * @param length Defines the length of the ray to create
  87209. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87210. * @param origin Defines the start point of the ray which defaults to the camera position
  87211. * @returns the forward ray
  87212. */
  87213. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87214. /**
  87215. * Releases resources associated with this node.
  87216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87218. */
  87219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87220. /** @hidden */
  87221. _isLeftCamera: boolean;
  87222. /**
  87223. * Gets the left camera of a rig setup in case of Rigged Camera
  87224. */
  87225. readonly isLeftCamera: boolean;
  87226. /** @hidden */
  87227. _isRightCamera: boolean;
  87228. /**
  87229. * Gets the right camera of a rig setup in case of Rigged Camera
  87230. */
  87231. readonly isRightCamera: boolean;
  87232. /**
  87233. * Gets the left camera of a rig setup in case of Rigged Camera
  87234. */
  87235. readonly leftCamera: Nullable<FreeCamera>;
  87236. /**
  87237. * Gets the right camera of a rig setup in case of Rigged Camera
  87238. */
  87239. readonly rightCamera: Nullable<FreeCamera>;
  87240. /**
  87241. * Gets the left camera target of a rig setup in case of Rigged Camera
  87242. * @returns the target position
  87243. */
  87244. getLeftTarget(): Nullable<Vector3>;
  87245. /**
  87246. * Gets the right camera target of a rig setup in case of Rigged Camera
  87247. * @returns the target position
  87248. */
  87249. getRightTarget(): Nullable<Vector3>;
  87250. /**
  87251. * @hidden
  87252. */
  87253. setCameraRigMode(mode: number, rigParams: any): void;
  87254. /** @hidden */
  87255. static _setStereoscopicRigMode(camera: Camera): void;
  87256. /** @hidden */
  87257. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87258. /** @hidden */
  87259. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87260. /** @hidden */
  87261. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87262. /** @hidden */
  87263. _getVRProjectionMatrix(): Matrix;
  87264. protected _updateCameraRotationMatrix(): void;
  87265. protected _updateWebVRCameraRotationMatrix(): void;
  87266. /**
  87267. * This function MUST be overwritten by the different WebVR cameras available.
  87268. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87269. * @hidden
  87270. */
  87271. _getWebVRProjectionMatrix(): Matrix;
  87272. /**
  87273. * This function MUST be overwritten by the different WebVR cameras available.
  87274. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87275. * @hidden
  87276. */
  87277. _getWebVRViewMatrix(): Matrix;
  87278. /** @hidden */
  87279. setCameraRigParameter(name: string, value: any): void;
  87280. /**
  87281. * needs to be overridden by children so sub has required properties to be copied
  87282. * @hidden
  87283. */
  87284. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87285. /**
  87286. * May need to be overridden by children
  87287. * @hidden
  87288. */
  87289. _updateRigCameras(): void;
  87290. /** @hidden */
  87291. _setupInputs(): void;
  87292. /**
  87293. * Serialiaze the camera setup to a json represention
  87294. * @returns the JSON representation
  87295. */
  87296. serialize(): any;
  87297. /**
  87298. * Clones the current camera.
  87299. * @param name The cloned camera name
  87300. * @returns the cloned camera
  87301. */
  87302. clone(name: string): Camera;
  87303. /**
  87304. * Gets the direction of the camera relative to a given local axis.
  87305. * @param localAxis Defines the reference axis to provide a relative direction.
  87306. * @return the direction
  87307. */
  87308. getDirection(localAxis: Vector3): Vector3;
  87309. /**
  87310. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87311. * @param localAxis Defines the reference axis to provide a relative direction.
  87312. * @param result Defines the vector to store the result in
  87313. */
  87314. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87315. /**
  87316. * Gets a camera constructor for a given camera type
  87317. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87318. * @param name The name of the camera the result will be able to instantiate
  87319. * @param scene The scene the result will construct the camera in
  87320. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87321. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87322. * @returns a factory method to construc the camera
  87323. */
  87324. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87325. /**
  87326. * Compute the world matrix of the camera.
  87327. * @returns the camera workd matrix
  87328. */
  87329. computeWorldMatrix(): Matrix;
  87330. /**
  87331. * Parse a JSON and creates the camera from the parsed information
  87332. * @param parsedCamera The JSON to parse
  87333. * @param scene The scene to instantiate the camera in
  87334. * @returns the newly constructed camera
  87335. */
  87336. static Parse(parsedCamera: any, scene: Scene): Camera;
  87337. }
  87338. }
  87339. declare module BABYLON {
  87340. /**
  87341. * Interface for any object that can request an animation frame
  87342. */
  87343. export interface ICustomAnimationFrameRequester {
  87344. /**
  87345. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87346. */
  87347. renderFunction?: Function;
  87348. /**
  87349. * Called to request the next frame to render to
  87350. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87351. */
  87352. requestAnimationFrame: Function;
  87353. /**
  87354. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87355. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87356. */
  87357. requestID?: number;
  87358. }
  87359. /**
  87360. * Interface containing an array of animations
  87361. */
  87362. export interface IAnimatable {
  87363. /**
  87364. * Array of animations
  87365. */
  87366. animations: Array<Animation>;
  87367. }
  87368. /** Interface used by value gradients (color, factor, ...) */
  87369. export interface IValueGradient {
  87370. /**
  87371. * Gets or sets the gradient value (between 0 and 1)
  87372. */
  87373. gradient: number;
  87374. }
  87375. /** Class used to store color4 gradient */
  87376. export class ColorGradient implements IValueGradient {
  87377. /**
  87378. * Gets or sets the gradient value (between 0 and 1)
  87379. */
  87380. gradient: number;
  87381. /**
  87382. * Gets or sets first associated color
  87383. */
  87384. color1: Color4;
  87385. /**
  87386. * Gets or sets second associated color
  87387. */
  87388. color2?: Color4;
  87389. /**
  87390. * Will get a color picked randomly between color1 and color2.
  87391. * If color2 is undefined then color1 will be used
  87392. * @param result defines the target Color4 to store the result in
  87393. */
  87394. getColorToRef(result: Color4): void;
  87395. }
  87396. /** Class used to store color 3 gradient */
  87397. export class Color3Gradient implements IValueGradient {
  87398. /**
  87399. * Gets or sets the gradient value (between 0 and 1)
  87400. */
  87401. gradient: number;
  87402. /**
  87403. * Gets or sets the associated color
  87404. */
  87405. color: Color3;
  87406. }
  87407. /** Class used to store factor gradient */
  87408. export class FactorGradient implements IValueGradient {
  87409. /**
  87410. * Gets or sets the gradient value (between 0 and 1)
  87411. */
  87412. gradient: number;
  87413. /**
  87414. * Gets or sets first associated factor
  87415. */
  87416. factor1: number;
  87417. /**
  87418. * Gets or sets second associated factor
  87419. */
  87420. factor2?: number;
  87421. /**
  87422. * Will get a number picked randomly between factor1 and factor2.
  87423. * If factor2 is undefined then factor1 will be used
  87424. * @returns the picked number
  87425. */
  87426. getFactor(): number;
  87427. }
  87428. /**
  87429. * @ignore
  87430. * Application error to support additional information when loading a file
  87431. */
  87432. export class LoadFileError extends Error {
  87433. /** defines the optional XHR request */
  87434. request?: XMLHttpRequest | undefined;
  87435. private static _setPrototypeOf;
  87436. /**
  87437. * Creates a new LoadFileError
  87438. * @param message defines the message of the error
  87439. * @param request defines the optional XHR request
  87440. */
  87441. constructor(message: string,
  87442. /** defines the optional XHR request */
  87443. request?: XMLHttpRequest | undefined);
  87444. }
  87445. /**
  87446. * Class used to define a retry strategy when error happens while loading assets
  87447. */
  87448. export class RetryStrategy {
  87449. /**
  87450. * Function used to defines an exponential back off strategy
  87451. * @param maxRetries defines the maximum number of retries (3 by default)
  87452. * @param baseInterval defines the interval between retries
  87453. * @returns the strategy function to use
  87454. */
  87455. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87456. }
  87457. /**
  87458. * File request interface
  87459. */
  87460. export interface IFileRequest {
  87461. /**
  87462. * Raised when the request is complete (success or error).
  87463. */
  87464. onCompleteObservable: Observable<IFileRequest>;
  87465. /**
  87466. * Aborts the request for a file.
  87467. */
  87468. abort: () => void;
  87469. }
  87470. /**
  87471. * Class containing a set of static utilities functions
  87472. */
  87473. export class Tools {
  87474. /**
  87475. * Gets or sets the base URL to use to load assets
  87476. */
  87477. static BaseUrl: string;
  87478. /**
  87479. * Enable/Disable Custom HTTP Request Headers globally.
  87480. * default = false
  87481. * @see CustomRequestHeaders
  87482. */
  87483. static UseCustomRequestHeaders: boolean;
  87484. /**
  87485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87486. * i.e. when loading files, where the server/service expects an Authorization header.
  87487. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87488. */
  87489. static CustomRequestHeaders: {
  87490. [key: string]: string;
  87491. };
  87492. /**
  87493. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87494. */
  87495. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87496. /**
  87497. * Default behaviour for cors in the application.
  87498. * It can be a string if the expected behavior is identical in the entire app.
  87499. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87500. */
  87501. static CorsBehavior: string | ((url: string | string[]) => string);
  87502. /**
  87503. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87504. * @ignorenaming
  87505. */
  87506. static UseFallbackTexture: boolean;
  87507. /**
  87508. * Use this object to register external classes like custom textures or material
  87509. * to allow the laoders to instantiate them
  87510. */
  87511. static RegisteredExternalClasses: {
  87512. [key: string]: Object;
  87513. };
  87514. /**
  87515. * Texture content used if a texture cannot loaded
  87516. * @ignorenaming
  87517. */
  87518. static fallbackTexture: string;
  87519. /**
  87520. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87521. * @param u defines the coordinate on X axis
  87522. * @param v defines the coordinate on Y axis
  87523. * @param width defines the width of the source data
  87524. * @param height defines the height of the source data
  87525. * @param pixels defines the source byte array
  87526. * @param color defines the output color
  87527. */
  87528. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87529. /**
  87530. * Interpolates between a and b via alpha
  87531. * @param a The lower value (returned when alpha = 0)
  87532. * @param b The upper value (returned when alpha = 1)
  87533. * @param alpha The interpolation-factor
  87534. * @return The mixed value
  87535. */
  87536. static Mix(a: number, b: number, alpha: number): number;
  87537. /**
  87538. * Tries to instantiate a new object from a given class name
  87539. * @param className defines the class name to instantiate
  87540. * @returns the new object or null if the system was not able to do the instantiation
  87541. */
  87542. static Instantiate(className: string): any;
  87543. /**
  87544. * Provides a slice function that will work even on IE
  87545. * @param data defines the array to slice
  87546. * @param start defines the start of the data (optional)
  87547. * @param end defines the end of the data (optional)
  87548. * @returns the new sliced array
  87549. */
  87550. static Slice<T>(data: T, start?: number, end?: number): T;
  87551. /**
  87552. * Polyfill for setImmediate
  87553. * @param action defines the action to execute after the current execution block
  87554. */
  87555. static SetImmediate(action: () => void): void;
  87556. /**
  87557. * Function indicating if a number is an exponent of 2
  87558. * @param value defines the value to test
  87559. * @returns true if the value is an exponent of 2
  87560. */
  87561. static IsExponentOfTwo(value: number): boolean;
  87562. private static _tmpFloatArray;
  87563. /**
  87564. * Returns the nearest 32-bit single precision float representation of a Number
  87565. * @param value A Number. If the parameter is of a different type, it will get converted
  87566. * to a number or to NaN if it cannot be converted
  87567. * @returns number
  87568. */
  87569. static FloatRound(value: number): number;
  87570. /**
  87571. * Find the next highest power of two.
  87572. * @param x Number to start search from.
  87573. * @return Next highest power of two.
  87574. */
  87575. static CeilingPOT(x: number): number;
  87576. /**
  87577. * Find the next lowest power of two.
  87578. * @param x Number to start search from.
  87579. * @return Next lowest power of two.
  87580. */
  87581. static FloorPOT(x: number): number;
  87582. /**
  87583. * Find the nearest power of two.
  87584. * @param x Number to start search from.
  87585. * @return Next nearest power of two.
  87586. */
  87587. static NearestPOT(x: number): number;
  87588. /**
  87589. * Get the closest exponent of two
  87590. * @param value defines the value to approximate
  87591. * @param max defines the maximum value to return
  87592. * @param mode defines how to define the closest value
  87593. * @returns closest exponent of two of the given value
  87594. */
  87595. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87596. /**
  87597. * Extracts the filename from a path
  87598. * @param path defines the path to use
  87599. * @returns the filename
  87600. */
  87601. static GetFilename(path: string): string;
  87602. /**
  87603. * Extracts the "folder" part of a path (everything before the filename).
  87604. * @param uri The URI to extract the info from
  87605. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87606. * @returns The "folder" part of the path
  87607. */
  87608. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87609. /**
  87610. * Extracts text content from a DOM element hierarchy
  87611. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87612. */
  87613. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87614. /**
  87615. * Convert an angle in radians to degrees
  87616. * @param angle defines the angle to convert
  87617. * @returns the angle in degrees
  87618. */
  87619. static ToDegrees(angle: number): number;
  87620. /**
  87621. * Convert an angle in degrees to radians
  87622. * @param angle defines the angle to convert
  87623. * @returns the angle in radians
  87624. */
  87625. static ToRadians(angle: number): number;
  87626. /**
  87627. * Encode a buffer to a base64 string
  87628. * @param buffer defines the buffer to encode
  87629. * @returns the encoded string
  87630. */
  87631. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87632. /**
  87633. * Extracts minimum and maximum values from a list of indexed positions
  87634. * @param positions defines the positions to use
  87635. * @param indices defines the indices to the positions
  87636. * @param indexStart defines the start index
  87637. * @param indexCount defines the end index
  87638. * @param bias defines bias value to add to the result
  87639. * @return minimum and maximum values
  87640. */
  87641. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87642. minimum: Vector3;
  87643. maximum: Vector3;
  87644. };
  87645. /**
  87646. * Extracts minimum and maximum values from a list of positions
  87647. * @param positions defines the positions to use
  87648. * @param start defines the start index in the positions array
  87649. * @param count defines the number of positions to handle
  87650. * @param bias defines bias value to add to the result
  87651. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87652. * @return minimum and maximum values
  87653. */
  87654. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87655. minimum: Vector3;
  87656. maximum: Vector3;
  87657. };
  87658. /**
  87659. * Returns an array if obj is not an array
  87660. * @param obj defines the object to evaluate as an array
  87661. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87662. * @returns either obj directly if obj is an array or a new array containing obj
  87663. */
  87664. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87665. /**
  87666. * Gets the pointer prefix to use
  87667. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87668. */
  87669. static GetPointerPrefix(): string;
  87670. /**
  87671. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87672. * @param func - the function to be called
  87673. * @param requester - the object that will request the next frame. Falls back to window.
  87674. * @returns frame number
  87675. */
  87676. static QueueNewFrame(func: () => void, requester?: any): number;
  87677. /**
  87678. * Ask the browser to promote the current element to fullscreen rendering mode
  87679. * @param element defines the DOM element to promote
  87680. */
  87681. static RequestFullscreen(element: HTMLElement): void;
  87682. /**
  87683. * Asks the browser to exit fullscreen mode
  87684. */
  87685. static ExitFullscreen(): void;
  87686. /**
  87687. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87688. * @param url define the url we are trying
  87689. * @param element define the dom element where to configure the cors policy
  87690. */
  87691. static SetCorsBehavior(url: string | string[], element: {
  87692. crossOrigin: string | null;
  87693. }): void;
  87694. /**
  87695. * Removes unwanted characters from an url
  87696. * @param url defines the url to clean
  87697. * @returns the cleaned url
  87698. */
  87699. static CleanUrl(url: string): string;
  87700. /**
  87701. * Gets or sets a function used to pre-process url before using them to load assets
  87702. */
  87703. static PreprocessUrl: (url: string) => string;
  87704. /**
  87705. * Loads an image as an HTMLImageElement.
  87706. * @param input url string, ArrayBuffer, or Blob to load
  87707. * @param onLoad callback called when the image successfully loads
  87708. * @param onError callback called when the image fails to load
  87709. * @param offlineProvider offline provider for caching
  87710. * @returns the HTMLImageElement of the loaded image
  87711. */
  87712. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87713. /**
  87714. * Loads a file
  87715. * @param url url string, ArrayBuffer, or Blob to load
  87716. * @param onSuccess callback called when the file successfully loads
  87717. * @param onProgress callback called while file is loading (if the server supports this mode)
  87718. * @param offlineProvider defines the offline provider for caching
  87719. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87720. * @param onError callback called when the file fails to load
  87721. * @returns a file request object
  87722. */
  87723. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  87724. /**
  87725. * Load a script (identified by an url). When the url returns, the
  87726. * content of this file is added into a new script element, attached to the DOM (body element)
  87727. * @param scriptUrl defines the url of the script to laod
  87728. * @param onSuccess defines the callback called when the script is loaded
  87729. * @param onError defines the callback to call if an error occurs
  87730. */
  87731. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87732. /**
  87733. * Loads a file from a blob
  87734. * @param fileToLoad defines the blob to use
  87735. * @param callback defines the callback to call when data is loaded
  87736. * @param progressCallback defines the callback to call during loading process
  87737. * @returns a file request object
  87738. */
  87739. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87740. /**
  87741. * Loads a file
  87742. * @param fileToLoad defines the file to load
  87743. * @param callback defines the callback to call when data is loaded
  87744. * @param progressCallBack defines the callback to call during loading process
  87745. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87746. * @returns a file request object
  87747. */
  87748. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87749. /**
  87750. * Creates a data url from a given string content
  87751. * @param content defines the content to convert
  87752. * @returns the new data url link
  87753. */
  87754. static FileAsURL(content: string): string;
  87755. /**
  87756. * Format the given number to a specific decimal format
  87757. * @param value defines the number to format
  87758. * @param decimals defines the number of decimals to use
  87759. * @returns the formatted string
  87760. */
  87761. static Format(value: number, decimals?: number): string;
  87762. /**
  87763. * Checks if a given vector is inside a specific range
  87764. * @param v defines the vector to test
  87765. * @param min defines the minimum range
  87766. * @param max defines the maximum range
  87767. */
  87768. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87769. /**
  87770. * Tries to copy an object by duplicating every property
  87771. * @param source defines the source object
  87772. * @param destination defines the target object
  87773. * @param doNotCopyList defines a list of properties to avoid
  87774. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87775. */
  87776. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87777. /**
  87778. * Gets a boolean indicating if the given object has no own property
  87779. * @param obj defines the object to test
  87780. * @returns true if object has no own property
  87781. */
  87782. static IsEmpty(obj: any): boolean;
  87783. /**
  87784. * Function used to register events at window level
  87785. * @param events defines the events to register
  87786. */
  87787. static RegisterTopRootEvents(events: {
  87788. name: string;
  87789. handler: Nullable<(e: FocusEvent) => any>;
  87790. }[]): void;
  87791. /**
  87792. * Function used to unregister events from window level
  87793. * @param events defines the events to unregister
  87794. */
  87795. static UnregisterTopRootEvents(events: {
  87796. name: string;
  87797. handler: Nullable<(e: FocusEvent) => any>;
  87798. }[]): void;
  87799. /**
  87800. * @ignore
  87801. */
  87802. static _ScreenshotCanvas: HTMLCanvasElement;
  87803. /**
  87804. * Dumps the current bound framebuffer
  87805. * @param width defines the rendering width
  87806. * @param height defines the rendering height
  87807. * @param engine defines the hosting engine
  87808. * @param successCallback defines the callback triggered once the data are available
  87809. * @param mimeType defines the mime type of the result
  87810. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87811. */
  87812. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87813. /**
  87814. * Converts the canvas data to blob.
  87815. * This acts as a polyfill for browsers not supporting the to blob function.
  87816. * @param canvas Defines the canvas to extract the data from
  87817. * @param successCallback Defines the callback triggered once the data are available
  87818. * @param mimeType Defines the mime type of the result
  87819. */
  87820. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87821. /**
  87822. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87823. * @param successCallback defines the callback triggered once the data are available
  87824. * @param mimeType defines the mime type of the result
  87825. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87826. */
  87827. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87828. /**
  87829. * Downloads a blob in the browser
  87830. * @param blob defines the blob to download
  87831. * @param fileName defines the name of the downloaded file
  87832. */
  87833. static Download(blob: Blob, fileName: string): void;
  87834. /**
  87835. * Captures a screenshot of the current rendering
  87836. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87837. * @param engine defines the rendering engine
  87838. * @param camera defines the source camera
  87839. * @param size This parameter can be set to a single number or to an object with the
  87840. * following (optional) properties: precision, width, height. If a single number is passed,
  87841. * it will be used for both width and height. If an object is passed, the screenshot size
  87842. * will be derived from the parameters. The precision property is a multiplier allowing
  87843. * rendering at a higher or lower resolution
  87844. * @param successCallback defines the callback receives a single parameter which contains the
  87845. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87846. * src parameter of an <img> to display it
  87847. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87848. * Check your browser for supported MIME types
  87849. */
  87850. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87851. /**
  87852. * Generates an image screenshot from the specified camera.
  87853. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87854. * @param engine The engine to use for rendering
  87855. * @param camera The camera to use for rendering
  87856. * @param size This parameter can be set to a single number or to an object with the
  87857. * following (optional) properties: precision, width, height. If a single number is passed,
  87858. * it will be used for both width and height. If an object is passed, the screenshot size
  87859. * will be derived from the parameters. The precision property is a multiplier allowing
  87860. * rendering at a higher or lower resolution
  87861. * @param successCallback The callback receives a single parameter which contains the
  87862. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87863. * src parameter of an <img> to display it
  87864. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87865. * Check your browser for supported MIME types
  87866. * @param samples Texture samples (default: 1)
  87867. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87868. * @param fileName A name for for the downloaded file.
  87869. */
  87870. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87871. /**
  87872. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87873. * Be aware Math.random() could cause collisions, but:
  87874. * "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"
  87875. * @returns a pseudo random id
  87876. */
  87877. static RandomId(): string;
  87878. /**
  87879. * Test if the given uri is a base64 string
  87880. * @param uri The uri to test
  87881. * @return True if the uri is a base64 string or false otherwise
  87882. */
  87883. static IsBase64(uri: string): boolean;
  87884. /**
  87885. * Decode the given base64 uri.
  87886. * @param uri The uri to decode
  87887. * @return The decoded base64 data.
  87888. */
  87889. static DecodeBase64(uri: string): ArrayBuffer;
  87890. /**
  87891. * No log
  87892. */
  87893. static readonly NoneLogLevel: number;
  87894. /**
  87895. * Only message logs
  87896. */
  87897. static readonly MessageLogLevel: number;
  87898. /**
  87899. * Only warning logs
  87900. */
  87901. static readonly WarningLogLevel: number;
  87902. /**
  87903. * Only error logs
  87904. */
  87905. static readonly ErrorLogLevel: number;
  87906. /**
  87907. * All logs
  87908. */
  87909. static readonly AllLogLevel: number;
  87910. /**
  87911. * Gets a value indicating the number of loading errors
  87912. * @ignorenaming
  87913. */
  87914. static readonly errorsCount: number;
  87915. /**
  87916. * Callback called when a new log is added
  87917. */
  87918. static OnNewCacheEntry: (entry: string) => void;
  87919. /**
  87920. * Log a message to the console
  87921. * @param message defines the message to log
  87922. */
  87923. static Log(message: string): void;
  87924. /**
  87925. * Write a warning message to the console
  87926. * @param message defines the message to log
  87927. */
  87928. static Warn(message: string): void;
  87929. /**
  87930. * Write an error message to the console
  87931. * @param message defines the message to log
  87932. */
  87933. static Error(message: string): void;
  87934. /**
  87935. * Gets current log cache (list of logs)
  87936. */
  87937. static readonly LogCache: string;
  87938. /**
  87939. * Clears the log cache
  87940. */
  87941. static ClearLogCache(): void;
  87942. /**
  87943. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87944. */
  87945. static LogLevels: number;
  87946. /**
  87947. * Checks if the loaded document was accessed via `file:`-Protocol.
  87948. * @returns boolean
  87949. */
  87950. static IsFileURL(): boolean;
  87951. /**
  87952. * Checks if the window object exists
  87953. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87954. */
  87955. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87956. /**
  87957. * No performance log
  87958. */
  87959. static readonly PerformanceNoneLogLevel: number;
  87960. /**
  87961. * Use user marks to log performance
  87962. */
  87963. static readonly PerformanceUserMarkLogLevel: number;
  87964. /**
  87965. * Log performance to the console
  87966. */
  87967. static readonly PerformanceConsoleLogLevel: number;
  87968. private static _performance;
  87969. /**
  87970. * Sets the current performance log level
  87971. */
  87972. static PerformanceLogLevel: number;
  87973. private static _StartPerformanceCounterDisabled;
  87974. private static _EndPerformanceCounterDisabled;
  87975. private static _StartUserMark;
  87976. private static _EndUserMark;
  87977. private static _StartPerformanceConsole;
  87978. private static _EndPerformanceConsole;
  87979. /**
  87980. * Injects the @see CustomRequestHeaders into the given request
  87981. * @param request the request that should be used for injection
  87982. */
  87983. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87984. /**
  87985. * Starts a performance counter
  87986. */
  87987. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87988. /**
  87989. * Ends a specific performance coutner
  87990. */
  87991. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87992. /**
  87993. * Gets either window.performance.now() if supported or Date.now() else
  87994. */
  87995. static readonly Now: number;
  87996. /**
  87997. * This method will return the name of the class used to create the instance of the given object.
  87998. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87999. * @param object the object to get the class name from
  88000. * @param isType defines if the object is actually a type
  88001. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88002. */
  88003. static GetClassName(object: any, isType?: boolean): string;
  88004. /**
  88005. * Gets the first element of an array satisfying a given predicate
  88006. * @param array defines the array to browse
  88007. * @param predicate defines the predicate to use
  88008. * @returns null if not found or the element
  88009. */
  88010. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88011. /**
  88012. * This method will return the name of the full name of the class, including its owning module (if any).
  88013. * 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).
  88014. * @param object the object to get the class name from
  88015. * @param isType defines if the object is actually a type
  88016. * @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.
  88017. * @ignorenaming
  88018. */
  88019. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88020. /**
  88021. * Returns a promise that resolves after the given amount of time.
  88022. * @param delay Number of milliseconds to delay
  88023. * @returns Promise that resolves after the given amount of time
  88024. */
  88025. static DelayAsync(delay: number): Promise<void>;
  88026. /**
  88027. * Gets the current gradient from an array of IValueGradient
  88028. * @param ratio defines the current ratio to get
  88029. * @param gradients defines the array of IValueGradient
  88030. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88031. */
  88032. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88033. }
  88034. /**
  88035. * This class is used to track a performance counter which is number based.
  88036. * The user has access to many properties which give statistics of different nature.
  88037. *
  88038. * The implementer can track two kinds of Performance Counter: time and count.
  88039. * 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.
  88040. * 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.
  88041. */
  88042. export class PerfCounter {
  88043. /**
  88044. * Gets or sets a global boolean to turn on and off all the counters
  88045. */
  88046. static Enabled: boolean;
  88047. /**
  88048. * Returns the smallest value ever
  88049. */
  88050. readonly min: number;
  88051. /**
  88052. * Returns the biggest value ever
  88053. */
  88054. readonly max: number;
  88055. /**
  88056. * Returns the average value since the performance counter is running
  88057. */
  88058. readonly average: number;
  88059. /**
  88060. * Returns the average value of the last second the counter was monitored
  88061. */
  88062. readonly lastSecAverage: number;
  88063. /**
  88064. * Returns the current value
  88065. */
  88066. readonly current: number;
  88067. /**
  88068. * Gets the accumulated total
  88069. */
  88070. readonly total: number;
  88071. /**
  88072. * Gets the total value count
  88073. */
  88074. readonly count: number;
  88075. /**
  88076. * Creates a new counter
  88077. */
  88078. constructor();
  88079. /**
  88080. * Call this method to start monitoring a new frame.
  88081. * 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.
  88082. */
  88083. fetchNewFrame(): void;
  88084. /**
  88085. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88086. * @param newCount the count value to add to the monitored count
  88087. * @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.
  88088. */
  88089. addCount(newCount: number, fetchResult: boolean): void;
  88090. /**
  88091. * Start monitoring this performance counter
  88092. */
  88093. beginMonitoring(): void;
  88094. /**
  88095. * Compute the time lapsed since the previous beginMonitoring() call.
  88096. * @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
  88097. */
  88098. endMonitoring(newFrame?: boolean): void;
  88099. private _fetchResult;
  88100. private _startMonitoringTime;
  88101. private _min;
  88102. private _max;
  88103. private _average;
  88104. private _current;
  88105. private _totalValueCount;
  88106. private _totalAccumulated;
  88107. private _lastSecAverage;
  88108. private _lastSecAccumulated;
  88109. private _lastSecTime;
  88110. private _lastSecValueCount;
  88111. }
  88112. /**
  88113. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88114. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88115. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88116. * @param name The name of the class, case should be preserved
  88117. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88118. */
  88119. export function className(name: string, module?: string): (target: Object) => void;
  88120. /**
  88121. * An implementation of a loop for asynchronous functions.
  88122. */
  88123. export class AsyncLoop {
  88124. /**
  88125. * Defines the number of iterations for the loop
  88126. */
  88127. iterations: number;
  88128. /**
  88129. * Defines the current index of the loop.
  88130. */
  88131. index: number;
  88132. private _done;
  88133. private _fn;
  88134. private _successCallback;
  88135. /**
  88136. * Constructor.
  88137. * @param iterations the number of iterations.
  88138. * @param func the function to run each iteration
  88139. * @param successCallback the callback that will be called upon succesful execution
  88140. * @param offset starting offset.
  88141. */
  88142. constructor(
  88143. /**
  88144. * Defines the number of iterations for the loop
  88145. */
  88146. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88147. /**
  88148. * Execute the next iteration. Must be called after the last iteration was finished.
  88149. */
  88150. executeNext(): void;
  88151. /**
  88152. * Break the loop and run the success callback.
  88153. */
  88154. breakLoop(): void;
  88155. /**
  88156. * Create and run an async loop.
  88157. * @param iterations the number of iterations.
  88158. * @param fn the function to run each iteration
  88159. * @param successCallback the callback that will be called upon succesful execution
  88160. * @param offset starting offset.
  88161. * @returns the created async loop object
  88162. */
  88163. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88164. /**
  88165. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88166. * @param iterations total number of iterations
  88167. * @param syncedIterations number of synchronous iterations in each async iteration.
  88168. * @param fn the function to call each iteration.
  88169. * @param callback a success call back that will be called when iterating stops.
  88170. * @param breakFunction a break condition (optional)
  88171. * @param timeout timeout settings for the setTimeout function. default - 0.
  88172. * @returns the created async loop object
  88173. */
  88174. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88175. }
  88176. }
  88177. declare module BABYLON {
  88178. /** @hidden */
  88179. export interface ICollisionCoordinator {
  88180. createCollider(): Collider;
  88181. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88182. init(scene: Scene): void;
  88183. }
  88184. /** @hidden */
  88185. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88186. private _scene;
  88187. private _scaledPosition;
  88188. private _scaledVelocity;
  88189. private _finalPosition;
  88190. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88191. createCollider(): Collider;
  88192. init(scene: Scene): void;
  88193. private _collideWithWorld;
  88194. }
  88195. }
  88196. declare module BABYLON {
  88197. /**
  88198. * This class defines the direct association between an animation and a target
  88199. */
  88200. export class TargetedAnimation {
  88201. /**
  88202. * Animation to perform
  88203. */
  88204. animation: Animation;
  88205. /**
  88206. * Target to animate
  88207. */
  88208. target: any;
  88209. }
  88210. /**
  88211. * Use this class to create coordinated animations on multiple targets
  88212. */
  88213. export class AnimationGroup implements IDisposable {
  88214. /** The name of the animation group */
  88215. name: string;
  88216. private _scene;
  88217. private _targetedAnimations;
  88218. private _animatables;
  88219. private _from;
  88220. private _to;
  88221. private _isStarted;
  88222. private _isPaused;
  88223. private _speedRatio;
  88224. /**
  88225. * Gets or sets the unique id of the node
  88226. */
  88227. uniqueId: number;
  88228. /**
  88229. * This observable will notify when one animation have ended
  88230. */
  88231. onAnimationEndObservable: Observable<TargetedAnimation>;
  88232. /**
  88233. * Observer raised when one animation loops
  88234. */
  88235. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88236. /**
  88237. * This observable will notify when all animations have ended.
  88238. */
  88239. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88240. /**
  88241. * This observable will notify when all animations have paused.
  88242. */
  88243. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88244. /**
  88245. * This observable will notify when all animations are playing.
  88246. */
  88247. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88248. /**
  88249. * Gets the first frame
  88250. */
  88251. readonly from: number;
  88252. /**
  88253. * Gets the last frame
  88254. */
  88255. readonly to: number;
  88256. /**
  88257. * Define if the animations are started
  88258. */
  88259. readonly isStarted: boolean;
  88260. /**
  88261. * Gets a value indicating that the current group is playing
  88262. */
  88263. readonly isPlaying: boolean;
  88264. /**
  88265. * Gets or sets the speed ratio to use for all animations
  88266. */
  88267. /**
  88268. * Gets or sets the speed ratio to use for all animations
  88269. */
  88270. speedRatio: number;
  88271. /**
  88272. * Gets the targeted animations for this animation group
  88273. */
  88274. readonly targetedAnimations: Array<TargetedAnimation>;
  88275. /**
  88276. * returning the list of animatables controlled by this animation group.
  88277. */
  88278. readonly animatables: Array<Animatable>;
  88279. /**
  88280. * Instantiates a new Animation Group.
  88281. * This helps managing several animations at once.
  88282. * @see http://doc.babylonjs.com/how_to/group
  88283. * @param name Defines the name of the group
  88284. * @param scene Defines the scene the group belongs to
  88285. */
  88286. constructor(
  88287. /** The name of the animation group */
  88288. name: string, scene?: Nullable<Scene>);
  88289. /**
  88290. * Add an animation (with its target) in the group
  88291. * @param animation defines the animation we want to add
  88292. * @param target defines the target of the animation
  88293. * @returns the TargetedAnimation object
  88294. */
  88295. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88296. /**
  88297. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88298. * It can add constant keys at begin or end
  88299. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88300. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88301. * @returns the animation group
  88302. */
  88303. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88304. /**
  88305. * Start all animations on given targets
  88306. * @param loop defines if animations must loop
  88307. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88308. * @param from defines the from key (optional)
  88309. * @param to defines the to key (optional)
  88310. * @returns the current animation group
  88311. */
  88312. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88313. /**
  88314. * Pause all animations
  88315. * @returns the animation group
  88316. */
  88317. pause(): AnimationGroup;
  88318. /**
  88319. * Play all animations to initial state
  88320. * This function will start() the animations if they were not started or will restart() them if they were paused
  88321. * @param loop defines if animations must loop
  88322. * @returns the animation group
  88323. */
  88324. play(loop?: boolean): AnimationGroup;
  88325. /**
  88326. * Reset all animations to initial state
  88327. * @returns the animation group
  88328. */
  88329. reset(): AnimationGroup;
  88330. /**
  88331. * Restart animations from key 0
  88332. * @returns the animation group
  88333. */
  88334. restart(): AnimationGroup;
  88335. /**
  88336. * Stop all animations
  88337. * @returns the animation group
  88338. */
  88339. stop(): AnimationGroup;
  88340. /**
  88341. * Set animation weight for all animatables
  88342. * @param weight defines the weight to use
  88343. * @return the animationGroup
  88344. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88345. */
  88346. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88347. /**
  88348. * Synchronize and normalize all animatables with a source animatable
  88349. * @param root defines the root animatable to synchronize with
  88350. * @return the animationGroup
  88351. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88352. */
  88353. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88354. /**
  88355. * Goes to a specific frame in this animation group
  88356. * @param frame the frame number to go to
  88357. * @return the animationGroup
  88358. */
  88359. goToFrame(frame: number): AnimationGroup;
  88360. /**
  88361. * Dispose all associated resources
  88362. */
  88363. dispose(): void;
  88364. private _checkAnimationGroupEnded;
  88365. /**
  88366. * Clone the current animation group and returns a copy
  88367. * @param newName defines the name of the new group
  88368. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88369. * @returns the new aniamtion group
  88370. */
  88371. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88372. /**
  88373. * Returns a new AnimationGroup object parsed from the source provided.
  88374. * @param parsedAnimationGroup defines the source
  88375. * @param scene defines the scene that will receive the animationGroup
  88376. * @returns a new AnimationGroup
  88377. */
  88378. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88379. /**
  88380. * Returns the string "AnimationGroup"
  88381. * @returns "AnimationGroup"
  88382. */
  88383. getClassName(): string;
  88384. /**
  88385. * Creates a detailled string about the object
  88386. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88387. * @returns a string representing the object
  88388. */
  88389. toString(fullDetails?: boolean): string;
  88390. }
  88391. }
  88392. declare module BABYLON {
  88393. /**
  88394. * Define an interface for all classes that will hold resources
  88395. */
  88396. export interface IDisposable {
  88397. /**
  88398. * Releases all held resources
  88399. */
  88400. dispose(): void;
  88401. }
  88402. /** Interface defining initialization parameters for Scene class */
  88403. export interface SceneOptions {
  88404. /**
  88405. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88406. * It will improve performance when the number of geometries becomes important.
  88407. */
  88408. useGeometryUniqueIdsMap?: boolean;
  88409. /**
  88410. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88411. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88412. */
  88413. useMaterialMeshMap?: boolean;
  88414. /**
  88415. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88416. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88417. */
  88418. useClonedMeshhMap?: boolean;
  88419. }
  88420. /**
  88421. * Represents a scene to be rendered by the engine.
  88422. * @see http://doc.babylonjs.com/features/scene
  88423. */
  88424. export class Scene extends AbstractScene implements IAnimatable {
  88425. private static _uniqueIdCounter;
  88426. /** The fog is deactivated */
  88427. static readonly FOGMODE_NONE: number;
  88428. /** The fog density is following an exponential function */
  88429. static readonly FOGMODE_EXP: number;
  88430. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88431. static readonly FOGMODE_EXP2: number;
  88432. /** The fog density is following a linear function. */
  88433. static readonly FOGMODE_LINEAR: number;
  88434. /**
  88435. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88436. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88437. */
  88438. static MinDeltaTime: number;
  88439. /**
  88440. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88442. */
  88443. static MaxDeltaTime: number;
  88444. /**
  88445. * Factory used to create the default material.
  88446. * @param name The name of the material to create
  88447. * @param scene The scene to create the material for
  88448. * @returns The default material
  88449. */
  88450. static DefaultMaterialFactory(scene: Scene): Material;
  88451. /**
  88452. * Factory used to create the a collision coordinator.
  88453. * @returns The collision coordinator
  88454. */
  88455. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88456. /** @hidden */
  88457. readonly _isScene: boolean;
  88458. /**
  88459. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88460. */
  88461. autoClear: boolean;
  88462. /**
  88463. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88464. */
  88465. autoClearDepthAndStencil: boolean;
  88466. /**
  88467. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88468. */
  88469. clearColor: Color4;
  88470. /**
  88471. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88472. */
  88473. ambientColor: Color3;
  88474. /** @hidden */
  88475. _environmentBRDFTexture: BaseTexture;
  88476. /** @hidden */
  88477. protected _environmentTexture: Nullable<BaseTexture>;
  88478. /**
  88479. * Texture used in all pbr material as the reflection texture.
  88480. * As in the majority of the scene they are the same (exception for multi room and so on),
  88481. * this is easier to reference from here than from all the materials.
  88482. */
  88483. /**
  88484. * Texture used in all pbr material as the reflection texture.
  88485. * As in the majority of the scene they are the same (exception for multi room and so on),
  88486. * this is easier to set here than in all the materials.
  88487. */
  88488. environmentTexture: Nullable<BaseTexture>;
  88489. /** @hidden */
  88490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88491. /**
  88492. * Default image processing configuration used either in the rendering
  88493. * Forward main pass or through the imageProcessingPostProcess if present.
  88494. * As in the majority of the scene they are the same (exception for multi camera),
  88495. * this is easier to reference from here than from all the materials and post process.
  88496. *
  88497. * No setter as we it is a shared configuration, you can set the values instead.
  88498. */
  88499. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88500. private _forceWireframe;
  88501. /**
  88502. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88503. */
  88504. forceWireframe: boolean;
  88505. private _forcePointsCloud;
  88506. /**
  88507. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88508. */
  88509. forcePointsCloud: boolean;
  88510. /**
  88511. * Gets or sets the active clipplane 1
  88512. */
  88513. clipPlane: Nullable<Plane>;
  88514. /**
  88515. * Gets or sets the active clipplane 2
  88516. */
  88517. clipPlane2: Nullable<Plane>;
  88518. /**
  88519. * Gets or sets the active clipplane 3
  88520. */
  88521. clipPlane3: Nullable<Plane>;
  88522. /**
  88523. * Gets or sets the active clipplane 4
  88524. */
  88525. clipPlane4: Nullable<Plane>;
  88526. /**
  88527. * Gets or sets a boolean indicating if animations are enabled
  88528. */
  88529. animationsEnabled: boolean;
  88530. private _animationPropertiesOverride;
  88531. /**
  88532. * Gets or sets the animation properties override
  88533. */
  88534. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88535. /**
  88536. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88537. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88538. */
  88539. useConstantAnimationDeltaTime: boolean;
  88540. /**
  88541. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88542. * Please note that it requires to run a ray cast through the scene on every frame
  88543. */
  88544. constantlyUpdateMeshUnderPointer: boolean;
  88545. /**
  88546. * Defines the HTML cursor to use when hovering over interactive elements
  88547. */
  88548. hoverCursor: string;
  88549. /**
  88550. * Defines the HTML default cursor to use (empty by default)
  88551. */
  88552. defaultCursor: string;
  88553. /**
  88554. * This is used to call preventDefault() on pointer down
  88555. * in order to block unwanted artifacts like system double clicks
  88556. */
  88557. preventDefaultOnPointerDown: boolean;
  88558. /**
  88559. * This is used to call preventDefault() on pointer up
  88560. * in order to block unwanted artifacts like system double clicks
  88561. */
  88562. preventDefaultOnPointerUp: boolean;
  88563. /**
  88564. * Gets or sets user defined metadata
  88565. */
  88566. metadata: any;
  88567. /**
  88568. * For internal use only. Please do not use.
  88569. */
  88570. reservedDataStore: any;
  88571. /**
  88572. * Gets the name of the plugin used to load this scene (null by default)
  88573. */
  88574. loadingPluginName: string;
  88575. /**
  88576. * Use this array to add regular expressions used to disable offline support for specific urls
  88577. */
  88578. disableOfflineSupportExceptionRules: RegExp[];
  88579. /**
  88580. * An event triggered when the scene is disposed.
  88581. */
  88582. onDisposeObservable: Observable<Scene>;
  88583. private _onDisposeObserver;
  88584. /** Sets a function to be executed when this scene is disposed. */
  88585. onDispose: () => void;
  88586. /**
  88587. * An event triggered before rendering the scene (right after animations and physics)
  88588. */
  88589. onBeforeRenderObservable: Observable<Scene>;
  88590. private _onBeforeRenderObserver;
  88591. /** Sets a function to be executed before rendering this scene */
  88592. beforeRender: Nullable<() => void>;
  88593. /**
  88594. * An event triggered after rendering the scene
  88595. */
  88596. onAfterRenderObservable: Observable<Scene>;
  88597. private _onAfterRenderObserver;
  88598. /** Sets a function to be executed after rendering this scene */
  88599. afterRender: Nullable<() => void>;
  88600. /**
  88601. * An event triggered before animating the scene
  88602. */
  88603. onBeforeAnimationsObservable: Observable<Scene>;
  88604. /**
  88605. * An event triggered after animations processing
  88606. */
  88607. onAfterAnimationsObservable: Observable<Scene>;
  88608. /**
  88609. * An event triggered before draw calls are ready to be sent
  88610. */
  88611. onBeforeDrawPhaseObservable: Observable<Scene>;
  88612. /**
  88613. * An event triggered after draw calls have been sent
  88614. */
  88615. onAfterDrawPhaseObservable: Observable<Scene>;
  88616. /**
  88617. * An event triggered when the scene is ready
  88618. */
  88619. onReadyObservable: Observable<Scene>;
  88620. /**
  88621. * An event triggered before rendering a camera
  88622. */
  88623. onBeforeCameraRenderObservable: Observable<Camera>;
  88624. private _onBeforeCameraRenderObserver;
  88625. /** Sets a function to be executed before rendering a camera*/
  88626. beforeCameraRender: () => void;
  88627. /**
  88628. * An event triggered after rendering a camera
  88629. */
  88630. onAfterCameraRenderObservable: Observable<Camera>;
  88631. private _onAfterCameraRenderObserver;
  88632. /** Sets a function to be executed after rendering a camera*/
  88633. afterCameraRender: () => void;
  88634. /**
  88635. * An event triggered when active meshes evaluation is about to start
  88636. */
  88637. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88638. /**
  88639. * An event triggered when active meshes evaluation is done
  88640. */
  88641. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88642. /**
  88643. * An event triggered when particles rendering is about to start
  88644. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88645. */
  88646. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88647. /**
  88648. * An event triggered when particles rendering is done
  88649. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88650. */
  88651. onAfterParticlesRenderingObservable: Observable<Scene>;
  88652. /**
  88653. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88654. */
  88655. onDataLoadedObservable: Observable<Scene>;
  88656. /**
  88657. * An event triggered when a camera is created
  88658. */
  88659. onNewCameraAddedObservable: Observable<Camera>;
  88660. /**
  88661. * An event triggered when a camera is removed
  88662. */
  88663. onCameraRemovedObservable: Observable<Camera>;
  88664. /**
  88665. * An event triggered when a light is created
  88666. */
  88667. onNewLightAddedObservable: Observable<Light>;
  88668. /**
  88669. * An event triggered when a light is removed
  88670. */
  88671. onLightRemovedObservable: Observable<Light>;
  88672. /**
  88673. * An event triggered when a geometry is created
  88674. */
  88675. onNewGeometryAddedObservable: Observable<Geometry>;
  88676. /**
  88677. * An event triggered when a geometry is removed
  88678. */
  88679. onGeometryRemovedObservable: Observable<Geometry>;
  88680. /**
  88681. * An event triggered when a transform node is created
  88682. */
  88683. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88684. /**
  88685. * An event triggered when a transform node is removed
  88686. */
  88687. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88688. /**
  88689. * An event triggered when a mesh is created
  88690. */
  88691. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88692. /**
  88693. * An event triggered when a mesh is removed
  88694. */
  88695. onMeshRemovedObservable: Observable<AbstractMesh>;
  88696. /**
  88697. * An event triggered when a material is created
  88698. */
  88699. onNewMaterialAddedObservable: Observable<Material>;
  88700. /**
  88701. * An event triggered when a material is removed
  88702. */
  88703. onMaterialRemovedObservable: Observable<Material>;
  88704. /**
  88705. * An event triggered when a texture is created
  88706. */
  88707. onNewTextureAddedObservable: Observable<BaseTexture>;
  88708. /**
  88709. * An event triggered when a texture is removed
  88710. */
  88711. onTextureRemovedObservable: Observable<BaseTexture>;
  88712. /**
  88713. * An event triggered when render targets are about to be rendered
  88714. * Can happen multiple times per frame.
  88715. */
  88716. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88717. /**
  88718. * An event triggered when render targets were rendered.
  88719. * Can happen multiple times per frame.
  88720. */
  88721. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88722. /**
  88723. * An event triggered before calculating deterministic simulation step
  88724. */
  88725. onBeforeStepObservable: Observable<Scene>;
  88726. /**
  88727. * An event triggered after calculating deterministic simulation step
  88728. */
  88729. onAfterStepObservable: Observable<Scene>;
  88730. /**
  88731. * An event triggered when the activeCamera property is updated
  88732. */
  88733. onActiveCameraChanged: Observable<Scene>;
  88734. /**
  88735. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88736. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88737. * 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)
  88738. */
  88739. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88740. /**
  88741. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88742. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88743. * 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)
  88744. */
  88745. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88746. /**
  88747. * This Observable will when a mesh has been imported into the scene.
  88748. */
  88749. onMeshImportedObservable: Observable<AbstractMesh>;
  88750. /**
  88751. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88752. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88753. */
  88754. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88755. /** @hidden */
  88756. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88757. /**
  88758. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88759. */
  88760. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88761. /**
  88762. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88763. */
  88764. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88765. /**
  88766. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88767. */
  88768. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88769. private _onPointerMove;
  88770. private _onPointerDown;
  88771. private _onPointerUp;
  88772. /** Callback called when a pointer move is detected */
  88773. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88774. /** Callback called when a pointer down is detected */
  88775. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88776. /** Callback called when a pointer up is detected */
  88777. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88778. /** Callback called when a pointer pick is detected */
  88779. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88780. /**
  88781. * 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).
  88782. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88783. */
  88784. onPrePointerObservable: Observable<PointerInfoPre>;
  88785. /**
  88786. * Observable event triggered each time an input event is received from the rendering canvas
  88787. */
  88788. onPointerObservable: Observable<PointerInfo>;
  88789. /**
  88790. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88791. */
  88792. readonly unTranslatedPointer: Vector2;
  88793. /** The distance in pixel that you have to move to prevent some events */
  88794. static DragMovementThreshold: number;
  88795. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88796. static LongPressDelay: number;
  88797. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88798. static DoubleClickDelay: number;
  88799. /** If you need to check double click without raising a single click at first click, enable this flag */
  88800. static ExclusiveDoubleClickMode: boolean;
  88801. private _initClickEvent;
  88802. private _initActionManager;
  88803. private _delayedSimpleClick;
  88804. private _delayedSimpleClickTimeout;
  88805. private _previousDelayedSimpleClickTimeout;
  88806. private _meshPickProceed;
  88807. private _previousButtonPressed;
  88808. private _currentPickResult;
  88809. private _previousPickResult;
  88810. private _totalPointersPressed;
  88811. private _doubleClickOccured;
  88812. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88813. cameraToUseForPointers: Nullable<Camera>;
  88814. private _pointerX;
  88815. private _pointerY;
  88816. private _unTranslatedPointerX;
  88817. private _unTranslatedPointerY;
  88818. private _startingPointerPosition;
  88819. private _previousStartingPointerPosition;
  88820. private _startingPointerTime;
  88821. private _previousStartingPointerTime;
  88822. private _pointerCaptures;
  88823. private _timeAccumulator;
  88824. private _currentStepId;
  88825. private _currentInternalStep;
  88826. /** @hidden */
  88827. _mirroredCameraPosition: Nullable<Vector3>;
  88828. /**
  88829. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88830. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88831. */
  88832. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88833. /**
  88834. * Observable event triggered each time an keyboard event is received from the hosting window
  88835. */
  88836. onKeyboardObservable: Observable<KeyboardInfo>;
  88837. private _onKeyDown;
  88838. private _onKeyUp;
  88839. private _onCanvasFocusObserver;
  88840. private _onCanvasBlurObserver;
  88841. private _useRightHandedSystem;
  88842. /**
  88843. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88844. */
  88845. useRightHandedSystem: boolean;
  88846. /**
  88847. * Sets the step Id used by deterministic lock step
  88848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88849. * @param newStepId defines the step Id
  88850. */
  88851. setStepId(newStepId: number): void;
  88852. /**
  88853. * Gets the step Id used by deterministic lock step
  88854. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88855. * @returns the step Id
  88856. */
  88857. getStepId(): number;
  88858. /**
  88859. * Gets the internal step used by deterministic lock step
  88860. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88861. * @returns the internal step
  88862. */
  88863. getInternalStep(): number;
  88864. private _fogEnabled;
  88865. /**
  88866. * Gets or sets a boolean indicating if fog is enabled on this scene
  88867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88868. * (Default is true)
  88869. */
  88870. fogEnabled: boolean;
  88871. private _fogMode;
  88872. /**
  88873. * Gets or sets the fog mode to use
  88874. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88875. * | mode | value |
  88876. * | --- | --- |
  88877. * | FOGMODE_NONE | 0 |
  88878. * | FOGMODE_EXP | 1 |
  88879. * | FOGMODE_EXP2 | 2 |
  88880. * | FOGMODE_LINEAR | 3 |
  88881. */
  88882. fogMode: number;
  88883. /**
  88884. * Gets or sets the fog color to use
  88885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88886. * (Default is Color3(0.2, 0.2, 0.3))
  88887. */
  88888. fogColor: Color3;
  88889. /**
  88890. * Gets or sets the fog density to use
  88891. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88892. * (Default is 0.1)
  88893. */
  88894. fogDensity: number;
  88895. /**
  88896. * Gets or sets the fog start distance to use
  88897. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88898. * (Default is 0)
  88899. */
  88900. fogStart: number;
  88901. /**
  88902. * Gets or sets the fog end distance to use
  88903. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88904. * (Default is 1000)
  88905. */
  88906. fogEnd: number;
  88907. private _shadowsEnabled;
  88908. /**
  88909. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88910. */
  88911. shadowsEnabled: boolean;
  88912. private _lightsEnabled;
  88913. /**
  88914. * Gets or sets a boolean indicating if lights are enabled on this scene
  88915. */
  88916. lightsEnabled: boolean;
  88917. /** All of the active cameras added to this scene. */
  88918. activeCameras: Camera[];
  88919. private _activeCamera;
  88920. /** Gets or sets the current active camera */
  88921. activeCamera: Nullable<Camera>;
  88922. private _defaultMaterial;
  88923. /** The default material used on meshes when no material is affected */
  88924. /** The default material used on meshes when no material is affected */
  88925. defaultMaterial: Material;
  88926. private _texturesEnabled;
  88927. /**
  88928. * Gets or sets a boolean indicating if textures are enabled on this scene
  88929. */
  88930. texturesEnabled: boolean;
  88931. /**
  88932. * Gets or sets a boolean indicating if particles are enabled on this scene
  88933. */
  88934. particlesEnabled: boolean;
  88935. /**
  88936. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88937. */
  88938. spritesEnabled: boolean;
  88939. private _skeletonsEnabled;
  88940. /**
  88941. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88942. */
  88943. skeletonsEnabled: boolean;
  88944. /**
  88945. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88946. */
  88947. lensFlaresEnabled: boolean;
  88948. /**
  88949. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88950. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88951. */
  88952. collisionsEnabled: boolean;
  88953. private _collisionCoordinator;
  88954. /** @hidden */
  88955. readonly collisionCoordinator: ICollisionCoordinator;
  88956. /**
  88957. * Defines the gravity applied to this scene (used only for collisions)
  88958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88959. */
  88960. gravity: Vector3;
  88961. /**
  88962. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88963. */
  88964. postProcessesEnabled: boolean;
  88965. /**
  88966. * The list of postprocesses added to the scene
  88967. */
  88968. postProcesses: PostProcess[];
  88969. /**
  88970. * Gets the current postprocess manager
  88971. */
  88972. postProcessManager: PostProcessManager;
  88973. /**
  88974. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88975. */
  88976. renderTargetsEnabled: boolean;
  88977. /**
  88978. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88979. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88980. */
  88981. dumpNextRenderTargets: boolean;
  88982. /**
  88983. * The list of user defined render targets added to the scene
  88984. */
  88985. customRenderTargets: RenderTargetTexture[];
  88986. /**
  88987. * Defines if texture loading must be delayed
  88988. * If true, textures will only be loaded when they need to be rendered
  88989. */
  88990. useDelayedTextureLoading: boolean;
  88991. /**
  88992. * Gets the list of meshes imported to the scene through SceneLoader
  88993. */
  88994. importedMeshesFiles: String[];
  88995. /**
  88996. * Gets or sets a boolean indicating if probes are enabled on this scene
  88997. */
  88998. probesEnabled: boolean;
  88999. /**
  89000. * Gets or sets the current offline provider to use to store scene data
  89001. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89002. */
  89003. offlineProvider: IOfflineProvider;
  89004. /**
  89005. * Gets or sets the action manager associated with the scene
  89006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89007. */
  89008. actionManager: AbstractActionManager;
  89009. private _meshesForIntersections;
  89010. /**
  89011. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89012. */
  89013. proceduralTexturesEnabled: boolean;
  89014. private _engine;
  89015. private _totalVertices;
  89016. /** @hidden */
  89017. _activeIndices: PerfCounter;
  89018. /** @hidden */
  89019. _activeParticles: PerfCounter;
  89020. /** @hidden */
  89021. _activeBones: PerfCounter;
  89022. private _animationRatio;
  89023. /** @hidden */
  89024. _animationTimeLast: number;
  89025. /** @hidden */
  89026. _animationTime: number;
  89027. /**
  89028. * Gets or sets a general scale for animation speed
  89029. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89030. */
  89031. animationTimeScale: number;
  89032. /** @hidden */
  89033. _cachedMaterial: Nullable<Material>;
  89034. /** @hidden */
  89035. _cachedEffect: Nullable<Effect>;
  89036. /** @hidden */
  89037. _cachedVisibility: Nullable<number>;
  89038. private _renderId;
  89039. private _frameId;
  89040. private _executeWhenReadyTimeoutId;
  89041. private _intermediateRendering;
  89042. private _viewUpdateFlag;
  89043. private _projectionUpdateFlag;
  89044. private _alternateViewUpdateFlag;
  89045. private _alternateProjectionUpdateFlag;
  89046. /** @hidden */
  89047. _toBeDisposed: Nullable<IDisposable>[];
  89048. private _activeRequests;
  89049. /** @hidden */
  89050. _pendingData: any[];
  89051. private _isDisposed;
  89052. /**
  89053. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89054. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89055. */
  89056. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89057. private _activeMeshes;
  89058. private _processedMaterials;
  89059. private _renderTargets;
  89060. /** @hidden */
  89061. _activeParticleSystems: SmartArray<IParticleSystem>;
  89062. private _activeSkeletons;
  89063. private _softwareSkinnedMeshes;
  89064. private _renderingManager;
  89065. /** @hidden */
  89066. _activeAnimatables: Animatable[];
  89067. private _transformMatrix;
  89068. private _sceneUbo;
  89069. private _alternateSceneUbo;
  89070. private _viewMatrix;
  89071. private _projectionMatrix;
  89072. private _alternateViewMatrix;
  89073. private _alternateProjectionMatrix;
  89074. private _alternateTransformMatrix;
  89075. private _useAlternateCameraConfiguration;
  89076. private _alternateRendering;
  89077. private _wheelEventName;
  89078. /** @hidden */
  89079. _forcedViewPosition: Nullable<Vector3>;
  89080. /** @hidden */
  89081. readonly _isAlternateRenderingEnabled: boolean;
  89082. private _frustumPlanes;
  89083. /**
  89084. * Gets the list of frustum planes (built from the active camera)
  89085. */
  89086. readonly frustumPlanes: Plane[];
  89087. /**
  89088. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89089. * This is useful if there are more lights that the maximum simulteanous authorized
  89090. */
  89091. requireLightSorting: boolean;
  89092. /** @hidden */
  89093. readonly useMaterialMeshMap: boolean;
  89094. /** @hidden */
  89095. readonly useClonedMeshhMap: boolean;
  89096. private _pointerOverMesh;
  89097. private _pickedDownMesh;
  89098. private _pickedUpMesh;
  89099. private _externalData;
  89100. private _uid;
  89101. /**
  89102. * @hidden
  89103. * Backing store of defined scene components.
  89104. */
  89105. _components: ISceneComponent[];
  89106. /**
  89107. * @hidden
  89108. * Backing store of defined scene components.
  89109. */
  89110. _serializableComponents: ISceneSerializableComponent[];
  89111. /**
  89112. * List of components to register on the next registration step.
  89113. */
  89114. private _transientComponents;
  89115. /**
  89116. * Registers the transient components if needed.
  89117. */
  89118. private _registerTransientComponents;
  89119. /**
  89120. * @hidden
  89121. * Add a component to the scene.
  89122. * Note that the ccomponent could be registered on th next frame if this is called after
  89123. * the register component stage.
  89124. * @param component Defines the component to add to the scene
  89125. */
  89126. _addComponent(component: ISceneComponent): void;
  89127. /**
  89128. * @hidden
  89129. * Gets a component from the scene.
  89130. * @param name defines the name of the component to retrieve
  89131. * @returns the component or null if not present
  89132. */
  89133. _getComponent(name: string): Nullable<ISceneComponent>;
  89134. /**
  89135. * @hidden
  89136. * Defines the actions happening before camera updates.
  89137. */
  89138. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89139. /**
  89140. * @hidden
  89141. * Defines the actions happening before clear the canvas.
  89142. */
  89143. _beforeClearStage: Stage<SimpleStageAction>;
  89144. /**
  89145. * @hidden
  89146. * Defines the actions when collecting render targets for the frame.
  89147. */
  89148. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89149. /**
  89150. * @hidden
  89151. * Defines the actions happening for one camera in the frame.
  89152. */
  89153. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89154. /**
  89155. * @hidden
  89156. * Defines the actions happening during the per mesh ready checks.
  89157. */
  89158. _isReadyForMeshStage: Stage<MeshStageAction>;
  89159. /**
  89160. * @hidden
  89161. * Defines the actions happening before evaluate active mesh checks.
  89162. */
  89163. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89164. /**
  89165. * @hidden
  89166. * Defines the actions happening during the evaluate sub mesh checks.
  89167. */
  89168. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89169. /**
  89170. * @hidden
  89171. * Defines the actions happening during the active mesh stage.
  89172. */
  89173. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89174. /**
  89175. * @hidden
  89176. * Defines the actions happening during the per camera render target step.
  89177. */
  89178. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89179. /**
  89180. * @hidden
  89181. * Defines the actions happening just before the active camera is drawing.
  89182. */
  89183. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89184. /**
  89185. * @hidden
  89186. * Defines the actions happening just before a render target is drawing.
  89187. */
  89188. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89189. /**
  89190. * @hidden
  89191. * Defines the actions happening just before a rendering group is drawing.
  89192. */
  89193. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89194. /**
  89195. * @hidden
  89196. * Defines the actions happening just before a mesh is drawing.
  89197. */
  89198. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89199. /**
  89200. * @hidden
  89201. * Defines the actions happening just after a mesh has been drawn.
  89202. */
  89203. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89204. /**
  89205. * @hidden
  89206. * Defines the actions happening just after a rendering group has been drawn.
  89207. */
  89208. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89209. /**
  89210. * @hidden
  89211. * Defines the actions happening just after the active camera has been drawn.
  89212. */
  89213. _afterCameraDrawStage: Stage<CameraStageAction>;
  89214. /**
  89215. * @hidden
  89216. * Defines the actions happening just after a render target has been drawn.
  89217. */
  89218. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89219. /**
  89220. * @hidden
  89221. * Defines the actions happening just after rendering all cameras and computing intersections.
  89222. */
  89223. _afterRenderStage: Stage<SimpleStageAction>;
  89224. /**
  89225. * @hidden
  89226. * Defines the actions happening when a pointer move event happens.
  89227. */
  89228. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89229. /**
  89230. * @hidden
  89231. * Defines the actions happening when a pointer down event happens.
  89232. */
  89233. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89234. /**
  89235. * @hidden
  89236. * Defines the actions happening when a pointer up event happens.
  89237. */
  89238. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89239. /**
  89240. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89241. */
  89242. private geometriesByUniqueId;
  89243. /**
  89244. * Creates a new Scene
  89245. * @param engine defines the engine to use to render this scene
  89246. * @param options defines the scene options
  89247. */
  89248. constructor(engine: Engine, options?: SceneOptions);
  89249. private _defaultMeshCandidates;
  89250. /**
  89251. * @hidden
  89252. */
  89253. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89254. private _defaultSubMeshCandidates;
  89255. /**
  89256. * @hidden
  89257. */
  89258. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89259. /**
  89260. * Sets the default candidate providers for the scene.
  89261. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89262. * and getCollidingSubMeshCandidates to their default function
  89263. */
  89264. setDefaultCandidateProviders(): void;
  89265. /**
  89266. * Gets the mesh that is currently under the pointer
  89267. */
  89268. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89269. /**
  89270. * Gets or sets the current on-screen X position of the pointer
  89271. */
  89272. pointerX: number;
  89273. /**
  89274. * Gets or sets the current on-screen Y position of the pointer
  89275. */
  89276. pointerY: number;
  89277. /**
  89278. * Gets the cached material (ie. the latest rendered one)
  89279. * @returns the cached material
  89280. */
  89281. getCachedMaterial(): Nullable<Material>;
  89282. /**
  89283. * Gets the cached effect (ie. the latest rendered one)
  89284. * @returns the cached effect
  89285. */
  89286. getCachedEffect(): Nullable<Effect>;
  89287. /**
  89288. * Gets the cached visibility state (ie. the latest rendered one)
  89289. * @returns the cached visibility state
  89290. */
  89291. getCachedVisibility(): Nullable<number>;
  89292. /**
  89293. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89294. * @param material defines the current material
  89295. * @param effect defines the current effect
  89296. * @param visibility defines the current visibility state
  89297. * @returns true if one parameter is not cached
  89298. */
  89299. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89300. /**
  89301. * Gets the engine associated with the scene
  89302. * @returns an Engine
  89303. */
  89304. getEngine(): Engine;
  89305. /**
  89306. * Gets the total number of vertices rendered per frame
  89307. * @returns the total number of vertices rendered per frame
  89308. */
  89309. getTotalVertices(): number;
  89310. /**
  89311. * Gets the performance counter for total vertices
  89312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89313. */
  89314. readonly totalVerticesPerfCounter: PerfCounter;
  89315. /**
  89316. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89317. * @returns the total number of active indices rendered per frame
  89318. */
  89319. getActiveIndices(): number;
  89320. /**
  89321. * Gets the performance counter for active indices
  89322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89323. */
  89324. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89325. /**
  89326. * Gets the total number of active particles rendered per frame
  89327. * @returns the total number of active particles rendered per frame
  89328. */
  89329. getActiveParticles(): number;
  89330. /**
  89331. * Gets the performance counter for active particles
  89332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89333. */
  89334. readonly activeParticlesPerfCounter: PerfCounter;
  89335. /**
  89336. * Gets the total number of active bones rendered per frame
  89337. * @returns the total number of active bones rendered per frame
  89338. */
  89339. getActiveBones(): number;
  89340. /**
  89341. * Gets the performance counter for active bones
  89342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89343. */
  89344. readonly activeBonesPerfCounter: PerfCounter;
  89345. /**
  89346. * Gets the array of active meshes
  89347. * @returns an array of AbstractMesh
  89348. */
  89349. getActiveMeshes(): SmartArray<AbstractMesh>;
  89350. /**
  89351. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89352. * @returns a number
  89353. */
  89354. getAnimationRatio(): number;
  89355. /**
  89356. * Gets an unique Id for the current render phase
  89357. * @returns a number
  89358. */
  89359. getRenderId(): number;
  89360. /**
  89361. * Gets an unique Id for the current frame
  89362. * @returns a number
  89363. */
  89364. getFrameId(): number;
  89365. /** Call this function if you want to manually increment the render Id*/
  89366. incrementRenderId(): void;
  89367. private _updatePointerPosition;
  89368. private _createUbo;
  89369. private _createAlternateUbo;
  89370. private _setRayOnPointerInfo;
  89371. /**
  89372. * Use this method to simulate a pointer move on a mesh
  89373. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89374. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89375. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89376. * @returns the current scene
  89377. */
  89378. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89379. private _processPointerMove;
  89380. private _checkPrePointerObservable;
  89381. /**
  89382. * Use this method to simulate a pointer down on a mesh
  89383. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89384. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89385. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89386. * @returns the current scene
  89387. */
  89388. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89389. private _processPointerDown;
  89390. /**
  89391. * Use this method to simulate a pointer up on a mesh
  89392. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89393. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89394. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89395. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89396. * @returns the current scene
  89397. */
  89398. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89399. private _processPointerUp;
  89400. /**
  89401. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89402. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89403. * @returns true if the pointer was captured
  89404. */
  89405. isPointerCaptured(pointerId?: number): boolean;
  89406. /** @hidden */
  89407. _isPointerSwiping(): boolean;
  89408. /**
  89409. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89410. * @param attachUp defines if you want to attach events to pointerup
  89411. * @param attachDown defines if you want to attach events to pointerdown
  89412. * @param attachMove defines if you want to attach events to pointermove
  89413. */
  89414. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89415. /** Detaches all event handlers*/
  89416. detachControl(): void;
  89417. /**
  89418. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89419. * Delay loaded resources are not taking in account
  89420. * @return true if all required resources are ready
  89421. */
  89422. isReady(): boolean;
  89423. /** Resets all cached information relative to material (including effect and visibility) */
  89424. resetCachedMaterial(): void;
  89425. /**
  89426. * Registers a function to be called before every frame render
  89427. * @param func defines the function to register
  89428. */
  89429. registerBeforeRender(func: () => void): void;
  89430. /**
  89431. * Unregisters a function called before every frame render
  89432. * @param func defines the function to unregister
  89433. */
  89434. unregisterBeforeRender(func: () => void): void;
  89435. /**
  89436. * Registers a function to be called after every frame render
  89437. * @param func defines the function to register
  89438. */
  89439. registerAfterRender(func: () => void): void;
  89440. /**
  89441. * Unregisters a function called after every frame render
  89442. * @param func defines the function to unregister
  89443. */
  89444. unregisterAfterRender(func: () => void): void;
  89445. private _executeOnceBeforeRender;
  89446. /**
  89447. * The provided function will run before render once and will be disposed afterwards.
  89448. * A timeout delay can be provided so that the function will be executed in N ms.
  89449. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89450. * @param func The function to be executed.
  89451. * @param timeout optional delay in ms
  89452. */
  89453. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89454. /** @hidden */
  89455. _addPendingData(data: any): void;
  89456. /** @hidden */
  89457. _removePendingData(data: any): void;
  89458. /**
  89459. * Returns the number of items waiting to be loaded
  89460. * @returns the number of items waiting to be loaded
  89461. */
  89462. getWaitingItemsCount(): number;
  89463. /**
  89464. * Returns a boolean indicating if the scene is still loading data
  89465. */
  89466. readonly isLoading: boolean;
  89467. /**
  89468. * Registers a function to be executed when the scene is ready
  89469. * @param {Function} func - the function to be executed
  89470. */
  89471. executeWhenReady(func: () => void): void;
  89472. /**
  89473. * Returns a promise that resolves when the scene is ready
  89474. * @returns A promise that resolves when the scene is ready
  89475. */
  89476. whenReadyAsync(): Promise<void>;
  89477. /** @hidden */
  89478. _checkIsReady(): void;
  89479. /**
  89480. * Gets all animatable attached to the scene
  89481. */
  89482. readonly animatables: Animatable[];
  89483. /**
  89484. * Resets the last animation time frame.
  89485. * Useful to override when animations start running when loading a scene for the first time.
  89486. */
  89487. resetLastAnimationTimeFrame(): void;
  89488. /** @hidden */
  89489. _switchToAlternateCameraConfiguration(active: boolean): void;
  89490. /**
  89491. * Gets the current view matrix
  89492. * @returns a Matrix
  89493. */
  89494. getViewMatrix(): Matrix;
  89495. /**
  89496. * Gets the current projection matrix
  89497. * @returns a Matrix
  89498. */
  89499. getProjectionMatrix(): Matrix;
  89500. /**
  89501. * Gets the current transform matrix
  89502. * @returns a Matrix made of View * Projection
  89503. */
  89504. getTransformMatrix(): Matrix;
  89505. /**
  89506. * Sets the current transform matrix
  89507. * @param view defines the View matrix to use
  89508. * @param projection defines the Projection matrix to use
  89509. */
  89510. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89511. /** @hidden */
  89512. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89513. /**
  89514. * Gets the uniform buffer used to store scene data
  89515. * @returns a UniformBuffer
  89516. */
  89517. getSceneUniformBuffer(): UniformBuffer;
  89518. /**
  89519. * Gets an unique (relatively to the current scene) Id
  89520. * @returns an unique number for the scene
  89521. */
  89522. getUniqueId(): number;
  89523. /**
  89524. * Add a mesh to the list of scene's meshes
  89525. * @param newMesh defines the mesh to add
  89526. * @param recursive if all child meshes should also be added to the scene
  89527. */
  89528. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89529. /**
  89530. * Remove a mesh for the list of scene's meshes
  89531. * @param toRemove defines the mesh to remove
  89532. * @param recursive if all child meshes should also be removed from the scene
  89533. * @returns the index where the mesh was in the mesh list
  89534. */
  89535. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89536. /**
  89537. * Add a transform node to the list of scene's transform nodes
  89538. * @param newTransformNode defines the transform node to add
  89539. */
  89540. addTransformNode(newTransformNode: TransformNode): void;
  89541. /**
  89542. * Remove a transform node for the list of scene's transform nodes
  89543. * @param toRemove defines the transform node to remove
  89544. * @returns the index where the transform node was in the transform node list
  89545. */
  89546. removeTransformNode(toRemove: TransformNode): number;
  89547. /**
  89548. * Remove a skeleton for the list of scene's skeletons
  89549. * @param toRemove defines the skeleton to remove
  89550. * @returns the index where the skeleton was in the skeleton list
  89551. */
  89552. removeSkeleton(toRemove: Skeleton): number;
  89553. /**
  89554. * Remove a morph target for the list of scene's morph targets
  89555. * @param toRemove defines the morph target to remove
  89556. * @returns the index where the morph target was in the morph target list
  89557. */
  89558. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89559. /**
  89560. * Remove a light for the list of scene's lights
  89561. * @param toRemove defines the light to remove
  89562. * @returns the index where the light was in the light list
  89563. */
  89564. removeLight(toRemove: Light): number;
  89565. /**
  89566. * Remove a camera for the list of scene's cameras
  89567. * @param toRemove defines the camera to remove
  89568. * @returns the index where the camera was in the camera list
  89569. */
  89570. removeCamera(toRemove: Camera): number;
  89571. /**
  89572. * Remove a particle system for the list of scene's particle systems
  89573. * @param toRemove defines the particle system to remove
  89574. * @returns the index where the particle system was in the particle system list
  89575. */
  89576. removeParticleSystem(toRemove: IParticleSystem): number;
  89577. /**
  89578. * Remove a animation for the list of scene's animations
  89579. * @param toRemove defines the animation to remove
  89580. * @returns the index where the animation was in the animation list
  89581. */
  89582. removeAnimation(toRemove: Animation): number;
  89583. /**
  89584. * Removes the given animation group from this scene.
  89585. * @param toRemove The animation group to remove
  89586. * @returns The index of the removed animation group
  89587. */
  89588. removeAnimationGroup(toRemove: AnimationGroup): number;
  89589. /**
  89590. * Removes the given multi-material from this scene.
  89591. * @param toRemove The multi-material to remove
  89592. * @returns The index of the removed multi-material
  89593. */
  89594. removeMultiMaterial(toRemove: MultiMaterial): number;
  89595. /**
  89596. * Removes the given material from this scene.
  89597. * @param toRemove The material to remove
  89598. * @returns The index of the removed material
  89599. */
  89600. removeMaterial(toRemove: Material): number;
  89601. /**
  89602. * Removes the given action manager from this scene.
  89603. * @param toRemove The action manager to remove
  89604. * @returns The index of the removed action manager
  89605. */
  89606. removeActionManager(toRemove: AbstractActionManager): number;
  89607. /**
  89608. * Removes the given texture from this scene.
  89609. * @param toRemove The texture to remove
  89610. * @returns The index of the removed texture
  89611. */
  89612. removeTexture(toRemove: BaseTexture): number;
  89613. /**
  89614. * Adds the given light to this scene
  89615. * @param newLight The light to add
  89616. */
  89617. addLight(newLight: Light): void;
  89618. /**
  89619. * Sorts the list list based on light priorities
  89620. */
  89621. sortLightsByPriority(): void;
  89622. /**
  89623. * Adds the given camera to this scene
  89624. * @param newCamera The camera to add
  89625. */
  89626. addCamera(newCamera: Camera): void;
  89627. /**
  89628. * Adds the given skeleton to this scene
  89629. * @param newSkeleton The skeleton to add
  89630. */
  89631. addSkeleton(newSkeleton: Skeleton): void;
  89632. /**
  89633. * Adds the given particle system to this scene
  89634. * @param newParticleSystem The particle system to add
  89635. */
  89636. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89637. /**
  89638. * Adds the given animation to this scene
  89639. * @param newAnimation The animation to add
  89640. */
  89641. addAnimation(newAnimation: Animation): void;
  89642. /**
  89643. * Adds the given animation group to this scene.
  89644. * @param newAnimationGroup The animation group to add
  89645. */
  89646. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89647. /**
  89648. * Adds the given multi-material to this scene
  89649. * @param newMultiMaterial The multi-material to add
  89650. */
  89651. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89652. /**
  89653. * Adds the given material to this scene
  89654. * @param newMaterial The material to add
  89655. */
  89656. addMaterial(newMaterial: Material): void;
  89657. /**
  89658. * Adds the given morph target to this scene
  89659. * @param newMorphTargetManager The morph target to add
  89660. */
  89661. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89662. /**
  89663. * Adds the given geometry to this scene
  89664. * @param newGeometry The geometry to add
  89665. */
  89666. addGeometry(newGeometry: Geometry): void;
  89667. /**
  89668. * Adds the given action manager to this scene
  89669. * @param newActionManager The action manager to add
  89670. */
  89671. addActionManager(newActionManager: AbstractActionManager): void;
  89672. /**
  89673. * Adds the given texture to this scene.
  89674. * @param newTexture The texture to add
  89675. */
  89676. addTexture(newTexture: BaseTexture): void;
  89677. /**
  89678. * Switch active camera
  89679. * @param newCamera defines the new active camera
  89680. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89681. */
  89682. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89683. /**
  89684. * sets the active camera of the scene using its ID
  89685. * @param id defines the camera's ID
  89686. * @return the new active camera or null if none found.
  89687. */
  89688. setActiveCameraByID(id: string): Nullable<Camera>;
  89689. /**
  89690. * sets the active camera of the scene using its name
  89691. * @param name defines the camera's name
  89692. * @returns the new active camera or null if none found.
  89693. */
  89694. setActiveCameraByName(name: string): Nullable<Camera>;
  89695. /**
  89696. * get an animation group using its name
  89697. * @param name defines the material's name
  89698. * @return the animation group or null if none found.
  89699. */
  89700. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89701. /**
  89702. * get a material using its id
  89703. * @param id defines the material's ID
  89704. * @return the material or null if none found.
  89705. */
  89706. getMaterialByID(id: string): Nullable<Material>;
  89707. /**
  89708. * Gets a material using its name
  89709. * @param name defines the material's name
  89710. * @return the material or null if none found.
  89711. */
  89712. getMaterialByName(name: string): Nullable<Material>;
  89713. /**
  89714. * Gets a camera using its id
  89715. * @param id defines the id to look for
  89716. * @returns the camera or null if not found
  89717. */
  89718. getCameraByID(id: string): Nullable<Camera>;
  89719. /**
  89720. * Gets a camera using its unique id
  89721. * @param uniqueId defines the unique id to look for
  89722. * @returns the camera or null if not found
  89723. */
  89724. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89725. /**
  89726. * Gets a camera using its name
  89727. * @param name defines the camera's name
  89728. * @return the camera or null if none found.
  89729. */
  89730. getCameraByName(name: string): Nullable<Camera>;
  89731. /**
  89732. * Gets a bone using its id
  89733. * @param id defines the bone's id
  89734. * @return the bone or null if not found
  89735. */
  89736. getBoneByID(id: string): Nullable<Bone>;
  89737. /**
  89738. * Gets a bone using its id
  89739. * @param name defines the bone's name
  89740. * @return the bone or null if not found
  89741. */
  89742. getBoneByName(name: string): Nullable<Bone>;
  89743. /**
  89744. * Gets a light node using its name
  89745. * @param name defines the the light's name
  89746. * @return the light or null if none found.
  89747. */
  89748. getLightByName(name: string): Nullable<Light>;
  89749. /**
  89750. * Gets a light node using its id
  89751. * @param id defines the light's id
  89752. * @return the light or null if none found.
  89753. */
  89754. getLightByID(id: string): Nullable<Light>;
  89755. /**
  89756. * Gets a light node using its scene-generated unique ID
  89757. * @param uniqueId defines the light's unique id
  89758. * @return the light or null if none found.
  89759. */
  89760. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89761. /**
  89762. * Gets a particle system by id
  89763. * @param id defines the particle system id
  89764. * @return the corresponding system or null if none found
  89765. */
  89766. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89767. /**
  89768. * Gets a geometry using its ID
  89769. * @param id defines the geometry's id
  89770. * @return the geometry or null if none found.
  89771. */
  89772. getGeometryByID(id: string): Nullable<Geometry>;
  89773. private _getGeometryByUniqueID;
  89774. /**
  89775. * Add a new geometry to this scene
  89776. * @param geometry defines the geometry to be added to the scene.
  89777. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89778. * @return a boolean defining if the geometry was added or not
  89779. */
  89780. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89781. /**
  89782. * Removes an existing geometry
  89783. * @param geometry defines the geometry to be removed from the scene
  89784. * @return a boolean defining if the geometry was removed or not
  89785. */
  89786. removeGeometry(geometry: Geometry): boolean;
  89787. /**
  89788. * Gets the list of geometries attached to the scene
  89789. * @returns an array of Geometry
  89790. */
  89791. getGeometries(): Geometry[];
  89792. /**
  89793. * Gets the first added mesh found of a given ID
  89794. * @param id defines the id to search for
  89795. * @return the mesh found or null if not found at all
  89796. */
  89797. getMeshByID(id: string): Nullable<AbstractMesh>;
  89798. /**
  89799. * Gets a list of meshes using their id
  89800. * @param id defines the id to search for
  89801. * @returns a list of meshes
  89802. */
  89803. getMeshesByID(id: string): Array<AbstractMesh>;
  89804. /**
  89805. * Gets the first added transform node found of a given ID
  89806. * @param id defines the id to search for
  89807. * @return the found transform node or null if not found at all.
  89808. */
  89809. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89810. /**
  89811. * Gets a list of transform nodes using their id
  89812. * @param id defines the id to search for
  89813. * @returns a list of transform nodes
  89814. */
  89815. getTransformNodesByID(id: string): Array<TransformNode>;
  89816. /**
  89817. * Gets a mesh with its auto-generated unique id
  89818. * @param uniqueId defines the unique id to search for
  89819. * @return the found mesh or null if not found at all.
  89820. */
  89821. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89822. /**
  89823. * Gets a the last added mesh using a given id
  89824. * @param id defines the id to search for
  89825. * @return the found mesh or null if not found at all.
  89826. */
  89827. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89828. /**
  89829. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89830. * @param id defines the id to search for
  89831. * @return the found node or null if not found at all
  89832. */
  89833. getLastEntryByID(id: string): Nullable<Node>;
  89834. /**
  89835. * Gets a node (Mesh, Camera, Light) using a given id
  89836. * @param id defines the id to search for
  89837. * @return the found node or null if not found at all
  89838. */
  89839. getNodeByID(id: string): Nullable<Node>;
  89840. /**
  89841. * Gets a node (Mesh, Camera, Light) using a given name
  89842. * @param name defines the name to search for
  89843. * @return the found node or null if not found at all.
  89844. */
  89845. getNodeByName(name: string): Nullable<Node>;
  89846. /**
  89847. * Gets a mesh using a given name
  89848. * @param name defines the name to search for
  89849. * @return the found mesh or null if not found at all.
  89850. */
  89851. getMeshByName(name: string): Nullable<AbstractMesh>;
  89852. /**
  89853. * Gets a transform node using a given name
  89854. * @param name defines the name to search for
  89855. * @return the found transform node or null if not found at all.
  89856. */
  89857. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89858. /**
  89859. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89860. * @param id defines the id to search for
  89861. * @return the found skeleton or null if not found at all.
  89862. */
  89863. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89864. /**
  89865. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89866. * @param id defines the id to search for
  89867. * @return the found skeleton or null if not found at all.
  89868. */
  89869. getSkeletonById(id: string): Nullable<Skeleton>;
  89870. /**
  89871. * Gets a skeleton using a given name
  89872. * @param name defines the name to search for
  89873. * @return the found skeleton or null if not found at all.
  89874. */
  89875. getSkeletonByName(name: string): Nullable<Skeleton>;
  89876. /**
  89877. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89878. * @param id defines the id to search for
  89879. * @return the found morph target manager or null if not found at all.
  89880. */
  89881. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89882. /**
  89883. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89884. * @param id defines the id to search for
  89885. * @return the found morph target or null if not found at all.
  89886. */
  89887. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89888. /**
  89889. * Gets a boolean indicating if the given mesh is active
  89890. * @param mesh defines the mesh to look for
  89891. * @returns true if the mesh is in the active list
  89892. */
  89893. isActiveMesh(mesh: AbstractMesh): boolean;
  89894. /**
  89895. * Return a unique id as a string which can serve as an identifier for the scene
  89896. */
  89897. readonly uid: string;
  89898. /**
  89899. * Add an externaly attached data from its key.
  89900. * This method call will fail and return false, if such key already exists.
  89901. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89902. * @param key the unique key that identifies the data
  89903. * @param data the data object to associate to the key for this Engine instance
  89904. * @return true if no such key were already present and the data was added successfully, false otherwise
  89905. */
  89906. addExternalData<T>(key: string, data: T): boolean;
  89907. /**
  89908. * Get an externaly attached data from its key
  89909. * @param key the unique key that identifies the data
  89910. * @return the associated data, if present (can be null), or undefined if not present
  89911. */
  89912. getExternalData<T>(key: string): Nullable<T>;
  89913. /**
  89914. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89915. * @param key the unique key that identifies the data
  89916. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89917. * @return the associated data, can be null if the factory returned null.
  89918. */
  89919. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89920. /**
  89921. * Remove an externaly attached data from the Engine instance
  89922. * @param key the unique key that identifies the data
  89923. * @return true if the data was successfully removed, false if it doesn't exist
  89924. */
  89925. removeExternalData(key: string): boolean;
  89926. private _evaluateSubMesh;
  89927. /**
  89928. * Clear the processed materials smart array preventing retention point in material dispose.
  89929. */
  89930. freeProcessedMaterials(): void;
  89931. private _preventFreeActiveMeshesAndRenderingGroups;
  89932. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89933. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89934. * when disposing several meshes in a row or a hierarchy of meshes.
  89935. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89936. */
  89937. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89938. /**
  89939. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89940. */
  89941. freeActiveMeshes(): void;
  89942. /**
  89943. * Clear the info related to rendering groups preventing retention points during dispose.
  89944. */
  89945. freeRenderingGroups(): void;
  89946. /** @hidden */
  89947. _isInIntermediateRendering(): boolean;
  89948. /**
  89949. * Lambda returning the list of potentially active meshes.
  89950. */
  89951. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89952. /**
  89953. * Lambda returning the list of potentially active sub meshes.
  89954. */
  89955. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89956. /**
  89957. * Lambda returning the list of potentially intersecting sub meshes.
  89958. */
  89959. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89960. /**
  89961. * Lambda returning the list of potentially colliding sub meshes.
  89962. */
  89963. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89964. private _activeMeshesFrozen;
  89965. /**
  89966. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89967. * @returns the current scene
  89968. */
  89969. freezeActiveMeshes(): Scene;
  89970. /**
  89971. * Use this function to restart evaluating active meshes on every frame
  89972. * @returns the current scene
  89973. */
  89974. unfreezeActiveMeshes(): Scene;
  89975. private _evaluateActiveMeshes;
  89976. private _activeMesh;
  89977. /**
  89978. * Update the transform matrix to update from the current active camera
  89979. * @param force defines a boolean used to force the update even if cache is up to date
  89980. */
  89981. updateTransformMatrix(force?: boolean): void;
  89982. /**
  89983. * 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)
  89984. * @param alternateCamera defines the camera to use
  89985. */
  89986. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89987. /** @hidden */
  89988. _allowPostProcessClearColor: boolean;
  89989. private _renderForCamera;
  89990. private _processSubCameras;
  89991. private _checkIntersections;
  89992. /** @hidden */
  89993. _advancePhysicsEngineStep(step: number): void;
  89994. /**
  89995. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89996. */
  89997. getDeterministicFrameTime: () => number;
  89998. /** @hidden */
  89999. _animate(): void;
  90000. /**
  90001. * Render the scene
  90002. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90003. */
  90004. render(updateCameras?: boolean): void;
  90005. /**
  90006. * Freeze all materials
  90007. * A frozen material will not be updatable but should be faster to render
  90008. */
  90009. freezeMaterials(): void;
  90010. /**
  90011. * Unfreeze all materials
  90012. * A frozen material will not be updatable but should be faster to render
  90013. */
  90014. unfreezeMaterials(): void;
  90015. /**
  90016. * Releases all held ressources
  90017. */
  90018. dispose(): void;
  90019. /**
  90020. * Gets if the scene is already disposed
  90021. */
  90022. readonly isDisposed: boolean;
  90023. /**
  90024. * Call this function to reduce memory footprint of the scene.
  90025. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90026. */
  90027. clearCachedVertexData(): void;
  90028. /**
  90029. * This function will remove the local cached buffer data from texture.
  90030. * It will save memory but will prevent the texture from being rebuilt
  90031. */
  90032. cleanCachedTextureBuffer(): void;
  90033. /**
  90034. * Get the world extend vectors with an optional filter
  90035. *
  90036. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90037. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90038. */
  90039. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90040. min: Vector3;
  90041. max: Vector3;
  90042. };
  90043. /**
  90044. * Creates a ray that can be used to pick in the scene
  90045. * @param x defines the x coordinate of the origin (on-screen)
  90046. * @param y defines the y coordinate of the origin (on-screen)
  90047. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90048. * @param camera defines the camera to use for the picking
  90049. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90050. * @returns a Ray
  90051. */
  90052. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90053. /**
  90054. * Creates a ray that can be used to pick in the scene
  90055. * @param x defines the x coordinate of the origin (on-screen)
  90056. * @param y defines the y coordinate of the origin (on-screen)
  90057. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90058. * @param result defines the ray where to store the picking ray
  90059. * @param camera defines the camera to use for the picking
  90060. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90061. * @returns the current scene
  90062. */
  90063. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90064. /**
  90065. * Creates a ray that can be used to pick in the scene
  90066. * @param x defines the x coordinate of the origin (on-screen)
  90067. * @param y defines the y coordinate of the origin (on-screen)
  90068. * @param camera defines the camera to use for the picking
  90069. * @returns a Ray
  90070. */
  90071. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90072. /**
  90073. * Creates a ray that can be used to pick in the scene
  90074. * @param x defines the x coordinate of the origin (on-screen)
  90075. * @param y defines the y coordinate of the origin (on-screen)
  90076. * @param result defines the ray where to store the picking ray
  90077. * @param camera defines the camera to use for the picking
  90078. * @returns the current scene
  90079. */
  90080. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90081. /** Launch a ray to try to pick a mesh in the scene
  90082. * @param x position on screen
  90083. * @param y position on screen
  90084. * @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
  90085. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90086. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90088. * @returns a PickingInfo
  90089. */
  90090. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90091. /** Use the given ray to pick a mesh in the scene
  90092. * @param ray The ray to use to pick meshes
  90093. * @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
  90094. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90095. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90096. * @returns a PickingInfo
  90097. */
  90098. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90099. /**
  90100. * Launch a ray to try to pick a mesh in the scene
  90101. * @param x X position on screen
  90102. * @param y Y position on screen
  90103. * @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
  90104. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90105. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90106. * @returns an array of PickingInfo
  90107. */
  90108. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90109. /**
  90110. * Launch a ray to try to pick a mesh in the scene
  90111. * @param ray Ray to use
  90112. * @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
  90113. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90114. * @returns an array of PickingInfo
  90115. */
  90116. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90117. /**
  90118. * Force the value of meshUnderPointer
  90119. * @param mesh defines the mesh to use
  90120. */
  90121. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90122. /**
  90123. * Gets the mesh under the pointer
  90124. * @returns a Mesh or null if no mesh is under the pointer
  90125. */
  90126. getPointerOverMesh(): Nullable<AbstractMesh>;
  90127. /** @hidden */
  90128. _rebuildGeometries(): void;
  90129. /** @hidden */
  90130. _rebuildTextures(): void;
  90131. private _getByTags;
  90132. /**
  90133. * Get a list of meshes by tags
  90134. * @param tagsQuery defines the tags query to use
  90135. * @param forEach defines a predicate used to filter results
  90136. * @returns an array of Mesh
  90137. */
  90138. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90139. /**
  90140. * Get a list of cameras by tags
  90141. * @param tagsQuery defines the tags query to use
  90142. * @param forEach defines a predicate used to filter results
  90143. * @returns an array of Camera
  90144. */
  90145. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90146. /**
  90147. * Get a list of lights by tags
  90148. * @param tagsQuery defines the tags query to use
  90149. * @param forEach defines a predicate used to filter results
  90150. * @returns an array of Light
  90151. */
  90152. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90153. /**
  90154. * Get a list of materials by tags
  90155. * @param tagsQuery defines the tags query to use
  90156. * @param forEach defines a predicate used to filter results
  90157. * @returns an array of Material
  90158. */
  90159. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90160. /**
  90161. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90162. * This allowed control for front to back rendering or reversly depending of the special needs.
  90163. *
  90164. * @param renderingGroupId The rendering group id corresponding to its index
  90165. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90166. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90167. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90168. */
  90169. 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;
  90170. /**
  90171. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90172. *
  90173. * @param renderingGroupId The rendering group id corresponding to its index
  90174. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90175. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90176. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90177. */
  90178. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90179. /**
  90180. * Gets the current auto clear configuration for one rendering group of the rendering
  90181. * manager.
  90182. * @param index the rendering group index to get the information for
  90183. * @returns The auto clear setup for the requested rendering group
  90184. */
  90185. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90186. private _blockMaterialDirtyMechanism;
  90187. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90188. blockMaterialDirtyMechanism: boolean;
  90189. /**
  90190. * Will flag all materials as dirty to trigger new shader compilation
  90191. * @param flag defines the flag used to specify which material part must be marked as dirty
  90192. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90193. */
  90194. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90195. /** @hidden */
  90196. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  90197. /** @hidden */
  90198. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90199. }
  90200. }
  90201. declare module BABYLON {
  90202. /**
  90203. * Set of assets to keep when moving a scene into an asset container.
  90204. */
  90205. export class KeepAssets extends AbstractScene {
  90206. }
  90207. /**
  90208. * Container with a set of assets that can be added or removed from a scene.
  90209. */
  90210. export class AssetContainer extends AbstractScene {
  90211. /**
  90212. * The scene the AssetContainer belongs to.
  90213. */
  90214. scene: Scene;
  90215. /**
  90216. * Instantiates an AssetContainer.
  90217. * @param scene The scene the AssetContainer belongs to.
  90218. */
  90219. constructor(scene: Scene);
  90220. /**
  90221. * Adds all the assets from the container to the scene.
  90222. */
  90223. addAllToScene(): void;
  90224. /**
  90225. * Removes all the assets in the container from the scene
  90226. */
  90227. removeAllFromScene(): void;
  90228. /**
  90229. * Disposes all the assets in the container
  90230. */
  90231. dispose(): void;
  90232. private _moveAssets;
  90233. /**
  90234. * Removes all the assets contained in the scene and adds them to the container.
  90235. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90236. */
  90237. moveAllFromScene(keepAssets?: KeepAssets): void;
  90238. /**
  90239. * 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.
  90240. * @returns the root mesh
  90241. */
  90242. createRootMesh(): Mesh;
  90243. }
  90244. }
  90245. declare module BABYLON {
  90246. /**
  90247. * Defines how the parser contract is defined.
  90248. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90249. */
  90250. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90251. /**
  90252. * Defines how the individual parser contract is defined.
  90253. * These parser can parse an individual asset
  90254. */
  90255. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90256. /**
  90257. * Base class of the scene acting as a container for the different elements composing a scene.
  90258. * This class is dynamically extended by the different components of the scene increasing
  90259. * flexibility and reducing coupling
  90260. */
  90261. export abstract class AbstractScene {
  90262. /**
  90263. * Stores the list of available parsers in the application.
  90264. */
  90265. private static _BabylonFileParsers;
  90266. /**
  90267. * Stores the list of available individual parsers in the application.
  90268. */
  90269. private static _IndividualBabylonFileParsers;
  90270. /**
  90271. * Adds a parser in the list of available ones
  90272. * @param name Defines the name of the parser
  90273. * @param parser Defines the parser to add
  90274. */
  90275. static AddParser(name: string, parser: BabylonFileParser): void;
  90276. /**
  90277. * Gets a general parser from the list of avaialble ones
  90278. * @param name Defines the name of the parser
  90279. * @returns the requested parser or null
  90280. */
  90281. static GetParser(name: string): Nullable<BabylonFileParser>;
  90282. /**
  90283. * Adds n individual parser in the list of available ones
  90284. * @param name Defines the name of the parser
  90285. * @param parser Defines the parser to add
  90286. */
  90287. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90288. /**
  90289. * Gets an individual parser from the list of avaialble ones
  90290. * @param name Defines the name of the parser
  90291. * @returns the requested parser or null
  90292. */
  90293. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90294. /**
  90295. * Parser json data and populate both a scene and its associated container object
  90296. * @param jsonData Defines the data to parse
  90297. * @param scene Defines the scene to parse the data for
  90298. * @param container Defines the container attached to the parsing sequence
  90299. * @param rootUrl Defines the root url of the data
  90300. */
  90301. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90302. /**
  90303. * Gets the list of root nodes (ie. nodes with no parent)
  90304. */
  90305. rootNodes: Node[];
  90306. /** All of the cameras added to this scene
  90307. * @see http://doc.babylonjs.com/babylon101/cameras
  90308. */
  90309. cameras: Camera[];
  90310. /**
  90311. * All of the lights added to this scene
  90312. * @see http://doc.babylonjs.com/babylon101/lights
  90313. */
  90314. lights: Light[];
  90315. /**
  90316. * All of the (abstract) meshes added to this scene
  90317. */
  90318. meshes: AbstractMesh[];
  90319. /**
  90320. * The list of skeletons added to the scene
  90321. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90322. */
  90323. skeletons: Skeleton[];
  90324. /**
  90325. * All of the particle systems added to this scene
  90326. * @see http://doc.babylonjs.com/babylon101/particles
  90327. */
  90328. particleSystems: IParticleSystem[];
  90329. /**
  90330. * Gets a list of Animations associated with the scene
  90331. */
  90332. animations: Animation[];
  90333. /**
  90334. * All of the animation groups added to this scene
  90335. * @see http://doc.babylonjs.com/how_to/group
  90336. */
  90337. animationGroups: AnimationGroup[];
  90338. /**
  90339. * All of the multi-materials added to this scene
  90340. * @see http://doc.babylonjs.com/how_to/multi_materials
  90341. */
  90342. multiMaterials: MultiMaterial[];
  90343. /**
  90344. * All of the materials added to this scene
  90345. * In the context of a Scene, it is not supposed to be modified manually.
  90346. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90347. * Note also that the order of the Material wihin the array is not significant and might change.
  90348. * @see http://doc.babylonjs.com/babylon101/materials
  90349. */
  90350. materials: Material[];
  90351. /**
  90352. * The list of morph target managers added to the scene
  90353. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90354. */
  90355. morphTargetManagers: MorphTargetManager[];
  90356. /**
  90357. * The list of geometries used in the scene.
  90358. */
  90359. geometries: Geometry[];
  90360. /**
  90361. * All of the tranform nodes added to this scene
  90362. * In the context of a Scene, it is not supposed to be modified manually.
  90363. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90364. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90365. * @see http://doc.babylonjs.com/how_to/transformnode
  90366. */
  90367. transformNodes: TransformNode[];
  90368. /**
  90369. * ActionManagers available on the scene.
  90370. */
  90371. actionManagers: AbstractActionManager[];
  90372. /**
  90373. * Textures to keep.
  90374. */
  90375. textures: BaseTexture[];
  90376. }
  90377. }
  90378. declare module BABYLON {
  90379. /**
  90380. * Defines a sound that can be played in the application.
  90381. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90383. */
  90384. export class Sound {
  90385. /**
  90386. * The name of the sound in the scene.
  90387. */
  90388. name: string;
  90389. /**
  90390. * Does the sound autoplay once loaded.
  90391. */
  90392. autoplay: boolean;
  90393. /**
  90394. * Does the sound loop after it finishes playing once.
  90395. */
  90396. loop: boolean;
  90397. /**
  90398. * Does the sound use a custom attenuation curve to simulate the falloff
  90399. * happening when the source gets further away from the camera.
  90400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90401. */
  90402. useCustomAttenuation: boolean;
  90403. /**
  90404. * The sound track id this sound belongs to.
  90405. */
  90406. soundTrackId: number;
  90407. /**
  90408. * Is this sound currently played.
  90409. */
  90410. isPlaying: boolean;
  90411. /**
  90412. * Is this sound currently paused.
  90413. */
  90414. isPaused: boolean;
  90415. /**
  90416. * Does this sound enables spatial sound.
  90417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90418. */
  90419. spatialSound: boolean;
  90420. /**
  90421. * Define the reference distance the sound should be heard perfectly.
  90422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90423. */
  90424. refDistance: number;
  90425. /**
  90426. * Define the roll off factor of spatial sounds.
  90427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90428. */
  90429. rolloffFactor: number;
  90430. /**
  90431. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90433. */
  90434. maxDistance: number;
  90435. /**
  90436. * Define the distance attenuation model the sound will follow.
  90437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90438. */
  90439. distanceModel: string;
  90440. /**
  90441. * @hidden
  90442. * Back Compat
  90443. **/
  90444. onended: () => any;
  90445. /**
  90446. * Observable event when the current playing sound finishes.
  90447. */
  90448. onEndedObservable: Observable<Sound>;
  90449. private _panningModel;
  90450. private _playbackRate;
  90451. private _streaming;
  90452. private _startTime;
  90453. private _startOffset;
  90454. private _position;
  90455. /** @hidden */
  90456. _positionInEmitterSpace: boolean;
  90457. private _localDirection;
  90458. private _volume;
  90459. private _isReadyToPlay;
  90460. private _isDirectional;
  90461. private _readyToPlayCallback;
  90462. private _audioBuffer;
  90463. private _soundSource;
  90464. private _streamingSource;
  90465. private _soundPanner;
  90466. private _soundGain;
  90467. private _inputAudioNode;
  90468. private _outputAudioNode;
  90469. private _coneInnerAngle;
  90470. private _coneOuterAngle;
  90471. private _coneOuterGain;
  90472. private _scene;
  90473. private _connectedTransformNode;
  90474. private _customAttenuationFunction;
  90475. private _registerFunc;
  90476. private _isOutputConnected;
  90477. private _htmlAudioElement;
  90478. private _urlType;
  90479. /** @hidden */
  90480. static _SceneComponentInitialization: (scene: Scene) => void;
  90481. /**
  90482. * Create a sound and attach it to a scene
  90483. * @param name Name of your sound
  90484. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90485. * @param scene defines the scene the sound belongs to
  90486. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90487. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90488. */
  90489. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90490. /**
  90491. * Release the sound and its associated resources
  90492. */
  90493. dispose(): void;
  90494. /**
  90495. * Gets if the sounds is ready to be played or not.
  90496. * @returns true if ready, otherwise false
  90497. */
  90498. isReady(): boolean;
  90499. private _soundLoaded;
  90500. /**
  90501. * Sets the data of the sound from an audiobuffer
  90502. * @param audioBuffer The audioBuffer containing the data
  90503. */
  90504. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90505. /**
  90506. * Updates the current sounds options such as maxdistance, loop...
  90507. * @param options A JSON object containing values named as the object properties
  90508. */
  90509. updateOptions(options: any): void;
  90510. private _createSpatialParameters;
  90511. private _updateSpatialParameters;
  90512. /**
  90513. * Switch the panning model to HRTF:
  90514. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90516. */
  90517. switchPanningModelToHRTF(): void;
  90518. /**
  90519. * Switch the panning model to Equal Power:
  90520. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90522. */
  90523. switchPanningModelToEqualPower(): void;
  90524. private _switchPanningModel;
  90525. /**
  90526. * Connect this sound to a sound track audio node like gain...
  90527. * @param soundTrackAudioNode the sound track audio node to connect to
  90528. */
  90529. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90530. /**
  90531. * Transform this sound into a directional source
  90532. * @param coneInnerAngle Size of the inner cone in degree
  90533. * @param coneOuterAngle Size of the outer cone in degree
  90534. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90535. */
  90536. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90537. /**
  90538. * Gets or sets the inner angle for the directional cone.
  90539. */
  90540. /**
  90541. * Gets or sets the inner angle for the directional cone.
  90542. */
  90543. directionalConeInnerAngle: number;
  90544. /**
  90545. * Gets or sets the outer angle for the directional cone.
  90546. */
  90547. /**
  90548. * Gets or sets the outer angle for the directional cone.
  90549. */
  90550. directionalConeOuterAngle: number;
  90551. /**
  90552. * Sets the position of the emitter if spatial sound is enabled
  90553. * @param newPosition Defines the new posisiton
  90554. */
  90555. setPosition(newPosition: Vector3): void;
  90556. /**
  90557. * Sets the local direction of the emitter if spatial sound is enabled
  90558. * @param newLocalDirection Defines the new local direction
  90559. */
  90560. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90561. private _updateDirection;
  90562. /** @hidden */
  90563. updateDistanceFromListener(): void;
  90564. /**
  90565. * Sets a new custom attenuation function for the sound.
  90566. * @param callback Defines the function used for the attenuation
  90567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90568. */
  90569. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90570. /**
  90571. * Play the sound
  90572. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90573. * @param offset (optional) Start the sound setting it at a specific time
  90574. */
  90575. play(time?: number, offset?: number): void;
  90576. private _onended;
  90577. /**
  90578. * Stop the sound
  90579. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90580. */
  90581. stop(time?: number): void;
  90582. /**
  90583. * Put the sound in pause
  90584. */
  90585. pause(): void;
  90586. /**
  90587. * Sets a dedicated volume for this sounds
  90588. * @param newVolume Define the new volume of the sound
  90589. * @param time Define in how long the sound should be at this value
  90590. */
  90591. setVolume(newVolume: number, time?: number): void;
  90592. /**
  90593. * Set the sound play back rate
  90594. * @param newPlaybackRate Define the playback rate the sound should be played at
  90595. */
  90596. setPlaybackRate(newPlaybackRate: number): void;
  90597. /**
  90598. * Gets the volume of the sound.
  90599. * @returns the volume of the sound
  90600. */
  90601. getVolume(): number;
  90602. /**
  90603. * Attach the sound to a dedicated mesh
  90604. * @param transformNode The transform node to connect the sound with
  90605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90606. */
  90607. attachToMesh(transformNode: TransformNode): void;
  90608. /**
  90609. * Detach the sound from the previously attached mesh
  90610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90611. */
  90612. detachFromMesh(): void;
  90613. private _onRegisterAfterWorldMatrixUpdate;
  90614. /**
  90615. * Clone the current sound in the scene.
  90616. * @returns the new sound clone
  90617. */
  90618. clone(): Nullable<Sound>;
  90619. /**
  90620. * Gets the current underlying audio buffer containing the data
  90621. * @returns the audio buffer
  90622. */
  90623. getAudioBuffer(): Nullable<AudioBuffer>;
  90624. /**
  90625. * Serializes the Sound in a JSON representation
  90626. * @returns the JSON representation of the sound
  90627. */
  90628. serialize(): any;
  90629. /**
  90630. * Parse a JSON representation of a sound to innstantiate in a given scene
  90631. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90632. * @param scene Define the scene the new parsed sound should be created in
  90633. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90634. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90635. * @returns the newly parsed sound
  90636. */
  90637. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90638. }
  90639. }
  90640. declare module BABYLON {
  90641. /**
  90642. * This defines an action helpful to play a defined sound on a triggered action.
  90643. */
  90644. export class PlaySoundAction extends Action {
  90645. private _sound;
  90646. /**
  90647. * Instantiate the action
  90648. * @param triggerOptions defines the trigger options
  90649. * @param sound defines the sound to play
  90650. * @param condition defines the trigger related conditions
  90651. */
  90652. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90653. /** @hidden */
  90654. _prepare(): void;
  90655. /**
  90656. * Execute the action and play the sound.
  90657. */
  90658. execute(): void;
  90659. /**
  90660. * Serializes the actions and its related information.
  90661. * @param parent defines the object to serialize in
  90662. * @returns the serialized object
  90663. */
  90664. serialize(parent: any): any;
  90665. }
  90666. /**
  90667. * This defines an action helpful to stop a defined sound on a triggered action.
  90668. */
  90669. export class StopSoundAction extends Action {
  90670. private _sound;
  90671. /**
  90672. * Instantiate the action
  90673. * @param triggerOptions defines the trigger options
  90674. * @param sound defines the sound to stop
  90675. * @param condition defines the trigger related conditions
  90676. */
  90677. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90678. /** @hidden */
  90679. _prepare(): void;
  90680. /**
  90681. * Execute the action and stop the sound.
  90682. */
  90683. execute(): void;
  90684. /**
  90685. * Serializes the actions and its related information.
  90686. * @param parent defines the object to serialize in
  90687. * @returns the serialized object
  90688. */
  90689. serialize(parent: any): any;
  90690. }
  90691. }
  90692. declare module BABYLON {
  90693. /**
  90694. * This defines an action responsible to change the value of a property
  90695. * by interpolating between its current value and the newly set one once triggered.
  90696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90697. */
  90698. export class InterpolateValueAction extends Action {
  90699. /**
  90700. * Defines the path of the property where the value should be interpolated
  90701. */
  90702. propertyPath: string;
  90703. /**
  90704. * Defines the target value at the end of the interpolation.
  90705. */
  90706. value: any;
  90707. /**
  90708. * Defines the time it will take for the property to interpolate to the value.
  90709. */
  90710. duration: number;
  90711. /**
  90712. * Defines if the other scene animations should be stopped when the action has been triggered
  90713. */
  90714. stopOtherAnimations?: boolean;
  90715. /**
  90716. * Defines a callback raised once the interpolation animation has been done.
  90717. */
  90718. onInterpolationDone?: () => void;
  90719. /**
  90720. * Observable triggered once the interpolation animation has been done.
  90721. */
  90722. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90723. private _target;
  90724. private _effectiveTarget;
  90725. private _property;
  90726. /**
  90727. * Instantiate the action
  90728. * @param triggerOptions defines the trigger options
  90729. * @param target defines the object containing the value to interpolate
  90730. * @param propertyPath defines the path to the property in the target object
  90731. * @param value defines the target value at the end of the interpolation
  90732. * @param duration deines the time it will take for the property to interpolate to the value.
  90733. * @param condition defines the trigger related conditions
  90734. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90735. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90736. */
  90737. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90738. /** @hidden */
  90739. _prepare(): void;
  90740. /**
  90741. * Execute the action starts the value interpolation.
  90742. */
  90743. execute(): void;
  90744. /**
  90745. * Serializes the actions and its related information.
  90746. * @param parent defines the object to serialize in
  90747. * @returns the serialized object
  90748. */
  90749. serialize(parent: any): any;
  90750. }
  90751. }
  90752. declare module BABYLON {
  90753. /**
  90754. * Options allowed during the creation of a sound track.
  90755. */
  90756. export interface ISoundTrackOptions {
  90757. /**
  90758. * The volume the sound track should take during creation
  90759. */
  90760. volume?: number;
  90761. /**
  90762. * Define if the sound track is the main sound track of the scene
  90763. */
  90764. mainTrack?: boolean;
  90765. }
  90766. /**
  90767. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90768. * It will be also used in a future release to apply effects on a specific track.
  90769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90770. */
  90771. export class SoundTrack {
  90772. /**
  90773. * The unique identifier of the sound track in the scene.
  90774. */
  90775. id: number;
  90776. /**
  90777. * The list of sounds included in the sound track.
  90778. */
  90779. soundCollection: Array<Sound>;
  90780. private _outputAudioNode;
  90781. private _scene;
  90782. private _isMainTrack;
  90783. private _connectedAnalyser;
  90784. private _options;
  90785. private _isInitialized;
  90786. /**
  90787. * Creates a new sound track.
  90788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90789. * @param scene Define the scene the sound track belongs to
  90790. * @param options
  90791. */
  90792. constructor(scene: Scene, options?: ISoundTrackOptions);
  90793. private _initializeSoundTrackAudioGraph;
  90794. /**
  90795. * Release the sound track and its associated resources
  90796. */
  90797. dispose(): void;
  90798. /**
  90799. * Adds a sound to this sound track
  90800. * @param sound define the cound to add
  90801. * @ignoreNaming
  90802. */
  90803. AddSound(sound: Sound): void;
  90804. /**
  90805. * Removes a sound to this sound track
  90806. * @param sound define the cound to remove
  90807. * @ignoreNaming
  90808. */
  90809. RemoveSound(sound: Sound): void;
  90810. /**
  90811. * Set a global volume for the full sound track.
  90812. * @param newVolume Define the new volume of the sound track
  90813. */
  90814. setVolume(newVolume: number): void;
  90815. /**
  90816. * Switch the panning model to HRTF:
  90817. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90819. */
  90820. switchPanningModelToHRTF(): void;
  90821. /**
  90822. * Switch the panning model to Equal Power:
  90823. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90825. */
  90826. switchPanningModelToEqualPower(): void;
  90827. /**
  90828. * Connect the sound track to an audio analyser allowing some amazing
  90829. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90831. * @param analyser The analyser to connect to the engine
  90832. */
  90833. connectToAnalyser(analyser: Analyser): void;
  90834. }
  90835. }
  90836. declare module BABYLON {
  90837. interface AbstractScene {
  90838. /**
  90839. * The list of sounds used in the scene.
  90840. */
  90841. sounds: Nullable<Array<Sound>>;
  90842. }
  90843. interface Scene {
  90844. /**
  90845. * @hidden
  90846. * Backing field
  90847. */
  90848. _mainSoundTrack: SoundTrack;
  90849. /**
  90850. * The main sound track played by the scene.
  90851. * It cotains your primary collection of sounds.
  90852. */
  90853. mainSoundTrack: SoundTrack;
  90854. /**
  90855. * The list of sound tracks added to the scene
  90856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90857. */
  90858. soundTracks: Nullable<Array<SoundTrack>>;
  90859. /**
  90860. * Gets a sound using a given name
  90861. * @param name defines the name to search for
  90862. * @return the found sound or null if not found at all.
  90863. */
  90864. getSoundByName(name: string): Nullable<Sound>;
  90865. /**
  90866. * Gets or sets if audio support is enabled
  90867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90868. */
  90869. audioEnabled: boolean;
  90870. /**
  90871. * Gets or sets if audio will be output to headphones
  90872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90873. */
  90874. headphone: boolean;
  90875. }
  90876. /**
  90877. * Defines the sound scene component responsible to manage any sounds
  90878. * in a given scene.
  90879. */
  90880. export class AudioSceneComponent implements ISceneSerializableComponent {
  90881. /**
  90882. * The component name helpfull to identify the component in the list of scene components.
  90883. */
  90884. readonly name: string;
  90885. /**
  90886. * The scene the component belongs to.
  90887. */
  90888. scene: Scene;
  90889. private _audioEnabled;
  90890. /**
  90891. * Gets whether audio is enabled or not.
  90892. * Please use related enable/disable method to switch state.
  90893. */
  90894. readonly audioEnabled: boolean;
  90895. private _headphone;
  90896. /**
  90897. * Gets whether audio is outputing to headphone or not.
  90898. * Please use the according Switch methods to change output.
  90899. */
  90900. readonly headphone: boolean;
  90901. /**
  90902. * Creates a new instance of the component for the given scene
  90903. * @param scene Defines the scene to register the component in
  90904. */
  90905. constructor(scene: Scene);
  90906. /**
  90907. * Registers the component in a given scene
  90908. */
  90909. register(): void;
  90910. /**
  90911. * Rebuilds the elements related to this component in case of
  90912. * context lost for instance.
  90913. */
  90914. rebuild(): void;
  90915. /**
  90916. * Serializes the component data to the specified json object
  90917. * @param serializationObject The object to serialize to
  90918. */
  90919. serialize(serializationObject: any): void;
  90920. /**
  90921. * Adds all the element from the container to the scene
  90922. * @param container the container holding the elements
  90923. */
  90924. addFromContainer(container: AbstractScene): void;
  90925. /**
  90926. * Removes all the elements in the container from the scene
  90927. * @param container contains the elements to remove
  90928. */
  90929. removeFromContainer(container: AbstractScene): void;
  90930. /**
  90931. * Disposes the component and the associated ressources.
  90932. */
  90933. dispose(): void;
  90934. /**
  90935. * Disables audio in the associated scene.
  90936. */
  90937. disableAudio(): void;
  90938. /**
  90939. * Enables audio in the associated scene.
  90940. */
  90941. enableAudio(): void;
  90942. /**
  90943. * Switch audio to headphone output.
  90944. */
  90945. switchAudioModeForHeadphones(): void;
  90946. /**
  90947. * Switch audio to normal speakers.
  90948. */
  90949. switchAudioModeForNormalSpeakers(): void;
  90950. private _afterRender;
  90951. }
  90952. }
  90953. declare module BABYLON {
  90954. /**
  90955. * Wraps one or more Sound objects and selects one with random weight for playback.
  90956. */
  90957. export class WeightedSound {
  90958. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90959. loop: boolean;
  90960. private _coneInnerAngle;
  90961. private _coneOuterAngle;
  90962. private _volume;
  90963. /** A Sound is currently playing. */
  90964. isPlaying: boolean;
  90965. /** A Sound is currently paused. */
  90966. isPaused: boolean;
  90967. private _sounds;
  90968. private _weights;
  90969. private _currentIndex?;
  90970. /**
  90971. * Creates a new WeightedSound from the list of sounds given.
  90972. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90973. * @param sounds Array of Sounds that will be selected from.
  90974. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90975. */
  90976. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90977. /**
  90978. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90979. */
  90980. /**
  90981. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90982. */
  90983. directionalConeInnerAngle: number;
  90984. /**
  90985. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90986. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90987. */
  90988. /**
  90989. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90990. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90991. */
  90992. directionalConeOuterAngle: number;
  90993. /**
  90994. * Playback volume.
  90995. */
  90996. /**
  90997. * Playback volume.
  90998. */
  90999. volume: number;
  91000. private _onended;
  91001. /**
  91002. * Suspend playback
  91003. */
  91004. pause(): void;
  91005. /**
  91006. * Stop playback
  91007. */
  91008. stop(): void;
  91009. /**
  91010. * Start playback.
  91011. * @param startOffset Position the clip head at a specific time in seconds.
  91012. */
  91013. play(startOffset?: number): void;
  91014. }
  91015. }
  91016. declare module BABYLON {
  91017. /**
  91018. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91020. */
  91021. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91022. /**
  91023. * Gets the name of the behavior.
  91024. */
  91025. readonly name: string;
  91026. /**
  91027. * The easing function used by animations
  91028. */
  91029. static EasingFunction: BackEase;
  91030. /**
  91031. * The easing mode used by animations
  91032. */
  91033. static EasingMode: number;
  91034. /**
  91035. * The duration of the animation, in milliseconds
  91036. */
  91037. transitionDuration: number;
  91038. /**
  91039. * Length of the distance animated by the transition when lower radius is reached
  91040. */
  91041. lowerRadiusTransitionRange: number;
  91042. /**
  91043. * Length of the distance animated by the transition when upper radius is reached
  91044. */
  91045. upperRadiusTransitionRange: number;
  91046. private _autoTransitionRange;
  91047. /**
  91048. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91049. */
  91050. /**
  91051. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91052. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91053. */
  91054. autoTransitionRange: boolean;
  91055. private _attachedCamera;
  91056. private _onAfterCheckInputsObserver;
  91057. private _onMeshTargetChangedObserver;
  91058. /**
  91059. * Initializes the behavior.
  91060. */
  91061. init(): void;
  91062. /**
  91063. * Attaches the behavior to its arc rotate camera.
  91064. * @param camera Defines the camera to attach the behavior to
  91065. */
  91066. attach(camera: ArcRotateCamera): void;
  91067. /**
  91068. * Detaches the behavior from its current arc rotate camera.
  91069. */
  91070. detach(): void;
  91071. private _radiusIsAnimating;
  91072. private _radiusBounceTransition;
  91073. private _animatables;
  91074. private _cachedWheelPrecision;
  91075. /**
  91076. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91077. * @param radiusLimit The limit to check against.
  91078. * @return Bool to indicate if at limit.
  91079. */
  91080. private _isRadiusAtLimit;
  91081. /**
  91082. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91083. * @param radiusDelta The delta by which to animate to. Can be negative.
  91084. */
  91085. private _applyBoundRadiusAnimation;
  91086. /**
  91087. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91088. */
  91089. protected _clearAnimationLocks(): void;
  91090. /**
  91091. * Stops and removes all animations that have been applied to the camera
  91092. */
  91093. stopAllAnimations(): void;
  91094. }
  91095. }
  91096. declare module BABYLON {
  91097. /**
  91098. * 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.
  91099. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91100. */
  91101. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91102. /**
  91103. * Gets the name of the behavior.
  91104. */
  91105. readonly name: string;
  91106. private _mode;
  91107. private _radiusScale;
  91108. private _positionScale;
  91109. private _defaultElevation;
  91110. private _elevationReturnTime;
  91111. private _elevationReturnWaitTime;
  91112. private _zoomStopsAnimation;
  91113. private _framingTime;
  91114. /**
  91115. * The easing function used by animations
  91116. */
  91117. static EasingFunction: ExponentialEase;
  91118. /**
  91119. * The easing mode used by animations
  91120. */
  91121. static EasingMode: number;
  91122. /**
  91123. * Sets the current mode used by the behavior
  91124. */
  91125. /**
  91126. * Gets current mode used by the behavior.
  91127. */
  91128. mode: number;
  91129. /**
  91130. * Sets the scale applied to the radius (1 by default)
  91131. */
  91132. /**
  91133. * Gets the scale applied to the radius
  91134. */
  91135. radiusScale: number;
  91136. /**
  91137. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91138. */
  91139. /**
  91140. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91141. */
  91142. positionScale: number;
  91143. /**
  91144. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91145. * behaviour is triggered, in radians.
  91146. */
  91147. /**
  91148. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91149. * behaviour is triggered, in radians.
  91150. */
  91151. defaultElevation: number;
  91152. /**
  91153. * Sets the time (in milliseconds) taken to return to the default beta position.
  91154. * Negative value indicates camera should not return to default.
  91155. */
  91156. /**
  91157. * Gets the time (in milliseconds) taken to return to the default beta position.
  91158. * Negative value indicates camera should not return to default.
  91159. */
  91160. elevationReturnTime: number;
  91161. /**
  91162. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91163. */
  91164. /**
  91165. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91166. */
  91167. elevationReturnWaitTime: number;
  91168. /**
  91169. * Sets the flag that indicates if user zooming should stop animation.
  91170. */
  91171. /**
  91172. * Gets the flag that indicates if user zooming should stop animation.
  91173. */
  91174. zoomStopsAnimation: boolean;
  91175. /**
  91176. * Sets the transition time when framing the mesh, in milliseconds
  91177. */
  91178. /**
  91179. * Gets the transition time when framing the mesh, in milliseconds
  91180. */
  91181. framingTime: number;
  91182. /**
  91183. * Define if the behavior should automatically change the configured
  91184. * camera limits and sensibilities.
  91185. */
  91186. autoCorrectCameraLimitsAndSensibility: boolean;
  91187. private _onPrePointerObservableObserver;
  91188. private _onAfterCheckInputsObserver;
  91189. private _onMeshTargetChangedObserver;
  91190. private _attachedCamera;
  91191. private _isPointerDown;
  91192. private _lastInteractionTime;
  91193. /**
  91194. * Initializes the behavior.
  91195. */
  91196. init(): void;
  91197. /**
  91198. * Attaches the behavior to its arc rotate camera.
  91199. * @param camera Defines the camera to attach the behavior to
  91200. */
  91201. attach(camera: ArcRotateCamera): void;
  91202. /**
  91203. * Detaches the behavior from its current arc rotate camera.
  91204. */
  91205. detach(): void;
  91206. private _animatables;
  91207. private _betaIsAnimating;
  91208. private _betaTransition;
  91209. private _radiusTransition;
  91210. private _vectorTransition;
  91211. /**
  91212. * Targets the given mesh and updates zoom level accordingly.
  91213. * @param mesh The mesh to target.
  91214. * @param radius Optional. If a cached radius position already exists, overrides default.
  91215. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91216. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91217. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91218. */
  91219. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91220. /**
  91221. * Targets the given mesh with its children and updates zoom level accordingly.
  91222. * @param mesh The mesh to target.
  91223. * @param radius Optional. If a cached radius position already exists, overrides default.
  91224. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91225. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91226. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91227. */
  91228. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91229. /**
  91230. * Targets the given meshes with their children and updates zoom level accordingly.
  91231. * @param meshes The mesh to target.
  91232. * @param radius Optional. If a cached radius position already exists, overrides default.
  91233. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91234. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91235. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91236. */
  91237. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91238. /**
  91239. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91240. * @param minimumWorld Determines the smaller position of the bounding box extend
  91241. * @param maximumWorld Determines the bigger position of the bounding box extend
  91242. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91243. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91244. */
  91245. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91246. /**
  91247. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91248. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91249. * frustum width.
  91250. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91251. * to fully enclose the mesh in the viewing frustum.
  91252. */
  91253. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91254. /**
  91255. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91256. * is automatically returned to its default position (expected to be above ground plane).
  91257. */
  91258. private _maintainCameraAboveGround;
  91259. /**
  91260. * Returns the frustum slope based on the canvas ratio and camera FOV
  91261. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91262. */
  91263. private _getFrustumSlope;
  91264. /**
  91265. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91266. */
  91267. private _clearAnimationLocks;
  91268. /**
  91269. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91270. */
  91271. private _applyUserInteraction;
  91272. /**
  91273. * Stops and removes all animations that have been applied to the camera
  91274. */
  91275. stopAllAnimations(): void;
  91276. /**
  91277. * Gets a value indicating if the user is moving the camera
  91278. */
  91279. readonly isUserIsMoving: boolean;
  91280. /**
  91281. * The camera can move all the way towards the mesh.
  91282. */
  91283. static IgnoreBoundsSizeMode: number;
  91284. /**
  91285. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91286. */
  91287. static FitFrustumSidesMode: number;
  91288. }
  91289. }
  91290. declare module BABYLON {
  91291. /**
  91292. * Base class for Camera Pointer Inputs.
  91293. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91294. * for example usage.
  91295. */
  91296. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91297. /**
  91298. * Defines the camera the input is attached to.
  91299. */
  91300. abstract camera: Camera;
  91301. /**
  91302. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91303. */
  91304. protected _altKey: boolean;
  91305. protected _ctrlKey: boolean;
  91306. protected _metaKey: boolean;
  91307. protected _shiftKey: boolean;
  91308. /**
  91309. * Which mouse buttons were pressed at time of last mouse event.
  91310. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91311. */
  91312. protected _buttonsPressed: number;
  91313. /**
  91314. * Defines the buttons associated with the input to handle camera move.
  91315. */
  91316. buttons: number[];
  91317. /**
  91318. * Attach the input controls to a specific dom element to get the input from.
  91319. * @param element Defines the element the controls should be listened from
  91320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91321. */
  91322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91323. /**
  91324. * Detach the current controls from the specified dom element.
  91325. * @param element Defines the element to stop listening the inputs from
  91326. */
  91327. detachControl(element: Nullable<HTMLElement>): void;
  91328. /**
  91329. * Gets the class name of the current input.
  91330. * @returns the class name
  91331. */
  91332. getClassName(): string;
  91333. /**
  91334. * Get the friendly name associated with the input class.
  91335. * @returns the input friendly name
  91336. */
  91337. getSimpleName(): string;
  91338. /**
  91339. * Called on pointer POINTERDOUBLETAP event.
  91340. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91341. */
  91342. protected onDoubleTap(type: string): void;
  91343. /**
  91344. * Called on pointer POINTERMOVE event if only a single touch is active.
  91345. * Override this method to provide functionality.
  91346. */
  91347. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91348. /**
  91349. * Called on pointer POINTERMOVE event if multiple touches are active.
  91350. * Override this method to provide functionality.
  91351. */
  91352. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91353. /**
  91354. * Called on JS contextmenu event.
  91355. * Override this method to provide functionality.
  91356. */
  91357. protected onContextMenu(evt: PointerEvent): void;
  91358. /**
  91359. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91360. * press.
  91361. * Override this method to provide functionality.
  91362. */
  91363. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91364. /**
  91365. * Called each time a new POINTERUP event occurs. Ie, for each button
  91366. * release.
  91367. * Override this method to provide functionality.
  91368. */
  91369. protected onButtonUp(evt: PointerEvent): void;
  91370. /**
  91371. * Called when window becomes inactive.
  91372. * Override this method to provide functionality.
  91373. */
  91374. protected onLostFocus(): void;
  91375. private _pointerInput;
  91376. private _observer;
  91377. private _onLostFocus;
  91378. }
  91379. }
  91380. declare module BABYLON {
  91381. /**
  91382. * Manage the pointers inputs to control an arc rotate camera.
  91383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91384. */
  91385. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91386. /**
  91387. * Defines the camera the input is attached to.
  91388. */
  91389. camera: ArcRotateCamera;
  91390. /**
  91391. * Gets the class name of the current input.
  91392. * @returns the class name
  91393. */
  91394. getClassName(): string;
  91395. /**
  91396. * Defines the buttons associated with the input to handle camera move.
  91397. */
  91398. buttons: number[];
  91399. /**
  91400. * Defines the pointer angular sensibility along the X axis or how fast is
  91401. * the camera rotating.
  91402. */
  91403. angularSensibilityX: number;
  91404. /**
  91405. * Defines the pointer angular sensibility along the Y axis or how fast is
  91406. * the camera rotating.
  91407. */
  91408. angularSensibilityY: number;
  91409. /**
  91410. * Defines the pointer pinch precision or how fast is the camera zooming.
  91411. */
  91412. pinchPrecision: number;
  91413. /**
  91414. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91415. * from 0.
  91416. * It defines the percentage of current camera.radius to use as delta when
  91417. * pinch zoom is used.
  91418. */
  91419. pinchDeltaPercentage: number;
  91420. /**
  91421. * Defines the pointer panning sensibility or how fast is the camera moving.
  91422. */
  91423. panningSensibility: number;
  91424. /**
  91425. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91426. */
  91427. multiTouchPanning: boolean;
  91428. /**
  91429. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91430. * zoom (pinch) through multitouch.
  91431. */
  91432. multiTouchPanAndZoom: boolean;
  91433. /**
  91434. * Revers pinch action direction.
  91435. */
  91436. pinchInwards: boolean;
  91437. private _isPanClick;
  91438. private _twoFingerActivityCount;
  91439. private _isPinching;
  91440. /**
  91441. * Called on pointer POINTERMOVE event if only a single touch is active.
  91442. */
  91443. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91444. /**
  91445. * Called on pointer POINTERDOUBLETAP event.
  91446. */
  91447. protected onDoubleTap(type: string): void;
  91448. /**
  91449. * Called on pointer POINTERMOVE event if multiple touches are active.
  91450. */
  91451. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91452. /**
  91453. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91454. * press.
  91455. */
  91456. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91457. /**
  91458. * Called each time a new POINTERUP event occurs. Ie, for each button
  91459. * release.
  91460. */
  91461. protected onButtonUp(evt: PointerEvent): void;
  91462. /**
  91463. * Called when window becomes inactive.
  91464. */
  91465. protected onLostFocus(): void;
  91466. }
  91467. }
  91468. declare module BABYLON {
  91469. /**
  91470. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91472. */
  91473. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91474. /**
  91475. * Defines the camera the input is attached to.
  91476. */
  91477. camera: ArcRotateCamera;
  91478. /**
  91479. * Defines the list of key codes associated with the up action (increase alpha)
  91480. */
  91481. keysUp: number[];
  91482. /**
  91483. * Defines the list of key codes associated with the down action (decrease alpha)
  91484. */
  91485. keysDown: number[];
  91486. /**
  91487. * Defines the list of key codes associated with the left action (increase beta)
  91488. */
  91489. keysLeft: number[];
  91490. /**
  91491. * Defines the list of key codes associated with the right action (decrease beta)
  91492. */
  91493. keysRight: number[];
  91494. /**
  91495. * Defines the list of key codes associated with the reset action.
  91496. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91497. */
  91498. keysReset: number[];
  91499. /**
  91500. * Defines the panning sensibility of the inputs.
  91501. * (How fast is the camera paning)
  91502. */
  91503. panningSensibility: number;
  91504. /**
  91505. * Defines the zooming sensibility of the inputs.
  91506. * (How fast is the camera zooming)
  91507. */
  91508. zoomingSensibility: number;
  91509. /**
  91510. * Defines wether maintaining the alt key down switch the movement mode from
  91511. * orientation to zoom.
  91512. */
  91513. useAltToZoom: boolean;
  91514. /**
  91515. * Rotation speed of the camera
  91516. */
  91517. angularSpeed: number;
  91518. private _keys;
  91519. private _ctrlPressed;
  91520. private _altPressed;
  91521. private _onCanvasBlurObserver;
  91522. private _onKeyboardObserver;
  91523. private _engine;
  91524. private _scene;
  91525. /**
  91526. * Attach the input controls to a specific dom element to get the input from.
  91527. * @param element Defines the element the controls should be listened from
  91528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91529. */
  91530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91531. /**
  91532. * Detach the current controls from the specified dom element.
  91533. * @param element Defines the element to stop listening the inputs from
  91534. */
  91535. detachControl(element: Nullable<HTMLElement>): void;
  91536. /**
  91537. * Update the current camera state depending on the inputs that have been used this frame.
  91538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91539. */
  91540. checkInputs(): void;
  91541. /**
  91542. * Gets the class name of the current intput.
  91543. * @returns the class name
  91544. */
  91545. getClassName(): string;
  91546. /**
  91547. * Get the friendly name associated with the input class.
  91548. * @returns the input friendly name
  91549. */
  91550. getSimpleName(): string;
  91551. }
  91552. }
  91553. declare module BABYLON {
  91554. /**
  91555. * Manage the mouse wheel inputs to control an arc rotate camera.
  91556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91557. */
  91558. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91559. /**
  91560. * Defines the camera the input is attached to.
  91561. */
  91562. camera: ArcRotateCamera;
  91563. /**
  91564. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91565. */
  91566. wheelPrecision: number;
  91567. /**
  91568. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91569. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91570. */
  91571. wheelDeltaPercentage: number;
  91572. private _wheel;
  91573. private _observer;
  91574. /**
  91575. * Attach the input controls to a specific dom element to get the input from.
  91576. * @param element Defines the element the controls should be listened from
  91577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91578. */
  91579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91580. /**
  91581. * Detach the current controls from the specified dom element.
  91582. * @param element Defines the element to stop listening the inputs from
  91583. */
  91584. detachControl(element: Nullable<HTMLElement>): void;
  91585. /**
  91586. * Gets the class name of the current intput.
  91587. * @returns the class name
  91588. */
  91589. getClassName(): string;
  91590. /**
  91591. * Get the friendly name associated with the input class.
  91592. * @returns the input friendly name
  91593. */
  91594. getSimpleName(): string;
  91595. }
  91596. }
  91597. declare module BABYLON {
  91598. /**
  91599. * Default Inputs manager for the ArcRotateCamera.
  91600. * It groups all the default supported inputs for ease of use.
  91601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91602. */
  91603. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91604. /**
  91605. * Instantiates a new ArcRotateCameraInputsManager.
  91606. * @param camera Defines the camera the inputs belong to
  91607. */
  91608. constructor(camera: ArcRotateCamera);
  91609. /**
  91610. * Add mouse wheel input support to the input manager.
  91611. * @returns the current input manager
  91612. */
  91613. addMouseWheel(): ArcRotateCameraInputsManager;
  91614. /**
  91615. * Add pointers input support to the input manager.
  91616. * @returns the current input manager
  91617. */
  91618. addPointers(): ArcRotateCameraInputsManager;
  91619. /**
  91620. * Add keyboard input support to the input manager.
  91621. * @returns the current input manager
  91622. */
  91623. addKeyboard(): ArcRotateCameraInputsManager;
  91624. }
  91625. }
  91626. declare module BABYLON {
  91627. /**
  91628. * This represents an orbital type of camera.
  91629. *
  91630. * 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.
  91631. * 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.
  91632. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91633. */
  91634. export class ArcRotateCamera extends TargetCamera {
  91635. /**
  91636. * Defines the rotation angle of the camera along the longitudinal axis.
  91637. */
  91638. alpha: number;
  91639. /**
  91640. * Defines the rotation angle of the camera along the latitudinal axis.
  91641. */
  91642. beta: number;
  91643. /**
  91644. * Defines the radius of the camera from it s target point.
  91645. */
  91646. radius: number;
  91647. protected _target: Vector3;
  91648. protected _targetHost: Nullable<AbstractMesh>;
  91649. /**
  91650. * Defines the target point of the camera.
  91651. * The camera looks towards it form the radius distance.
  91652. */
  91653. target: Vector3;
  91654. /**
  91655. * Define the current local position of the camera in the scene
  91656. */
  91657. position: Vector3;
  91658. /**
  91659. * Current inertia value on the longitudinal axis.
  91660. * The bigger this number the longer it will take for the camera to stop.
  91661. */
  91662. inertialAlphaOffset: number;
  91663. /**
  91664. * Current inertia value on the latitudinal axis.
  91665. * The bigger this number the longer it will take for the camera to stop.
  91666. */
  91667. inertialBetaOffset: number;
  91668. /**
  91669. * Current inertia value on the radius axis.
  91670. * The bigger this number the longer it will take for the camera to stop.
  91671. */
  91672. inertialRadiusOffset: number;
  91673. /**
  91674. * Minimum allowed angle on the longitudinal axis.
  91675. * This can help limiting how the Camera is able to move in the scene.
  91676. */
  91677. lowerAlphaLimit: Nullable<number>;
  91678. /**
  91679. * Maximum allowed angle on the longitudinal axis.
  91680. * This can help limiting how the Camera is able to move in the scene.
  91681. */
  91682. upperAlphaLimit: Nullable<number>;
  91683. /**
  91684. * Minimum allowed angle on the latitudinal axis.
  91685. * This can help limiting how the Camera is able to move in the scene.
  91686. */
  91687. lowerBetaLimit: number;
  91688. /**
  91689. * Maximum allowed angle on the latitudinal axis.
  91690. * This can help limiting how the Camera is able to move in the scene.
  91691. */
  91692. upperBetaLimit: number;
  91693. /**
  91694. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91695. * This can help limiting how the Camera is able to move in the scene.
  91696. */
  91697. lowerRadiusLimit: Nullable<number>;
  91698. /**
  91699. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91700. * This can help limiting how the Camera is able to move in the scene.
  91701. */
  91702. upperRadiusLimit: Nullable<number>;
  91703. /**
  91704. * Defines the current inertia value used during panning of the camera along the X axis.
  91705. */
  91706. inertialPanningX: number;
  91707. /**
  91708. * Defines the current inertia value used during panning of the camera along the Y axis.
  91709. */
  91710. inertialPanningY: number;
  91711. /**
  91712. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91713. * Basically if your fingers moves away from more than this distance you will be considered
  91714. * in pinch mode.
  91715. */
  91716. pinchToPanMaxDistance: number;
  91717. /**
  91718. * Defines the maximum distance the camera can pan.
  91719. * This could help keeping the cammera always in your scene.
  91720. */
  91721. panningDistanceLimit: Nullable<number>;
  91722. /**
  91723. * Defines the target of the camera before paning.
  91724. */
  91725. panningOriginTarget: Vector3;
  91726. /**
  91727. * Defines the value of the inertia used during panning.
  91728. * 0 would mean stop inertia and one would mean no decelleration at all.
  91729. */
  91730. panningInertia: number;
  91731. /**
  91732. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91733. */
  91734. angularSensibilityX: number;
  91735. /**
  91736. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91737. */
  91738. angularSensibilityY: number;
  91739. /**
  91740. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91741. */
  91742. pinchPrecision: number;
  91743. /**
  91744. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91745. * It will be used instead of pinchDeltaPrecision if different from 0.
  91746. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91747. */
  91748. pinchDeltaPercentage: number;
  91749. /**
  91750. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91751. */
  91752. panningSensibility: number;
  91753. /**
  91754. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91755. */
  91756. keysUp: number[];
  91757. /**
  91758. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91759. */
  91760. keysDown: number[];
  91761. /**
  91762. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91763. */
  91764. keysLeft: number[];
  91765. /**
  91766. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91767. */
  91768. keysRight: number[];
  91769. /**
  91770. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91771. */
  91772. wheelPrecision: number;
  91773. /**
  91774. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91775. * It will be used instead of pinchDeltaPrecision if different from 0.
  91776. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91777. */
  91778. wheelDeltaPercentage: number;
  91779. /**
  91780. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91781. */
  91782. zoomOnFactor: number;
  91783. /**
  91784. * Defines a screen offset for the camera position.
  91785. */
  91786. targetScreenOffset: Vector2;
  91787. /**
  91788. * Allows the camera to be completely reversed.
  91789. * If false the camera can not arrive upside down.
  91790. */
  91791. allowUpsideDown: boolean;
  91792. /**
  91793. * Define if double tap/click is used to restore the previously saved state of the camera.
  91794. */
  91795. useInputToRestoreState: boolean;
  91796. /** @hidden */
  91797. _viewMatrix: Matrix;
  91798. /** @hidden */
  91799. _useCtrlForPanning: boolean;
  91800. /** @hidden */
  91801. _panningMouseButton: number;
  91802. /**
  91803. * Defines the input associated to the camera.
  91804. */
  91805. inputs: ArcRotateCameraInputsManager;
  91806. /** @hidden */
  91807. _reset: () => void;
  91808. /**
  91809. * Defines the allowed panning axis.
  91810. */
  91811. panningAxis: Vector3;
  91812. protected _localDirection: Vector3;
  91813. protected _transformedDirection: Vector3;
  91814. private _bouncingBehavior;
  91815. /**
  91816. * Gets the bouncing behavior of the camera if it has been enabled.
  91817. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91818. */
  91819. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91820. /**
  91821. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91822. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91823. */
  91824. useBouncingBehavior: boolean;
  91825. private _framingBehavior;
  91826. /**
  91827. * Gets the framing behavior of the camera if it has been enabled.
  91828. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91829. */
  91830. readonly framingBehavior: Nullable<FramingBehavior>;
  91831. /**
  91832. * Defines if the framing behavior of the camera is enabled on the camera.
  91833. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91834. */
  91835. useFramingBehavior: boolean;
  91836. private _autoRotationBehavior;
  91837. /**
  91838. * Gets the auto rotation behavior of the camera if it has been enabled.
  91839. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91840. */
  91841. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91842. /**
  91843. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91845. */
  91846. useAutoRotationBehavior: boolean;
  91847. /**
  91848. * Observable triggered when the mesh target has been changed on the camera.
  91849. */
  91850. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91851. /**
  91852. * Event raised when the camera is colliding with a mesh.
  91853. */
  91854. onCollide: (collidedMesh: AbstractMesh) => void;
  91855. /**
  91856. * Defines whether the camera should check collision with the objects oh the scene.
  91857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91858. */
  91859. checkCollisions: boolean;
  91860. /**
  91861. * Defines the collision radius of the camera.
  91862. * This simulates a sphere around the camera.
  91863. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91864. */
  91865. collisionRadius: Vector3;
  91866. protected _collider: Collider;
  91867. protected _previousPosition: Vector3;
  91868. protected _collisionVelocity: Vector3;
  91869. protected _newPosition: Vector3;
  91870. protected _previousAlpha: number;
  91871. protected _previousBeta: number;
  91872. protected _previousRadius: number;
  91873. protected _collisionTriggered: boolean;
  91874. protected _targetBoundingCenter: Nullable<Vector3>;
  91875. private _computationVector;
  91876. private _tempAxisVector;
  91877. private _tempAxisRotationMatrix;
  91878. /**
  91879. * Instantiates a new ArcRotateCamera in a given scene
  91880. * @param name Defines the name of the camera
  91881. * @param alpha Defines the camera rotation along the logitudinal axis
  91882. * @param beta Defines the camera rotation along the latitudinal axis
  91883. * @param radius Defines the camera distance from its target
  91884. * @param target Defines the camera target
  91885. * @param scene Defines the scene the camera belongs to
  91886. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91887. */
  91888. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91889. /** @hidden */
  91890. _initCache(): void;
  91891. /** @hidden */
  91892. _updateCache(ignoreParentClass?: boolean): void;
  91893. protected _getTargetPosition(): Vector3;
  91894. private _storedAlpha;
  91895. private _storedBeta;
  91896. private _storedRadius;
  91897. private _storedTarget;
  91898. /**
  91899. * Stores the current state of the camera (alpha, beta, radius and target)
  91900. * @returns the camera itself
  91901. */
  91902. storeState(): Camera;
  91903. /**
  91904. * @hidden
  91905. * Restored camera state. You must call storeState() first
  91906. */
  91907. _restoreStateValues(): boolean;
  91908. /** @hidden */
  91909. _isSynchronizedViewMatrix(): boolean;
  91910. /**
  91911. * Attached controls to the current camera.
  91912. * @param element Defines the element the controls should be listened from
  91913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91914. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91915. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91916. */
  91917. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91918. /**
  91919. * Detach the current controls from the camera.
  91920. * The camera will stop reacting to inputs.
  91921. * @param element Defines the element to stop listening the inputs from
  91922. */
  91923. detachControl(element: HTMLElement): void;
  91924. /** @hidden */
  91925. _checkInputs(): void;
  91926. protected _checkLimits(): void;
  91927. /**
  91928. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91929. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91930. */
  91931. rebuildAnglesAndRadius(updateView?: boolean): void;
  91932. /**
  91933. * Use a position to define the current camera related information like aplha, beta and radius
  91934. * @param position Defines the position to set the camera at
  91935. */
  91936. setPosition(position: Vector3): void;
  91937. /**
  91938. * Defines the target the camera should look at.
  91939. * This will automatically adapt alpha beta and radius to fit within the new target.
  91940. * @param target Defines the new target as a Vector or a mesh
  91941. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91942. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91943. */
  91944. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91945. /** @hidden */
  91946. _getViewMatrix(): Matrix;
  91947. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91948. /**
  91949. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91950. * @param meshes Defines the mesh to zoom on
  91951. * @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)
  91952. */
  91953. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91954. /**
  91955. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91956. * The target will be changed but the radius
  91957. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91958. * @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)
  91959. */
  91960. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91961. min: Vector3;
  91962. max: Vector3;
  91963. distance: number;
  91964. }, doNotUpdateMaxZ?: boolean): void;
  91965. /**
  91966. * @override
  91967. * Override Camera.createRigCamera
  91968. */
  91969. createRigCamera(name: string, cameraIndex: number): Camera;
  91970. /**
  91971. * @hidden
  91972. * @override
  91973. * Override Camera._updateRigCameras
  91974. */
  91975. _updateRigCameras(): void;
  91976. /**
  91977. * Destroy the camera and release the current resources hold by it.
  91978. */
  91979. dispose(): void;
  91980. /**
  91981. * Gets the current object class name.
  91982. * @return the class name
  91983. */
  91984. getClassName(): string;
  91985. }
  91986. }
  91987. declare module BABYLON {
  91988. /**
  91989. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91990. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91991. */
  91992. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91993. /**
  91994. * Gets the name of the behavior.
  91995. */
  91996. readonly name: string;
  91997. private _zoomStopsAnimation;
  91998. private _idleRotationSpeed;
  91999. private _idleRotationWaitTime;
  92000. private _idleRotationSpinupTime;
  92001. /**
  92002. * Sets the flag that indicates if user zooming should stop animation.
  92003. */
  92004. /**
  92005. * Gets the flag that indicates if user zooming should stop animation.
  92006. */
  92007. zoomStopsAnimation: boolean;
  92008. /**
  92009. * Sets the default speed at which the camera rotates around the model.
  92010. */
  92011. /**
  92012. * Gets the default speed at which the camera rotates around the model.
  92013. */
  92014. idleRotationSpeed: number;
  92015. /**
  92016. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92017. */
  92018. /**
  92019. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92020. */
  92021. idleRotationWaitTime: number;
  92022. /**
  92023. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92024. */
  92025. /**
  92026. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92027. */
  92028. idleRotationSpinupTime: number;
  92029. /**
  92030. * Gets a value indicating if the camera is currently rotating because of this behavior
  92031. */
  92032. readonly rotationInProgress: boolean;
  92033. private _onPrePointerObservableObserver;
  92034. private _onAfterCheckInputsObserver;
  92035. private _attachedCamera;
  92036. private _isPointerDown;
  92037. private _lastFrameTime;
  92038. private _lastInteractionTime;
  92039. private _cameraRotationSpeed;
  92040. /**
  92041. * Initializes the behavior.
  92042. */
  92043. init(): void;
  92044. /**
  92045. * Attaches the behavior to its arc rotate camera.
  92046. * @param camera Defines the camera to attach the behavior to
  92047. */
  92048. attach(camera: ArcRotateCamera): void;
  92049. /**
  92050. * Detaches the behavior from its current arc rotate camera.
  92051. */
  92052. detach(): void;
  92053. /**
  92054. * Returns true if user is scrolling.
  92055. * @return true if user is scrolling.
  92056. */
  92057. private _userIsZooming;
  92058. private _lastFrameRadius;
  92059. private _shouldAnimationStopForInteraction;
  92060. /**
  92061. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92062. */
  92063. private _applyUserInteraction;
  92064. private _userIsMoving;
  92065. }
  92066. }
  92067. declare module BABYLON {
  92068. /**
  92069. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92070. */
  92071. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92072. private ui;
  92073. /**
  92074. * The name of the behavior
  92075. */
  92076. name: string;
  92077. /**
  92078. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92079. */
  92080. distanceAwayFromFace: number;
  92081. /**
  92082. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92083. */
  92084. distanceAwayFromBottomOfFace: number;
  92085. private _faceVectors;
  92086. private _target;
  92087. private _scene;
  92088. private _onRenderObserver;
  92089. private _tmpMatrix;
  92090. private _tmpVector;
  92091. /**
  92092. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92093. * @param ui The transform node that should be attched to the mesh
  92094. */
  92095. constructor(ui: TransformNode);
  92096. /**
  92097. * Initializes the behavior
  92098. */
  92099. init(): void;
  92100. private _closestFace;
  92101. private _zeroVector;
  92102. private _lookAtTmpMatrix;
  92103. private _lookAtToRef;
  92104. /**
  92105. * Attaches the AttachToBoxBehavior to the passed in mesh
  92106. * @param target The mesh that the specified node will be attached to
  92107. */
  92108. attach(target: Mesh): void;
  92109. /**
  92110. * Detaches the behavior from the mesh
  92111. */
  92112. detach(): void;
  92113. }
  92114. }
  92115. declare module BABYLON {
  92116. /**
  92117. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92118. */
  92119. export class FadeInOutBehavior implements Behavior<Mesh> {
  92120. /**
  92121. * Time in milliseconds to delay before fading in (Default: 0)
  92122. */
  92123. delay: number;
  92124. /**
  92125. * Time in milliseconds for the mesh to fade in (Default: 300)
  92126. */
  92127. fadeInTime: number;
  92128. private _millisecondsPerFrame;
  92129. private _hovered;
  92130. private _hoverValue;
  92131. private _ownerNode;
  92132. /**
  92133. * Instatiates the FadeInOutBehavior
  92134. */
  92135. constructor();
  92136. /**
  92137. * The name of the behavior
  92138. */
  92139. readonly name: string;
  92140. /**
  92141. * Initializes the behavior
  92142. */
  92143. init(): void;
  92144. /**
  92145. * Attaches the fade behavior on the passed in mesh
  92146. * @param ownerNode The mesh that will be faded in/out once attached
  92147. */
  92148. attach(ownerNode: Mesh): void;
  92149. /**
  92150. * Detaches the behavior from the mesh
  92151. */
  92152. detach(): void;
  92153. /**
  92154. * Triggers the mesh to begin fading in or out
  92155. * @param value if the object should fade in or out (true to fade in)
  92156. */
  92157. fadeIn(value: boolean): void;
  92158. private _update;
  92159. private _setAllVisibility;
  92160. }
  92161. }
  92162. declare module BABYLON {
  92163. /**
  92164. * Class containing a set of static utilities functions for managing Pivots
  92165. * @hidden
  92166. */
  92167. export class PivotTools {
  92168. private static _PivotCached;
  92169. private static _OldPivotPoint;
  92170. private static _PivotTranslation;
  92171. private static _PivotTmpVector;
  92172. /** @hidden */
  92173. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92174. /** @hidden */
  92175. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92176. }
  92177. }
  92178. declare module BABYLON {
  92179. /**
  92180. * Class containing static functions to help procedurally build meshes
  92181. */
  92182. export class PlaneBuilder {
  92183. /**
  92184. * Creates a plane mesh
  92185. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92186. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92187. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92191. * @param name defines the name of the mesh
  92192. * @param options defines the options used to create the mesh
  92193. * @param scene defines the hosting scene
  92194. * @returns the plane mesh
  92195. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92196. */
  92197. static CreatePlane(name: string, options: {
  92198. size?: number;
  92199. width?: number;
  92200. height?: number;
  92201. sideOrientation?: number;
  92202. frontUVs?: Vector4;
  92203. backUVs?: Vector4;
  92204. updatable?: boolean;
  92205. sourcePlane?: Plane;
  92206. }, scene: Scene): Mesh;
  92207. }
  92208. }
  92209. declare module BABYLON {
  92210. /**
  92211. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92212. */
  92213. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92214. private static _AnyMouseID;
  92215. private _attachedNode;
  92216. private _dragPlane;
  92217. private _scene;
  92218. private _pointerObserver;
  92219. private _beforeRenderObserver;
  92220. private static _planeScene;
  92221. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92222. /**
  92223. * 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)
  92224. */
  92225. maxDragAngle: number;
  92226. /**
  92227. * @hidden
  92228. */
  92229. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92230. /**
  92231. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92232. */
  92233. currentDraggingPointerID: number;
  92234. /**
  92235. * The last position where the pointer hit the drag plane in world space
  92236. */
  92237. lastDragPosition: Vector3;
  92238. /**
  92239. * If the behavior is currently in a dragging state
  92240. */
  92241. dragging: boolean;
  92242. /**
  92243. * 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)
  92244. */
  92245. dragDeltaRatio: number;
  92246. /**
  92247. * If the drag plane orientation should be updated during the dragging (Default: true)
  92248. */
  92249. updateDragPlane: boolean;
  92250. private _debugMode;
  92251. private _moving;
  92252. /**
  92253. * Fires each time the attached mesh is dragged with the pointer
  92254. * * delta between last drag position and current drag position in world space
  92255. * * dragDistance along the drag axis
  92256. * * dragPlaneNormal normal of the current drag plane used during the drag
  92257. * * dragPlanePoint in world space where the drag intersects the drag plane
  92258. */
  92259. onDragObservable: Observable<{
  92260. delta: Vector3;
  92261. dragPlanePoint: Vector3;
  92262. dragPlaneNormal: Vector3;
  92263. dragDistance: number;
  92264. pointerId: number;
  92265. }>;
  92266. /**
  92267. * Fires each time a drag begins (eg. mouse down on mesh)
  92268. */
  92269. onDragStartObservable: Observable<{
  92270. dragPlanePoint: Vector3;
  92271. pointerId: number;
  92272. }>;
  92273. /**
  92274. * Fires each time a drag ends (eg. mouse release after drag)
  92275. */
  92276. onDragEndObservable: Observable<{
  92277. dragPlanePoint: Vector3;
  92278. pointerId: number;
  92279. }>;
  92280. /**
  92281. * If the attached mesh should be moved when dragged
  92282. */
  92283. moveAttached: boolean;
  92284. /**
  92285. * If the drag behavior will react to drag events (Default: true)
  92286. */
  92287. enabled: boolean;
  92288. /**
  92289. * If camera controls should be detached during the drag
  92290. */
  92291. detachCameraControls: boolean;
  92292. /**
  92293. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92294. */
  92295. useObjectOrienationForDragging: boolean;
  92296. private _options;
  92297. /**
  92298. * Creates a pointer drag behavior that can be attached to a mesh
  92299. * @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)
  92300. */
  92301. constructor(options?: {
  92302. dragAxis?: Vector3;
  92303. dragPlaneNormal?: Vector3;
  92304. });
  92305. /**
  92306. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92307. */
  92308. validateDrag: (targetPosition: Vector3) => boolean;
  92309. /**
  92310. * The name of the behavior
  92311. */
  92312. readonly name: string;
  92313. /**
  92314. * Initializes the behavior
  92315. */
  92316. init(): void;
  92317. private _tmpVector;
  92318. private _alternatePickedPoint;
  92319. private _worldDragAxis;
  92320. private _targetPosition;
  92321. private _attachedElement;
  92322. /**
  92323. * Attaches the drag behavior the passed in mesh
  92324. * @param ownerNode The mesh that will be dragged around once attached
  92325. */
  92326. attach(ownerNode: AbstractMesh): void;
  92327. /**
  92328. * Force relase the drag action by code.
  92329. */
  92330. releaseDrag(): void;
  92331. private _startDragRay;
  92332. private _lastPointerRay;
  92333. /**
  92334. * Simulates the start of a pointer drag event on the behavior
  92335. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92336. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92337. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92338. */
  92339. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92340. private _startDrag;
  92341. private _dragDelta;
  92342. private _moveDrag;
  92343. private _pickWithRayOnDragPlane;
  92344. private _pointA;
  92345. private _pointB;
  92346. private _pointC;
  92347. private _lineA;
  92348. private _lineB;
  92349. private _localAxis;
  92350. private _lookAt;
  92351. private _updateDragPlanePosition;
  92352. /**
  92353. * Detaches the behavior from the mesh
  92354. */
  92355. detach(): void;
  92356. }
  92357. }
  92358. declare module BABYLON {
  92359. /**
  92360. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92361. */
  92362. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92363. private _dragBehaviorA;
  92364. private _dragBehaviorB;
  92365. private _startDistance;
  92366. private _initialScale;
  92367. private _targetScale;
  92368. private _ownerNode;
  92369. private _sceneRenderObserver;
  92370. /**
  92371. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92372. */
  92373. constructor();
  92374. /**
  92375. * The name of the behavior
  92376. */
  92377. readonly name: string;
  92378. /**
  92379. * Initializes the behavior
  92380. */
  92381. init(): void;
  92382. private _getCurrentDistance;
  92383. /**
  92384. * Attaches the scale behavior the passed in mesh
  92385. * @param ownerNode The mesh that will be scaled around once attached
  92386. */
  92387. attach(ownerNode: Mesh): void;
  92388. /**
  92389. * Detaches the behavior from the mesh
  92390. */
  92391. detach(): void;
  92392. }
  92393. }
  92394. declare module BABYLON {
  92395. /**
  92396. * 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
  92397. */
  92398. export class SixDofDragBehavior implements Behavior<Mesh> {
  92399. private static _virtualScene;
  92400. private _ownerNode;
  92401. private _sceneRenderObserver;
  92402. private _scene;
  92403. private _targetPosition;
  92404. private _virtualOriginMesh;
  92405. private _virtualDragMesh;
  92406. private _pointerObserver;
  92407. private _moving;
  92408. private _startingOrientation;
  92409. /**
  92410. * 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)
  92411. */
  92412. private zDragFactor;
  92413. /**
  92414. * If the object should rotate to face the drag origin
  92415. */
  92416. rotateDraggedObject: boolean;
  92417. /**
  92418. * If the behavior is currently in a dragging state
  92419. */
  92420. dragging: boolean;
  92421. /**
  92422. * 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)
  92423. */
  92424. dragDeltaRatio: number;
  92425. /**
  92426. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92427. */
  92428. currentDraggingPointerID: number;
  92429. /**
  92430. * If camera controls should be detached during the drag
  92431. */
  92432. detachCameraControls: boolean;
  92433. /**
  92434. * Fires each time a drag starts
  92435. */
  92436. onDragStartObservable: Observable<{}>;
  92437. /**
  92438. * Fires each time a drag ends (eg. mouse release after drag)
  92439. */
  92440. onDragEndObservable: Observable<{}>;
  92441. /**
  92442. * 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
  92443. */
  92444. constructor();
  92445. /**
  92446. * The name of the behavior
  92447. */
  92448. readonly name: string;
  92449. /**
  92450. * Initializes the behavior
  92451. */
  92452. init(): void;
  92453. /**
  92454. * Attaches the scale behavior the passed in mesh
  92455. * @param ownerNode The mesh that will be scaled around once attached
  92456. */
  92457. attach(ownerNode: Mesh): void;
  92458. /**
  92459. * Detaches the behavior from the mesh
  92460. */
  92461. detach(): void;
  92462. }
  92463. }
  92464. declare module BABYLON {
  92465. /**
  92466. * Class used to apply inverse kinematics to bones
  92467. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92468. */
  92469. export class BoneIKController {
  92470. private static _tmpVecs;
  92471. private static _tmpQuat;
  92472. private static _tmpMats;
  92473. /**
  92474. * Gets or sets the target mesh
  92475. */
  92476. targetMesh: AbstractMesh;
  92477. /** Gets or sets the mesh used as pole */
  92478. poleTargetMesh: AbstractMesh;
  92479. /**
  92480. * Gets or sets the bone used as pole
  92481. */
  92482. poleTargetBone: Nullable<Bone>;
  92483. /**
  92484. * Gets or sets the target position
  92485. */
  92486. targetPosition: Vector3;
  92487. /**
  92488. * Gets or sets the pole target position
  92489. */
  92490. poleTargetPosition: Vector3;
  92491. /**
  92492. * Gets or sets the pole target local offset
  92493. */
  92494. poleTargetLocalOffset: Vector3;
  92495. /**
  92496. * Gets or sets the pole angle
  92497. */
  92498. poleAngle: number;
  92499. /**
  92500. * Gets or sets the mesh associated with the controller
  92501. */
  92502. mesh: AbstractMesh;
  92503. /**
  92504. * 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)
  92505. */
  92506. slerpAmount: number;
  92507. private _bone1Quat;
  92508. private _bone1Mat;
  92509. private _bone2Ang;
  92510. private _bone1;
  92511. private _bone2;
  92512. private _bone1Length;
  92513. private _bone2Length;
  92514. private _maxAngle;
  92515. private _maxReach;
  92516. private _rightHandedSystem;
  92517. private _bendAxis;
  92518. private _slerping;
  92519. private _adjustRoll;
  92520. /**
  92521. * Gets or sets maximum allowed angle
  92522. */
  92523. maxAngle: number;
  92524. /**
  92525. * Creates a new BoneIKController
  92526. * @param mesh defines the mesh to control
  92527. * @param bone defines the bone to control
  92528. * @param options defines options to set up the controller
  92529. */
  92530. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92531. targetMesh?: AbstractMesh;
  92532. poleTargetMesh?: AbstractMesh;
  92533. poleTargetBone?: Bone;
  92534. poleTargetLocalOffset?: Vector3;
  92535. poleAngle?: number;
  92536. bendAxis?: Vector3;
  92537. maxAngle?: number;
  92538. slerpAmount?: number;
  92539. });
  92540. private _setMaxAngle;
  92541. /**
  92542. * Force the controller to update the bones
  92543. */
  92544. update(): void;
  92545. }
  92546. }
  92547. declare module BABYLON {
  92548. /**
  92549. * Class used to make a bone look toward a point in space
  92550. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92551. */
  92552. export class BoneLookController {
  92553. private static _tmpVecs;
  92554. private static _tmpQuat;
  92555. private static _tmpMats;
  92556. /**
  92557. * The target Vector3 that the bone will look at
  92558. */
  92559. target: Vector3;
  92560. /**
  92561. * The mesh that the bone is attached to
  92562. */
  92563. mesh: AbstractMesh;
  92564. /**
  92565. * The bone that will be looking to the target
  92566. */
  92567. bone: Bone;
  92568. /**
  92569. * The up axis of the coordinate system that is used when the bone is rotated
  92570. */
  92571. upAxis: Vector3;
  92572. /**
  92573. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92574. */
  92575. upAxisSpace: Space;
  92576. /**
  92577. * Used to make an adjustment to the yaw of the bone
  92578. */
  92579. adjustYaw: number;
  92580. /**
  92581. * Used to make an adjustment to the pitch of the bone
  92582. */
  92583. adjustPitch: number;
  92584. /**
  92585. * Used to make an adjustment to the roll of the bone
  92586. */
  92587. adjustRoll: number;
  92588. /**
  92589. * 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)
  92590. */
  92591. slerpAmount: number;
  92592. private _minYaw;
  92593. private _maxYaw;
  92594. private _minPitch;
  92595. private _maxPitch;
  92596. private _minYawSin;
  92597. private _minYawCos;
  92598. private _maxYawSin;
  92599. private _maxYawCos;
  92600. private _midYawConstraint;
  92601. private _minPitchTan;
  92602. private _maxPitchTan;
  92603. private _boneQuat;
  92604. private _slerping;
  92605. private _transformYawPitch;
  92606. private _transformYawPitchInv;
  92607. private _firstFrameSkipped;
  92608. private _yawRange;
  92609. private _fowardAxis;
  92610. /**
  92611. * Gets or sets the minimum yaw angle that the bone can look to
  92612. */
  92613. minYaw: number;
  92614. /**
  92615. * Gets or sets the maximum yaw angle that the bone can look to
  92616. */
  92617. maxYaw: number;
  92618. /**
  92619. * Gets or sets the minimum pitch angle that the bone can look to
  92620. */
  92621. minPitch: number;
  92622. /**
  92623. * Gets or sets the maximum pitch angle that the bone can look to
  92624. */
  92625. maxPitch: number;
  92626. /**
  92627. * Create a BoneLookController
  92628. * @param mesh the mesh that the bone belongs to
  92629. * @param bone the bone that will be looking to the target
  92630. * @param target the target Vector3 to look at
  92631. * @param options optional settings:
  92632. * * maxYaw: the maximum angle the bone will yaw to
  92633. * * minYaw: the minimum angle the bone will yaw to
  92634. * * maxPitch: the maximum angle the bone will pitch to
  92635. * * minPitch: the minimum angle the bone will yaw to
  92636. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92637. * * upAxis: the up axis of the coordinate system
  92638. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92639. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92640. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92641. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92642. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92643. * * adjustRoll: used to make an adjustment to the roll of the bone
  92644. **/
  92645. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92646. maxYaw?: number;
  92647. minYaw?: number;
  92648. maxPitch?: number;
  92649. minPitch?: number;
  92650. slerpAmount?: number;
  92651. upAxis?: Vector3;
  92652. upAxisSpace?: Space;
  92653. yawAxis?: Vector3;
  92654. pitchAxis?: Vector3;
  92655. adjustYaw?: number;
  92656. adjustPitch?: number;
  92657. adjustRoll?: number;
  92658. });
  92659. /**
  92660. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92661. */
  92662. update(): void;
  92663. private _getAngleDiff;
  92664. private _getAngleBetween;
  92665. private _isAngleBetween;
  92666. }
  92667. }
  92668. declare module BABYLON {
  92669. /**
  92670. * Manage the gamepad inputs to control an arc rotate camera.
  92671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92672. */
  92673. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92674. /**
  92675. * Defines the camera the input is attached to.
  92676. */
  92677. camera: ArcRotateCamera;
  92678. /**
  92679. * Defines the gamepad the input is gathering event from.
  92680. */
  92681. gamepad: Nullable<Gamepad>;
  92682. /**
  92683. * Defines the gamepad rotation sensiblity.
  92684. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92685. */
  92686. gamepadRotationSensibility: number;
  92687. /**
  92688. * Defines the gamepad move sensiblity.
  92689. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92690. */
  92691. gamepadMoveSensibility: number;
  92692. private _onGamepadConnectedObserver;
  92693. private _onGamepadDisconnectedObserver;
  92694. /**
  92695. * Attach the input controls to a specific dom element to get the input from.
  92696. * @param element Defines the element the controls should be listened from
  92697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92698. */
  92699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92700. /**
  92701. * Detach the current controls from the specified dom element.
  92702. * @param element Defines the element to stop listening the inputs from
  92703. */
  92704. detachControl(element: Nullable<HTMLElement>): void;
  92705. /**
  92706. * Update the current camera state depending on the inputs that have been used this frame.
  92707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92708. */
  92709. checkInputs(): void;
  92710. /**
  92711. * Gets the class name of the current intput.
  92712. * @returns the class name
  92713. */
  92714. getClassName(): string;
  92715. /**
  92716. * Get the friendly name associated with the input class.
  92717. * @returns the input friendly name
  92718. */
  92719. getSimpleName(): string;
  92720. }
  92721. }
  92722. declare module BABYLON {
  92723. interface ArcRotateCameraInputsManager {
  92724. /**
  92725. * Add orientation input support to the input manager.
  92726. * @returns the current input manager
  92727. */
  92728. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92729. }
  92730. /**
  92731. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92733. */
  92734. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92735. /**
  92736. * Defines the camera the input is attached to.
  92737. */
  92738. camera: ArcRotateCamera;
  92739. /**
  92740. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92741. */
  92742. alphaCorrection: number;
  92743. /**
  92744. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92745. */
  92746. gammaCorrection: number;
  92747. private _alpha;
  92748. private _gamma;
  92749. private _dirty;
  92750. private _deviceOrientationHandler;
  92751. /**
  92752. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92753. */
  92754. constructor();
  92755. /**
  92756. * Attach the input controls to a specific dom element to get the input from.
  92757. * @param element Defines the element the controls should be listened from
  92758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92759. */
  92760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92761. /** @hidden */
  92762. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92763. /**
  92764. * Update the current camera state depending on the inputs that have been used this frame.
  92765. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92766. */
  92767. checkInputs(): void;
  92768. /**
  92769. * Detach the current controls from the specified dom element.
  92770. * @param element Defines the element to stop listening the inputs from
  92771. */
  92772. detachControl(element: Nullable<HTMLElement>): void;
  92773. /**
  92774. * Gets the class name of the current intput.
  92775. * @returns the class name
  92776. */
  92777. getClassName(): string;
  92778. /**
  92779. * Get the friendly name associated with the input class.
  92780. * @returns the input friendly name
  92781. */
  92782. getSimpleName(): string;
  92783. }
  92784. }
  92785. declare module BABYLON {
  92786. /**
  92787. * Listen to mouse events to control the camera.
  92788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92789. */
  92790. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92791. /**
  92792. * Defines the camera the input is attached to.
  92793. */
  92794. camera: FlyCamera;
  92795. /**
  92796. * Defines if touch is enabled. (Default is true.)
  92797. */
  92798. touchEnabled: boolean;
  92799. /**
  92800. * Defines the buttons associated with the input to handle camera rotation.
  92801. */
  92802. buttons: number[];
  92803. /**
  92804. * Assign buttons for Yaw control.
  92805. */
  92806. buttonsYaw: number[];
  92807. /**
  92808. * Assign buttons for Pitch control.
  92809. */
  92810. buttonsPitch: number[];
  92811. /**
  92812. * Assign buttons for Roll control.
  92813. */
  92814. buttonsRoll: number[];
  92815. /**
  92816. * Detect if any button is being pressed while mouse is moved.
  92817. * -1 = Mouse locked.
  92818. * 0 = Left button.
  92819. * 1 = Middle Button.
  92820. * 2 = Right Button.
  92821. */
  92822. activeButton: number;
  92823. /**
  92824. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92825. * Higher values reduce its sensitivity.
  92826. */
  92827. angularSensibility: number;
  92828. private _mousemoveCallback;
  92829. private _observer;
  92830. private _rollObserver;
  92831. private previousPosition;
  92832. private noPreventDefault;
  92833. private element;
  92834. /**
  92835. * Listen to mouse events to control the camera.
  92836. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92838. */
  92839. constructor(touchEnabled?: boolean);
  92840. /**
  92841. * Attach the mouse control to the HTML DOM element.
  92842. * @param element Defines the element that listens to the input events.
  92843. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92844. */
  92845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92846. /**
  92847. * Detach the current controls from the specified dom element.
  92848. * @param element Defines the element to stop listening the inputs from
  92849. */
  92850. detachControl(element: Nullable<HTMLElement>): void;
  92851. /**
  92852. * Gets the class name of the current input.
  92853. * @returns the class name.
  92854. */
  92855. getClassName(): string;
  92856. /**
  92857. * Get the friendly name associated with the input class.
  92858. * @returns the input's friendly name.
  92859. */
  92860. getSimpleName(): string;
  92861. private _pointerInput;
  92862. private _onMouseMove;
  92863. /**
  92864. * Rotate camera by mouse offset.
  92865. */
  92866. private rotateCamera;
  92867. }
  92868. }
  92869. declare module BABYLON {
  92870. /**
  92871. * Default Inputs manager for the FlyCamera.
  92872. * It groups all the default supported inputs for ease of use.
  92873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92874. */
  92875. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92876. /**
  92877. * Instantiates a new FlyCameraInputsManager.
  92878. * @param camera Defines the camera the inputs belong to.
  92879. */
  92880. constructor(camera: FlyCamera);
  92881. /**
  92882. * Add keyboard input support to the input manager.
  92883. * @returns the new FlyCameraKeyboardMoveInput().
  92884. */
  92885. addKeyboard(): FlyCameraInputsManager;
  92886. /**
  92887. * Add mouse input support to the input manager.
  92888. * @param touchEnabled Enable touch screen support.
  92889. * @returns the new FlyCameraMouseInput().
  92890. */
  92891. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92892. }
  92893. }
  92894. declare module BABYLON {
  92895. /**
  92896. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92897. * such as in a 3D Space Shooter or a Flight Simulator.
  92898. */
  92899. export class FlyCamera extends TargetCamera {
  92900. /**
  92901. * Define the collision ellipsoid of the camera.
  92902. * This is helpful for simulating a camera body, like a player's body.
  92903. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92904. */
  92905. ellipsoid: Vector3;
  92906. /**
  92907. * Define an offset for the position of the ellipsoid around the camera.
  92908. * This can be helpful if the camera is attached away from the player's body center,
  92909. * such as at its head.
  92910. */
  92911. ellipsoidOffset: Vector3;
  92912. /**
  92913. * Enable or disable collisions of the camera with the rest of the scene objects.
  92914. */
  92915. checkCollisions: boolean;
  92916. /**
  92917. * Enable or disable gravity on the camera.
  92918. */
  92919. applyGravity: boolean;
  92920. /**
  92921. * Define the current direction the camera is moving to.
  92922. */
  92923. cameraDirection: Vector3;
  92924. /**
  92925. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92926. * This overrides and empties cameraRotation.
  92927. */
  92928. rotationQuaternion: Quaternion;
  92929. /**
  92930. * Track Roll to maintain the wanted Rolling when looking around.
  92931. */
  92932. _trackRoll: number;
  92933. /**
  92934. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92935. */
  92936. rollCorrect: number;
  92937. /**
  92938. * Mimic a banked turn, Rolling the camera when Yawing.
  92939. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92940. */
  92941. bankedTurn: boolean;
  92942. /**
  92943. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92944. */
  92945. bankedTurnLimit: number;
  92946. /**
  92947. * Value of 0 disables the banked Roll.
  92948. * Value of 1 is equal to the Yaw angle in radians.
  92949. */
  92950. bankedTurnMultiplier: number;
  92951. /**
  92952. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92953. */
  92954. inputs: FlyCameraInputsManager;
  92955. /**
  92956. * Gets the input sensibility for mouse input.
  92957. * Higher values reduce sensitivity.
  92958. */
  92959. /**
  92960. * Sets the input sensibility for a mouse input.
  92961. * Higher values reduce sensitivity.
  92962. */
  92963. angularSensibility: number;
  92964. /**
  92965. * Get the keys for camera movement forward.
  92966. */
  92967. /**
  92968. * Set the keys for camera movement forward.
  92969. */
  92970. keysForward: number[];
  92971. /**
  92972. * Get the keys for camera movement backward.
  92973. */
  92974. keysBackward: number[];
  92975. /**
  92976. * Get the keys for camera movement up.
  92977. */
  92978. /**
  92979. * Set the keys for camera movement up.
  92980. */
  92981. keysUp: number[];
  92982. /**
  92983. * Get the keys for camera movement down.
  92984. */
  92985. /**
  92986. * Set the keys for camera movement down.
  92987. */
  92988. keysDown: number[];
  92989. /**
  92990. * Get the keys for camera movement left.
  92991. */
  92992. /**
  92993. * Set the keys for camera movement left.
  92994. */
  92995. keysLeft: number[];
  92996. /**
  92997. * Set the keys for camera movement right.
  92998. */
  92999. /**
  93000. * Set the keys for camera movement right.
  93001. */
  93002. keysRight: number[];
  93003. /**
  93004. * Event raised when the camera collides with a mesh in the scene.
  93005. */
  93006. onCollide: (collidedMesh: AbstractMesh) => void;
  93007. private _collider;
  93008. private _needMoveForGravity;
  93009. private _oldPosition;
  93010. private _diffPosition;
  93011. private _newPosition;
  93012. /** @hidden */
  93013. _localDirection: Vector3;
  93014. /** @hidden */
  93015. _transformedDirection: Vector3;
  93016. /**
  93017. * Instantiates a FlyCamera.
  93018. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93019. * such as in a 3D Space Shooter or a Flight Simulator.
  93020. * @param name Define the name of the camera in the scene.
  93021. * @param position Define the starting position of the camera in the scene.
  93022. * @param scene Define the scene the camera belongs to.
  93023. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93024. */
  93025. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93026. /**
  93027. * Attach a control to the HTML DOM element.
  93028. * @param element Defines the element that listens to the input events.
  93029. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93030. */
  93031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93032. /**
  93033. * Detach a control from the HTML DOM element.
  93034. * The camera will stop reacting to that input.
  93035. * @param element Defines the element that listens to the input events.
  93036. */
  93037. detachControl(element: HTMLElement): void;
  93038. private _collisionMask;
  93039. /**
  93040. * Get the mask that the camera ignores in collision events.
  93041. */
  93042. /**
  93043. * Set the mask that the camera ignores in collision events.
  93044. */
  93045. collisionMask: number;
  93046. /** @hidden */
  93047. _collideWithWorld(displacement: Vector3): void;
  93048. /** @hidden */
  93049. private _onCollisionPositionChange;
  93050. /** @hidden */
  93051. _checkInputs(): void;
  93052. /** @hidden */
  93053. _decideIfNeedsToMove(): boolean;
  93054. /** @hidden */
  93055. _updatePosition(): void;
  93056. /**
  93057. * Restore the Roll to its target value at the rate specified.
  93058. * @param rate - Higher means slower restoring.
  93059. * @hidden
  93060. */
  93061. restoreRoll(rate: number): void;
  93062. /**
  93063. * Destroy the camera and release the current resources held by it.
  93064. */
  93065. dispose(): void;
  93066. /**
  93067. * Get the current object class name.
  93068. * @returns the class name.
  93069. */
  93070. getClassName(): string;
  93071. }
  93072. }
  93073. declare module BABYLON {
  93074. /**
  93075. * Listen to keyboard events to control the camera.
  93076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93077. */
  93078. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93079. /**
  93080. * Defines the camera the input is attached to.
  93081. */
  93082. camera: FlyCamera;
  93083. /**
  93084. * The list of keyboard keys used to control the forward move of the camera.
  93085. */
  93086. keysForward: number[];
  93087. /**
  93088. * The list of keyboard keys used to control the backward move of the camera.
  93089. */
  93090. keysBackward: number[];
  93091. /**
  93092. * The list of keyboard keys used to control the forward move of the camera.
  93093. */
  93094. keysUp: number[];
  93095. /**
  93096. * The list of keyboard keys used to control the backward move of the camera.
  93097. */
  93098. keysDown: number[];
  93099. /**
  93100. * The list of keyboard keys used to control the right strafe move of the camera.
  93101. */
  93102. keysRight: number[];
  93103. /**
  93104. * The list of keyboard keys used to control the left strafe move of the camera.
  93105. */
  93106. keysLeft: number[];
  93107. private _keys;
  93108. private _onCanvasBlurObserver;
  93109. private _onKeyboardObserver;
  93110. private _engine;
  93111. private _scene;
  93112. /**
  93113. * Attach the input controls to a specific dom element to get the input from.
  93114. * @param element Defines the element the controls should be listened from
  93115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93116. */
  93117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93118. /**
  93119. * Detach the current controls from the specified dom element.
  93120. * @param element Defines the element to stop listening the inputs from
  93121. */
  93122. detachControl(element: Nullable<HTMLElement>): void;
  93123. /**
  93124. * Gets the class name of the current intput.
  93125. * @returns the class name
  93126. */
  93127. getClassName(): string;
  93128. /** @hidden */
  93129. _onLostFocus(e: FocusEvent): void;
  93130. /**
  93131. * Get the friendly name associated with the input class.
  93132. * @returns the input friendly name
  93133. */
  93134. getSimpleName(): string;
  93135. /**
  93136. * Update the current camera state depending on the inputs that have been used this frame.
  93137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93138. */
  93139. checkInputs(): void;
  93140. }
  93141. }
  93142. declare module BABYLON {
  93143. /**
  93144. * Manage the mouse wheel inputs to control a follow camera.
  93145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93146. */
  93147. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93148. /**
  93149. * Defines the camera the input is attached to.
  93150. */
  93151. camera: FollowCamera;
  93152. /**
  93153. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93154. */
  93155. axisControlRadius: boolean;
  93156. /**
  93157. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93158. */
  93159. axisControlHeight: boolean;
  93160. /**
  93161. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93162. */
  93163. axisControlRotation: boolean;
  93164. /**
  93165. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93166. * relation to mouseWheel events.
  93167. */
  93168. wheelPrecision: number;
  93169. /**
  93170. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93171. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93172. */
  93173. wheelDeltaPercentage: number;
  93174. private _wheel;
  93175. private _observer;
  93176. /**
  93177. * Attach the input controls to a specific dom element to get the input from.
  93178. * @param element Defines the element the controls should be listened from
  93179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93180. */
  93181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93182. /**
  93183. * Detach the current controls from the specified dom element.
  93184. * @param element Defines the element to stop listening the inputs from
  93185. */
  93186. detachControl(element: Nullable<HTMLElement>): void;
  93187. /**
  93188. * Gets the class name of the current intput.
  93189. * @returns the class name
  93190. */
  93191. getClassName(): string;
  93192. /**
  93193. * Get the friendly name associated with the input class.
  93194. * @returns the input friendly name
  93195. */
  93196. getSimpleName(): string;
  93197. }
  93198. }
  93199. declare module BABYLON {
  93200. /**
  93201. * Manage the pointers inputs to control an follow camera.
  93202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93203. */
  93204. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93205. /**
  93206. * Defines the camera the input is attached to.
  93207. */
  93208. camera: FollowCamera;
  93209. /**
  93210. * Gets the class name of the current input.
  93211. * @returns the class name
  93212. */
  93213. getClassName(): string;
  93214. /**
  93215. * Defines the pointer angular sensibility along the X axis or how fast is
  93216. * the camera rotating.
  93217. * A negative number will reverse the axis direction.
  93218. */
  93219. angularSensibilityX: number;
  93220. /**
  93221. * Defines the pointer angular sensibility along the Y axis or how fast is
  93222. * the camera rotating.
  93223. * A negative number will reverse the axis direction.
  93224. */
  93225. angularSensibilityY: number;
  93226. /**
  93227. * Defines the pointer pinch precision or how fast is the camera zooming.
  93228. * A negative number will reverse the axis direction.
  93229. */
  93230. pinchPrecision: number;
  93231. /**
  93232. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93233. * from 0.
  93234. * It defines the percentage of current camera.radius to use as delta when
  93235. * pinch zoom is used.
  93236. */
  93237. pinchDeltaPercentage: number;
  93238. /**
  93239. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93240. */
  93241. axisXControlRadius: boolean;
  93242. /**
  93243. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93244. */
  93245. axisXControlHeight: boolean;
  93246. /**
  93247. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93248. */
  93249. axisXControlRotation: boolean;
  93250. /**
  93251. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93252. */
  93253. axisYControlRadius: boolean;
  93254. /**
  93255. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93256. */
  93257. axisYControlHeight: boolean;
  93258. /**
  93259. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93260. */
  93261. axisYControlRotation: boolean;
  93262. /**
  93263. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93264. */
  93265. axisPinchControlRadius: boolean;
  93266. /**
  93267. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93268. */
  93269. axisPinchControlHeight: boolean;
  93270. /**
  93271. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93272. */
  93273. axisPinchControlRotation: boolean;
  93274. /**
  93275. * Log error messages if basic misconfiguration has occurred.
  93276. */
  93277. warningEnable: boolean;
  93278. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93279. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93280. private _warningCounter;
  93281. private _warning;
  93282. }
  93283. }
  93284. declare module BABYLON {
  93285. /**
  93286. * Default Inputs manager for the FollowCamera.
  93287. * It groups all the default supported inputs for ease of use.
  93288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93289. */
  93290. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93291. /**
  93292. * Instantiates a new FollowCameraInputsManager.
  93293. * @param camera Defines the camera the inputs belong to
  93294. */
  93295. constructor(camera: FollowCamera);
  93296. /**
  93297. * Add keyboard input support to the input manager.
  93298. * @returns the current input manager
  93299. */
  93300. addKeyboard(): FollowCameraInputsManager;
  93301. /**
  93302. * Add mouse wheel input support to the input manager.
  93303. * @returns the current input manager
  93304. */
  93305. addMouseWheel(): FollowCameraInputsManager;
  93306. /**
  93307. * Add pointers input support to the input manager.
  93308. * @returns the current input manager
  93309. */
  93310. addPointers(): FollowCameraInputsManager;
  93311. /**
  93312. * Add orientation input support to the input manager.
  93313. * @returns the current input manager
  93314. */
  93315. addVRDeviceOrientation(): FollowCameraInputsManager;
  93316. }
  93317. }
  93318. declare module BABYLON {
  93319. /**
  93320. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93321. * an arc rotate version arcFollowCamera are available.
  93322. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93323. */
  93324. export class FollowCamera extends TargetCamera {
  93325. /**
  93326. * Distance the follow camera should follow an object at
  93327. */
  93328. radius: number;
  93329. /**
  93330. * Minimum allowed distance of the camera to the axis of rotation
  93331. * (The camera can not get closer).
  93332. * This can help limiting how the Camera is able to move in the scene.
  93333. */
  93334. lowerRadiusLimit: Nullable<number>;
  93335. /**
  93336. * Maximum allowed distance of the camera to the axis of rotation
  93337. * (The camera can not get further).
  93338. * This can help limiting how the Camera is able to move in the scene.
  93339. */
  93340. upperRadiusLimit: Nullable<number>;
  93341. /**
  93342. * Define a rotation offset between the camera and the object it follows
  93343. */
  93344. rotationOffset: number;
  93345. /**
  93346. * Minimum allowed angle to camera position relative to target object.
  93347. * This can help limiting how the Camera is able to move in the scene.
  93348. */
  93349. lowerRotationOffsetLimit: Nullable<number>;
  93350. /**
  93351. * Maximum allowed angle to camera position relative to target object.
  93352. * This can help limiting how the Camera is able to move in the scene.
  93353. */
  93354. upperRotationOffsetLimit: Nullable<number>;
  93355. /**
  93356. * Define a height offset between the camera and the object it follows.
  93357. * It can help following an object from the top (like a car chaing a plane)
  93358. */
  93359. heightOffset: number;
  93360. /**
  93361. * Minimum allowed height of camera position relative to target object.
  93362. * This can help limiting how the Camera is able to move in the scene.
  93363. */
  93364. lowerHeightOffsetLimit: Nullable<number>;
  93365. /**
  93366. * Maximum allowed height of camera position relative to target object.
  93367. * This can help limiting how the Camera is able to move in the scene.
  93368. */
  93369. upperHeightOffsetLimit: Nullable<number>;
  93370. /**
  93371. * Define how fast the camera can accelerate to follow it s target.
  93372. */
  93373. cameraAcceleration: number;
  93374. /**
  93375. * Define the speed limit of the camera following an object.
  93376. */
  93377. maxCameraSpeed: number;
  93378. /**
  93379. * Define the target of the camera.
  93380. */
  93381. lockedTarget: Nullable<AbstractMesh>;
  93382. /**
  93383. * Defines the input associated with the camera.
  93384. */
  93385. inputs: FollowCameraInputsManager;
  93386. /**
  93387. * Instantiates the follow camera.
  93388. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93389. * @param name Define the name of the camera in the scene
  93390. * @param position Define the position of the camera
  93391. * @param scene Define the scene the camera belong to
  93392. * @param lockedTarget Define the target of the camera
  93393. */
  93394. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93395. private _follow;
  93396. /**
  93397. * Attached controls to the current camera.
  93398. * @param element Defines the element the controls should be listened from
  93399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93400. */
  93401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93402. /**
  93403. * Detach the current controls from the camera.
  93404. * The camera will stop reacting to inputs.
  93405. * @param element Defines the element to stop listening the inputs from
  93406. */
  93407. detachControl(element: HTMLElement): void;
  93408. /** @hidden */
  93409. _checkInputs(): void;
  93410. private _checkLimits;
  93411. /**
  93412. * Gets the camera class name.
  93413. * @returns the class name
  93414. */
  93415. getClassName(): string;
  93416. }
  93417. /**
  93418. * Arc Rotate version of the follow camera.
  93419. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93420. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93421. */
  93422. export class ArcFollowCamera extends TargetCamera {
  93423. /** The longitudinal angle of the camera */
  93424. alpha: number;
  93425. /** The latitudinal angle of the camera */
  93426. beta: number;
  93427. /** The radius of the camera from its target */
  93428. radius: number;
  93429. /** Define the camera target (the messh it should follow) */
  93430. target: Nullable<AbstractMesh>;
  93431. private _cartesianCoordinates;
  93432. /**
  93433. * Instantiates a new ArcFollowCamera
  93434. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93435. * @param name Define the name of the camera
  93436. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93437. * @param beta Define the rotation angle of the camera around the elevation axis
  93438. * @param radius Define the radius of the camera from its target point
  93439. * @param target Define the target of the camera
  93440. * @param scene Define the scene the camera belongs to
  93441. */
  93442. constructor(name: string,
  93443. /** The longitudinal angle of the camera */
  93444. alpha: number,
  93445. /** The latitudinal angle of the camera */
  93446. beta: number,
  93447. /** The radius of the camera from its target */
  93448. radius: number,
  93449. /** Define the camera target (the messh it should follow) */
  93450. target: Nullable<AbstractMesh>, scene: Scene);
  93451. private _follow;
  93452. /** @hidden */
  93453. _checkInputs(): void;
  93454. /**
  93455. * Returns the class name of the object.
  93456. * It is mostly used internally for serialization purposes.
  93457. */
  93458. getClassName(): string;
  93459. }
  93460. }
  93461. declare module BABYLON {
  93462. /**
  93463. * Manage the keyboard inputs to control the movement of a follow camera.
  93464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93465. */
  93466. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93467. /**
  93468. * Defines the camera the input is attached to.
  93469. */
  93470. camera: FollowCamera;
  93471. /**
  93472. * Defines the list of key codes associated with the up action (increase heightOffset)
  93473. */
  93474. keysHeightOffsetIncr: number[];
  93475. /**
  93476. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93477. */
  93478. keysHeightOffsetDecr: number[];
  93479. /**
  93480. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93481. */
  93482. keysHeightOffsetModifierAlt: boolean;
  93483. /**
  93484. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93485. */
  93486. keysHeightOffsetModifierCtrl: boolean;
  93487. /**
  93488. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93489. */
  93490. keysHeightOffsetModifierShift: boolean;
  93491. /**
  93492. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93493. */
  93494. keysRotationOffsetIncr: number[];
  93495. /**
  93496. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93497. */
  93498. keysRotationOffsetDecr: number[];
  93499. /**
  93500. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93501. */
  93502. keysRotationOffsetModifierAlt: boolean;
  93503. /**
  93504. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93505. */
  93506. keysRotationOffsetModifierCtrl: boolean;
  93507. /**
  93508. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93509. */
  93510. keysRotationOffsetModifierShift: boolean;
  93511. /**
  93512. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93513. */
  93514. keysRadiusIncr: number[];
  93515. /**
  93516. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93517. */
  93518. keysRadiusDecr: number[];
  93519. /**
  93520. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93521. */
  93522. keysRadiusModifierAlt: boolean;
  93523. /**
  93524. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93525. */
  93526. keysRadiusModifierCtrl: boolean;
  93527. /**
  93528. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93529. */
  93530. keysRadiusModifierShift: boolean;
  93531. /**
  93532. * Defines the rate of change of heightOffset.
  93533. */
  93534. heightSensibility: number;
  93535. /**
  93536. * Defines the rate of change of rotationOffset.
  93537. */
  93538. rotationSensibility: number;
  93539. /**
  93540. * Defines the rate of change of radius.
  93541. */
  93542. radiusSensibility: number;
  93543. private _keys;
  93544. private _ctrlPressed;
  93545. private _altPressed;
  93546. private _shiftPressed;
  93547. private _onCanvasBlurObserver;
  93548. private _onKeyboardObserver;
  93549. private _engine;
  93550. private _scene;
  93551. /**
  93552. * Attach the input controls to a specific dom element to get the input from.
  93553. * @param element Defines the element the controls should be listened from
  93554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93555. */
  93556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93557. /**
  93558. * Detach the current controls from the specified dom element.
  93559. * @param element Defines the element to stop listening the inputs from
  93560. */
  93561. detachControl(element: Nullable<HTMLElement>): void;
  93562. /**
  93563. * Update the current camera state depending on the inputs that have been used this frame.
  93564. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93565. */
  93566. checkInputs(): void;
  93567. /**
  93568. * Gets the class name of the current input.
  93569. * @returns the class name
  93570. */
  93571. getClassName(): string;
  93572. /**
  93573. * Get the friendly name associated with the input class.
  93574. * @returns the input friendly name
  93575. */
  93576. getSimpleName(): string;
  93577. /**
  93578. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93579. * allow modification of the heightOffset value.
  93580. */
  93581. private _modifierHeightOffset;
  93582. /**
  93583. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93584. * allow modification of the rotationOffset value.
  93585. */
  93586. private _modifierRotationOffset;
  93587. /**
  93588. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93589. * allow modification of the radius value.
  93590. */
  93591. private _modifierRadius;
  93592. }
  93593. }
  93594. declare module BABYLON {
  93595. interface FreeCameraInputsManager {
  93596. /**
  93597. * Add orientation input support to the input manager.
  93598. * @returns the current input manager
  93599. */
  93600. addDeviceOrientation(): FreeCameraInputsManager;
  93601. }
  93602. /**
  93603. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93604. * Screen rotation is taken into account.
  93605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93606. */
  93607. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93608. private _camera;
  93609. private _screenOrientationAngle;
  93610. private _constantTranform;
  93611. private _screenQuaternion;
  93612. private _alpha;
  93613. private _beta;
  93614. private _gamma;
  93615. /**
  93616. * Instantiates a new input
  93617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93618. */
  93619. constructor();
  93620. /**
  93621. * Define the camera controlled by the input.
  93622. */
  93623. camera: FreeCamera;
  93624. /**
  93625. * Attach the input controls to a specific dom element to get the input from.
  93626. * @param element Defines the element the controls should be listened from
  93627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93628. */
  93629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93630. private _orientationChanged;
  93631. private _deviceOrientation;
  93632. /**
  93633. * Detach the current controls from the specified dom element.
  93634. * @param element Defines the element to stop listening the inputs from
  93635. */
  93636. detachControl(element: Nullable<HTMLElement>): void;
  93637. /**
  93638. * Update the current camera state depending on the inputs that have been used this frame.
  93639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93640. */
  93641. checkInputs(): void;
  93642. /**
  93643. * Gets the class name of the current intput.
  93644. * @returns the class name
  93645. */
  93646. getClassName(): string;
  93647. /**
  93648. * Get the friendly name associated with the input class.
  93649. * @returns the input friendly name
  93650. */
  93651. getSimpleName(): string;
  93652. }
  93653. }
  93654. declare module BABYLON {
  93655. /**
  93656. * Manage the gamepad inputs to control a free camera.
  93657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93658. */
  93659. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93660. /**
  93661. * Define the camera the input is attached to.
  93662. */
  93663. camera: FreeCamera;
  93664. /**
  93665. * Define the Gamepad controlling the input
  93666. */
  93667. gamepad: Nullable<Gamepad>;
  93668. /**
  93669. * Defines the gamepad rotation sensiblity.
  93670. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93671. */
  93672. gamepadAngularSensibility: number;
  93673. /**
  93674. * Defines the gamepad move sensiblity.
  93675. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93676. */
  93677. gamepadMoveSensibility: number;
  93678. private _onGamepadConnectedObserver;
  93679. private _onGamepadDisconnectedObserver;
  93680. private _cameraTransform;
  93681. private _deltaTransform;
  93682. private _vector3;
  93683. private _vector2;
  93684. /**
  93685. * Attach the input controls to a specific dom element to get the input from.
  93686. * @param element Defines the element the controls should be listened from
  93687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93688. */
  93689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93690. /**
  93691. * Detach the current controls from the specified dom element.
  93692. * @param element Defines the element to stop listening the inputs from
  93693. */
  93694. detachControl(element: Nullable<HTMLElement>): void;
  93695. /**
  93696. * Update the current camera state depending on the inputs that have been used this frame.
  93697. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93698. */
  93699. checkInputs(): void;
  93700. /**
  93701. * Gets the class name of the current intput.
  93702. * @returns the class name
  93703. */
  93704. getClassName(): string;
  93705. /**
  93706. * Get the friendly name associated with the input class.
  93707. * @returns the input friendly name
  93708. */
  93709. getSimpleName(): string;
  93710. }
  93711. }
  93712. declare module BABYLON {
  93713. /**
  93714. * Defines the potential axis of a Joystick
  93715. */
  93716. export enum JoystickAxis {
  93717. /** X axis */
  93718. X = 0,
  93719. /** Y axis */
  93720. Y = 1,
  93721. /** Z axis */
  93722. Z = 2
  93723. }
  93724. /**
  93725. * Class used to define virtual joystick (used in touch mode)
  93726. */
  93727. export class VirtualJoystick {
  93728. /**
  93729. * Gets or sets a boolean indicating that left and right values must be inverted
  93730. */
  93731. reverseLeftRight: boolean;
  93732. /**
  93733. * Gets or sets a boolean indicating that up and down values must be inverted
  93734. */
  93735. reverseUpDown: boolean;
  93736. /**
  93737. * Gets the offset value for the position (ie. the change of the position value)
  93738. */
  93739. deltaPosition: Vector3;
  93740. /**
  93741. * Gets a boolean indicating if the virtual joystick was pressed
  93742. */
  93743. pressed: boolean;
  93744. /**
  93745. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93746. */
  93747. static Canvas: Nullable<HTMLCanvasElement>;
  93748. private static _globalJoystickIndex;
  93749. private static vjCanvasContext;
  93750. private static vjCanvasWidth;
  93751. private static vjCanvasHeight;
  93752. private static halfWidth;
  93753. private _action;
  93754. private _axisTargetedByLeftAndRight;
  93755. private _axisTargetedByUpAndDown;
  93756. private _joystickSensibility;
  93757. private _inversedSensibility;
  93758. private _joystickPointerID;
  93759. private _joystickColor;
  93760. private _joystickPointerPos;
  93761. private _joystickPreviousPointerPos;
  93762. private _joystickPointerStartPos;
  93763. private _deltaJoystickVector;
  93764. private _leftJoystick;
  93765. private _touches;
  93766. private _onPointerDownHandlerRef;
  93767. private _onPointerMoveHandlerRef;
  93768. private _onPointerUpHandlerRef;
  93769. private _onResize;
  93770. /**
  93771. * Creates a new virtual joystick
  93772. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93773. */
  93774. constructor(leftJoystick?: boolean);
  93775. /**
  93776. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  93777. * @param newJoystickSensibility defines the new sensibility
  93778. */
  93779. setJoystickSensibility(newJoystickSensibility: number): void;
  93780. private _onPointerDown;
  93781. private _onPointerMove;
  93782. private _onPointerUp;
  93783. /**
  93784. * Change the color of the virtual joystick
  93785. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  93786. */
  93787. setJoystickColor(newColor: string): void;
  93788. /**
  93789. * Defines a callback to call when the joystick is touched
  93790. * @param action defines the callback
  93791. */
  93792. setActionOnTouch(action: () => any): void;
  93793. /**
  93794. * Defines which axis you'd like to control for left & right
  93795. * @param axis defines the axis to use
  93796. */
  93797. setAxisForLeftRight(axis: JoystickAxis): void;
  93798. /**
  93799. * Defines which axis you'd like to control for up & down
  93800. * @param axis defines the axis to use
  93801. */
  93802. setAxisForUpDown(axis: JoystickAxis): void;
  93803. private _drawVirtualJoystick;
  93804. /**
  93805. * Release internal HTML canvas
  93806. */
  93807. releaseCanvas(): void;
  93808. }
  93809. }
  93810. declare module BABYLON {
  93811. interface FreeCameraInputsManager {
  93812. /**
  93813. * Add virtual joystick input support to the input manager.
  93814. * @returns the current input manager
  93815. */
  93816. addVirtualJoystick(): FreeCameraInputsManager;
  93817. }
  93818. /**
  93819. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  93820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93821. */
  93822. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  93823. /**
  93824. * Defines the camera the input is attached to.
  93825. */
  93826. camera: FreeCamera;
  93827. private _leftjoystick;
  93828. private _rightjoystick;
  93829. /**
  93830. * Gets the left stick of the virtual joystick.
  93831. * @returns The virtual Joystick
  93832. */
  93833. getLeftJoystick(): VirtualJoystick;
  93834. /**
  93835. * Gets the right stick of the virtual joystick.
  93836. * @returns The virtual Joystick
  93837. */
  93838. getRightJoystick(): VirtualJoystick;
  93839. /**
  93840. * Update the current camera state depending on the inputs that have been used this frame.
  93841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93842. */
  93843. checkInputs(): void;
  93844. /**
  93845. * Attach the input controls to a specific dom element to get the input from.
  93846. * @param element Defines the element the controls should be listened from
  93847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93848. */
  93849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93850. /**
  93851. * Detach the current controls from the specified dom element.
  93852. * @param element Defines the element to stop listening the inputs from
  93853. */
  93854. detachControl(element: Nullable<HTMLElement>): void;
  93855. /**
  93856. * Gets the class name of the current intput.
  93857. * @returns the class name
  93858. */
  93859. getClassName(): string;
  93860. /**
  93861. * Get the friendly name associated with the input class.
  93862. * @returns the input friendly name
  93863. */
  93864. getSimpleName(): string;
  93865. }
  93866. }
  93867. declare module BABYLON {
  93868. /**
  93869. * This represents a FPS type of camera controlled by touch.
  93870. * This is like a universal camera minus the Gamepad controls.
  93871. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93872. */
  93873. export class TouchCamera extends FreeCamera {
  93874. /**
  93875. * Defines the touch sensibility for rotation.
  93876. * The higher the faster.
  93877. */
  93878. touchAngularSensibility: number;
  93879. /**
  93880. * Defines the touch sensibility for move.
  93881. * The higher the faster.
  93882. */
  93883. touchMoveSensibility: number;
  93884. /**
  93885. * Instantiates a new touch camera.
  93886. * This represents a FPS type of camera controlled by touch.
  93887. * This is like a universal camera minus the Gamepad controls.
  93888. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93889. * @param name Define the name of the camera in the scene
  93890. * @param position Define the start position of the camera in the scene
  93891. * @param scene Define the scene the camera belongs to
  93892. */
  93893. constructor(name: string, position: Vector3, scene: Scene);
  93894. /**
  93895. * Gets the current object class name.
  93896. * @return the class name
  93897. */
  93898. getClassName(): string;
  93899. /** @hidden */
  93900. _setupInputs(): void;
  93901. }
  93902. }
  93903. declare module BABYLON {
  93904. /**
  93905. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  93906. * being tilted forward or back and left or right.
  93907. */
  93908. export class DeviceOrientationCamera extends FreeCamera {
  93909. private _initialQuaternion;
  93910. private _quaternionCache;
  93911. /**
  93912. * Creates a new device orientation camera
  93913. * @param name The name of the camera
  93914. * @param position The start position camera
  93915. * @param scene The scene the camera belongs to
  93916. */
  93917. constructor(name: string, position: Vector3, scene: Scene);
  93918. /**
  93919. * Gets the current instance class name ("DeviceOrientationCamera").
  93920. * This helps avoiding instanceof at run time.
  93921. * @returns the class name
  93922. */
  93923. getClassName(): string;
  93924. /**
  93925. * @hidden
  93926. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  93927. */
  93928. _checkInputs(): void;
  93929. /**
  93930. * Reset the camera to its default orientation on the specified axis only.
  93931. * @param axis The axis to reset
  93932. */
  93933. resetToCurrentRotation(axis?: Axis): void;
  93934. }
  93935. }
  93936. declare module BABYLON {
  93937. /**
  93938. * 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,
  93939. * which still works and will still be found in many Playgrounds.
  93940. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93941. */
  93942. export class UniversalCamera extends TouchCamera {
  93943. /**
  93944. * Defines the gamepad rotation sensiblity.
  93945. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93946. */
  93947. gamepadAngularSensibility: number;
  93948. /**
  93949. * Defines the gamepad move sensiblity.
  93950. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93951. */
  93952. gamepadMoveSensibility: number;
  93953. /**
  93954. * 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,
  93955. * which still works and will still be found in many Playgrounds.
  93956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93957. * @param name Define the name of the camera in the scene
  93958. * @param position Define the start position of the camera in the scene
  93959. * @param scene Define the scene the camera belongs to
  93960. */
  93961. constructor(name: string, position: Vector3, scene: Scene);
  93962. /**
  93963. * Gets the current object class name.
  93964. * @return the class name
  93965. */
  93966. getClassName(): string;
  93967. }
  93968. }
  93969. declare module BABYLON {
  93970. /**
  93971. * This represents a FPS type of camera. This is only here for back compat purpose.
  93972. * Please use the UniversalCamera instead as both are identical.
  93973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93974. */
  93975. export class GamepadCamera extends UniversalCamera {
  93976. /**
  93977. * Instantiates a new Gamepad Camera
  93978. * This represents a FPS type of camera. This is only here for back compat purpose.
  93979. * Please use the UniversalCamera instead as both are identical.
  93980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93981. * @param name Define the name of the camera in the scene
  93982. * @param position Define the start position of the camera in the scene
  93983. * @param scene Define the scene the camera belongs to
  93984. */
  93985. constructor(name: string, position: Vector3, scene: Scene);
  93986. /**
  93987. * Gets the current object class name.
  93988. * @return the class name
  93989. */
  93990. getClassName(): string;
  93991. }
  93992. }
  93993. declare module BABYLON {
  93994. /** @hidden */
  93995. export var passPixelShader: {
  93996. name: string;
  93997. shader: string;
  93998. };
  93999. }
  94000. declare module BABYLON {
  94001. /** @hidden */
  94002. export var passCubePixelShader: {
  94003. name: string;
  94004. shader: string;
  94005. };
  94006. }
  94007. declare module BABYLON {
  94008. /**
  94009. * PassPostProcess which produces an output the same as it's input
  94010. */
  94011. export class PassPostProcess extends PostProcess {
  94012. /**
  94013. * Creates the PassPostProcess
  94014. * @param name The name of the effect.
  94015. * @param options The required width/height ratio to downsize to before computing the render pass.
  94016. * @param camera The camera to apply the render pass to.
  94017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94018. * @param engine The engine which the post process will be applied. (default: current engine)
  94019. * @param reusable If the post process can be reused on the same frame. (default: false)
  94020. * @param textureType The type of texture to be used when performing the post processing.
  94021. * @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)
  94022. */
  94023. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94024. }
  94025. /**
  94026. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94027. */
  94028. export class PassCubePostProcess extends PostProcess {
  94029. private _face;
  94030. /**
  94031. * Gets or sets the cube face to display.
  94032. * * 0 is +X
  94033. * * 1 is -X
  94034. * * 2 is +Y
  94035. * * 3 is -Y
  94036. * * 4 is +Z
  94037. * * 5 is -Z
  94038. */
  94039. face: number;
  94040. /**
  94041. * Creates the PassCubePostProcess
  94042. * @param name The name of the effect.
  94043. * @param options The required width/height ratio to downsize to before computing the render pass.
  94044. * @param camera The camera to apply the render pass to.
  94045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94046. * @param engine The engine which the post process will be applied. (default: current engine)
  94047. * @param reusable If the post process can be reused on the same frame. (default: false)
  94048. * @param textureType The type of texture to be used when performing the post processing.
  94049. * @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)
  94050. */
  94051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94052. }
  94053. }
  94054. declare module BABYLON {
  94055. /** @hidden */
  94056. export var anaglyphPixelShader: {
  94057. name: string;
  94058. shader: string;
  94059. };
  94060. }
  94061. declare module BABYLON {
  94062. /**
  94063. * Postprocess used to generate anaglyphic rendering
  94064. */
  94065. export class AnaglyphPostProcess extends PostProcess {
  94066. private _passedProcess;
  94067. /**
  94068. * Creates a new AnaglyphPostProcess
  94069. * @param name defines postprocess name
  94070. * @param options defines creation options or target ratio scale
  94071. * @param rigCameras defines cameras using this postprocess
  94072. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94073. * @param engine defines hosting engine
  94074. * @param reusable defines if the postprocess will be reused multiple times per frame
  94075. */
  94076. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94077. }
  94078. }
  94079. declare module BABYLON {
  94080. /**
  94081. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94082. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94083. */
  94084. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94085. /**
  94086. * Creates a new AnaglyphArcRotateCamera
  94087. * @param name defines camera name
  94088. * @param alpha defines alpha angle (in radians)
  94089. * @param beta defines beta angle (in radians)
  94090. * @param radius defines radius
  94091. * @param target defines camera target
  94092. * @param interaxialDistance defines distance between each color axis
  94093. * @param scene defines the hosting scene
  94094. */
  94095. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94096. /**
  94097. * Gets camera class name
  94098. * @returns AnaglyphArcRotateCamera
  94099. */
  94100. getClassName(): string;
  94101. }
  94102. }
  94103. declare module BABYLON {
  94104. /**
  94105. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94106. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94107. */
  94108. export class AnaglyphFreeCamera extends FreeCamera {
  94109. /**
  94110. * Creates a new AnaglyphFreeCamera
  94111. * @param name defines camera name
  94112. * @param position defines initial position
  94113. * @param interaxialDistance defines distance between each color axis
  94114. * @param scene defines the hosting scene
  94115. */
  94116. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94117. /**
  94118. * Gets camera class name
  94119. * @returns AnaglyphFreeCamera
  94120. */
  94121. getClassName(): string;
  94122. }
  94123. }
  94124. declare module BABYLON {
  94125. /**
  94126. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94127. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94128. */
  94129. export class AnaglyphGamepadCamera extends GamepadCamera {
  94130. /**
  94131. * Creates a new AnaglyphGamepadCamera
  94132. * @param name defines camera name
  94133. * @param position defines initial position
  94134. * @param interaxialDistance defines distance between each color axis
  94135. * @param scene defines the hosting scene
  94136. */
  94137. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94138. /**
  94139. * Gets camera class name
  94140. * @returns AnaglyphGamepadCamera
  94141. */
  94142. getClassName(): string;
  94143. }
  94144. }
  94145. declare module BABYLON {
  94146. /**
  94147. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94148. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94149. */
  94150. export class AnaglyphUniversalCamera extends UniversalCamera {
  94151. /**
  94152. * Creates a new AnaglyphUniversalCamera
  94153. * @param name defines camera name
  94154. * @param position defines initial position
  94155. * @param interaxialDistance defines distance between each color axis
  94156. * @param scene defines the hosting scene
  94157. */
  94158. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94159. /**
  94160. * Gets camera class name
  94161. * @returns AnaglyphUniversalCamera
  94162. */
  94163. getClassName(): string;
  94164. }
  94165. }
  94166. declare module BABYLON {
  94167. /** @hidden */
  94168. export var stereoscopicInterlacePixelShader: {
  94169. name: string;
  94170. shader: string;
  94171. };
  94172. }
  94173. declare module BABYLON {
  94174. /**
  94175. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94176. */
  94177. export class StereoscopicInterlacePostProcess extends PostProcess {
  94178. private _stepSize;
  94179. private _passedProcess;
  94180. /**
  94181. * Initializes a StereoscopicInterlacePostProcess
  94182. * @param name The name of the effect.
  94183. * @param rigCameras The rig cameras to be appled to the post process
  94184. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94186. * @param engine The engine which the post process will be applied. (default: current engine)
  94187. * @param reusable If the post process can be reused on the same frame. (default: false)
  94188. */
  94189. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94190. }
  94191. }
  94192. declare module BABYLON {
  94193. /**
  94194. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94195. * @see http://doc.babylonjs.com/features/cameras
  94196. */
  94197. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94198. /**
  94199. * Creates a new StereoscopicArcRotateCamera
  94200. * @param name defines camera name
  94201. * @param alpha defines alpha angle (in radians)
  94202. * @param beta defines beta angle (in radians)
  94203. * @param radius defines radius
  94204. * @param target defines camera target
  94205. * @param interaxialDistance defines distance between each color axis
  94206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94207. * @param scene defines the hosting scene
  94208. */
  94209. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94210. /**
  94211. * Gets camera class name
  94212. * @returns StereoscopicArcRotateCamera
  94213. */
  94214. getClassName(): string;
  94215. }
  94216. }
  94217. declare module BABYLON {
  94218. /**
  94219. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94220. * @see http://doc.babylonjs.com/features/cameras
  94221. */
  94222. export class StereoscopicFreeCamera extends FreeCamera {
  94223. /**
  94224. * Creates a new StereoscopicFreeCamera
  94225. * @param name defines camera name
  94226. * @param position defines initial position
  94227. * @param interaxialDistance defines distance between each color axis
  94228. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94229. * @param scene defines the hosting scene
  94230. */
  94231. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94232. /**
  94233. * Gets camera class name
  94234. * @returns StereoscopicFreeCamera
  94235. */
  94236. getClassName(): string;
  94237. }
  94238. }
  94239. declare module BABYLON {
  94240. /**
  94241. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94242. * @see http://doc.babylonjs.com/features/cameras
  94243. */
  94244. export class StereoscopicGamepadCamera extends GamepadCamera {
  94245. /**
  94246. * Creates a new StereoscopicGamepadCamera
  94247. * @param name defines camera name
  94248. * @param position defines initial position
  94249. * @param interaxialDistance defines distance between each color axis
  94250. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94251. * @param scene defines the hosting scene
  94252. */
  94253. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94254. /**
  94255. * Gets camera class name
  94256. * @returns StereoscopicGamepadCamera
  94257. */
  94258. getClassName(): string;
  94259. }
  94260. }
  94261. declare module BABYLON {
  94262. /**
  94263. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94264. * @see http://doc.babylonjs.com/features/cameras
  94265. */
  94266. export class StereoscopicUniversalCamera extends UniversalCamera {
  94267. /**
  94268. * Creates a new StereoscopicUniversalCamera
  94269. * @param name defines camera name
  94270. * @param position defines initial position
  94271. * @param interaxialDistance defines distance between each color axis
  94272. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94273. * @param scene defines the hosting scene
  94274. */
  94275. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94276. /**
  94277. * Gets camera class name
  94278. * @returns StereoscopicUniversalCamera
  94279. */
  94280. getClassName(): string;
  94281. }
  94282. }
  94283. declare module BABYLON {
  94284. /**
  94285. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94286. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94287. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94288. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94289. */
  94290. export class VirtualJoysticksCamera extends FreeCamera {
  94291. /**
  94292. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94293. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94294. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94295. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94296. * @param name Define the name of the camera in the scene
  94297. * @param position Define the start position of the camera in the scene
  94298. * @param scene Define the scene the camera belongs to
  94299. */
  94300. constructor(name: string, position: Vector3, scene: Scene);
  94301. /**
  94302. * Gets the current object class name.
  94303. * @return the class name
  94304. */
  94305. getClassName(): string;
  94306. }
  94307. }
  94308. declare module BABYLON {
  94309. /**
  94310. * This represents all the required metrics to create a VR camera.
  94311. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94312. */
  94313. export class VRCameraMetrics {
  94314. /**
  94315. * Define the horizontal resolution off the screen.
  94316. */
  94317. hResolution: number;
  94318. /**
  94319. * Define the vertical resolution off the screen.
  94320. */
  94321. vResolution: number;
  94322. /**
  94323. * Define the horizontal screen size.
  94324. */
  94325. hScreenSize: number;
  94326. /**
  94327. * Define the vertical screen size.
  94328. */
  94329. vScreenSize: number;
  94330. /**
  94331. * Define the vertical screen center position.
  94332. */
  94333. vScreenCenter: number;
  94334. /**
  94335. * Define the distance of the eyes to the screen.
  94336. */
  94337. eyeToScreenDistance: number;
  94338. /**
  94339. * Define the distance between both lenses
  94340. */
  94341. lensSeparationDistance: number;
  94342. /**
  94343. * Define the distance between both viewer's eyes.
  94344. */
  94345. interpupillaryDistance: number;
  94346. /**
  94347. * Define the distortion factor of the VR postprocess.
  94348. * Please, touch with care.
  94349. */
  94350. distortionK: number[];
  94351. /**
  94352. * Define the chromatic aberration correction factors for the VR post process.
  94353. */
  94354. chromaAbCorrection: number[];
  94355. /**
  94356. * Define the scale factor of the post process.
  94357. * The smaller the better but the slower.
  94358. */
  94359. postProcessScaleFactor: number;
  94360. /**
  94361. * Define an offset for the lens center.
  94362. */
  94363. lensCenterOffset: number;
  94364. /**
  94365. * Define if the current vr camera should compensate the distortion of the lense or not.
  94366. */
  94367. compensateDistortion: boolean;
  94368. /**
  94369. * Gets the rendering aspect ratio based on the provided resolutions.
  94370. */
  94371. readonly aspectRatio: number;
  94372. /**
  94373. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94374. */
  94375. readonly aspectRatioFov: number;
  94376. /**
  94377. * @hidden
  94378. */
  94379. readonly leftHMatrix: Matrix;
  94380. /**
  94381. * @hidden
  94382. */
  94383. readonly rightHMatrix: Matrix;
  94384. /**
  94385. * @hidden
  94386. */
  94387. readonly leftPreViewMatrix: Matrix;
  94388. /**
  94389. * @hidden
  94390. */
  94391. readonly rightPreViewMatrix: Matrix;
  94392. /**
  94393. * Get the default VRMetrics based on the most generic setup.
  94394. * @returns the default vr metrics
  94395. */
  94396. static GetDefault(): VRCameraMetrics;
  94397. }
  94398. }
  94399. declare module BABYLON {
  94400. /** @hidden */
  94401. export var vrDistortionCorrectionPixelShader: {
  94402. name: string;
  94403. shader: string;
  94404. };
  94405. }
  94406. declare module BABYLON {
  94407. /**
  94408. * VRDistortionCorrectionPostProcess used for mobile VR
  94409. */
  94410. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94411. private _isRightEye;
  94412. private _distortionFactors;
  94413. private _postProcessScaleFactor;
  94414. private _lensCenterOffset;
  94415. private _scaleIn;
  94416. private _scaleFactor;
  94417. private _lensCenter;
  94418. /**
  94419. * Initializes the VRDistortionCorrectionPostProcess
  94420. * @param name The name of the effect.
  94421. * @param camera The camera to apply the render pass to.
  94422. * @param isRightEye If this is for the right eye distortion
  94423. * @param vrMetrics All the required metrics for the VR camera
  94424. */
  94425. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94426. }
  94427. }
  94428. declare module BABYLON {
  94429. /**
  94430. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94431. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94432. */
  94433. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94434. /**
  94435. * Creates a new VRDeviceOrientationArcRotateCamera
  94436. * @param name defines camera name
  94437. * @param alpha defines the camera rotation along the logitudinal axis
  94438. * @param beta defines the camera rotation along the latitudinal axis
  94439. * @param radius defines the camera distance from its target
  94440. * @param target defines the camera target
  94441. * @param scene defines the scene the camera belongs to
  94442. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94443. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94444. */
  94445. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94446. /**
  94447. * Gets camera class name
  94448. * @returns VRDeviceOrientationArcRotateCamera
  94449. */
  94450. getClassName(): string;
  94451. }
  94452. }
  94453. declare module BABYLON {
  94454. /**
  94455. * Camera used to simulate VR rendering (based on FreeCamera)
  94456. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94457. */
  94458. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94459. /**
  94460. * Creates a new VRDeviceOrientationFreeCamera
  94461. * @param name defines camera name
  94462. * @param position defines the start position of the camera
  94463. * @param scene defines the scene the camera belongs to
  94464. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94465. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94466. */
  94467. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94468. /**
  94469. * Gets camera class name
  94470. * @returns VRDeviceOrientationFreeCamera
  94471. */
  94472. getClassName(): string;
  94473. }
  94474. }
  94475. declare module BABYLON {
  94476. /**
  94477. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94478. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94479. */
  94480. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94481. /**
  94482. * Creates a new VRDeviceOrientationGamepadCamera
  94483. * @param name defines camera name
  94484. * @param position defines the start position of the camera
  94485. * @param scene defines the scene the camera belongs to
  94486. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94487. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94488. */
  94489. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94490. /**
  94491. * Gets camera class name
  94492. * @returns VRDeviceOrientationGamepadCamera
  94493. */
  94494. getClassName(): string;
  94495. }
  94496. }
  94497. declare module BABYLON {
  94498. /**
  94499. * Defines supported buttons for XBox360 compatible gamepads
  94500. */
  94501. export enum Xbox360Button {
  94502. /** A */
  94503. A = 0,
  94504. /** B */
  94505. B = 1,
  94506. /** X */
  94507. X = 2,
  94508. /** Y */
  94509. Y = 3,
  94510. /** Start */
  94511. Start = 4,
  94512. /** Back */
  94513. Back = 5,
  94514. /** Left button */
  94515. LB = 6,
  94516. /** Right button */
  94517. RB = 7,
  94518. /** Left stick */
  94519. LeftStick = 8,
  94520. /** Right stick */
  94521. RightStick = 9
  94522. }
  94523. /** Defines values for XBox360 DPad */
  94524. export enum Xbox360Dpad {
  94525. /** Up */
  94526. Up = 0,
  94527. /** Down */
  94528. Down = 1,
  94529. /** Left */
  94530. Left = 2,
  94531. /** Right */
  94532. Right = 3
  94533. }
  94534. /**
  94535. * Defines a XBox360 gamepad
  94536. */
  94537. export class Xbox360Pad extends Gamepad {
  94538. private _leftTrigger;
  94539. private _rightTrigger;
  94540. private _onlefttriggerchanged;
  94541. private _onrighttriggerchanged;
  94542. private _onbuttondown;
  94543. private _onbuttonup;
  94544. private _ondpaddown;
  94545. private _ondpadup;
  94546. /** Observable raised when a button is pressed */
  94547. onButtonDownObservable: Observable<Xbox360Button>;
  94548. /** Observable raised when a button is released */
  94549. onButtonUpObservable: Observable<Xbox360Button>;
  94550. /** Observable raised when a pad is pressed */
  94551. onPadDownObservable: Observable<Xbox360Dpad>;
  94552. /** Observable raised when a pad is released */
  94553. onPadUpObservable: Observable<Xbox360Dpad>;
  94554. private _buttonA;
  94555. private _buttonB;
  94556. private _buttonX;
  94557. private _buttonY;
  94558. private _buttonBack;
  94559. private _buttonStart;
  94560. private _buttonLB;
  94561. private _buttonRB;
  94562. private _buttonLeftStick;
  94563. private _buttonRightStick;
  94564. private _dPadUp;
  94565. private _dPadDown;
  94566. private _dPadLeft;
  94567. private _dPadRight;
  94568. private _isXboxOnePad;
  94569. /**
  94570. * Creates a new XBox360 gamepad object
  94571. * @param id defines the id of this gamepad
  94572. * @param index defines its index
  94573. * @param gamepad defines the internal HTML gamepad object
  94574. * @param xboxOne defines if it is a XBox One gamepad
  94575. */
  94576. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94577. /**
  94578. * Defines the callback to call when left trigger is pressed
  94579. * @param callback defines the callback to use
  94580. */
  94581. onlefttriggerchanged(callback: (value: number) => void): void;
  94582. /**
  94583. * Defines the callback to call when right trigger is pressed
  94584. * @param callback defines the callback to use
  94585. */
  94586. onrighttriggerchanged(callback: (value: number) => void): void;
  94587. /**
  94588. * Gets the left trigger value
  94589. */
  94590. /**
  94591. * Sets the left trigger value
  94592. */
  94593. leftTrigger: number;
  94594. /**
  94595. * Gets the right trigger value
  94596. */
  94597. /**
  94598. * Sets the right trigger value
  94599. */
  94600. rightTrigger: number;
  94601. /**
  94602. * Defines the callback to call when a button is pressed
  94603. * @param callback defines the callback to use
  94604. */
  94605. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94606. /**
  94607. * Defines the callback to call when a button is released
  94608. * @param callback defines the callback to use
  94609. */
  94610. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94611. /**
  94612. * Defines the callback to call when a pad is pressed
  94613. * @param callback defines the callback to use
  94614. */
  94615. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94616. /**
  94617. * Defines the callback to call when a pad is released
  94618. * @param callback defines the callback to use
  94619. */
  94620. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94621. private _setButtonValue;
  94622. private _setDPadValue;
  94623. /**
  94624. * Gets the value of the `A` button
  94625. */
  94626. /**
  94627. * Sets the value of the `A` button
  94628. */
  94629. buttonA: number;
  94630. /**
  94631. * Gets the value of the `B` button
  94632. */
  94633. /**
  94634. * Sets the value of the `B` button
  94635. */
  94636. buttonB: number;
  94637. /**
  94638. * Gets the value of the `X` button
  94639. */
  94640. /**
  94641. * Sets the value of the `X` button
  94642. */
  94643. buttonX: number;
  94644. /**
  94645. * Gets the value of the `Y` button
  94646. */
  94647. /**
  94648. * Sets the value of the `Y` button
  94649. */
  94650. buttonY: number;
  94651. /**
  94652. * Gets the value of the `Start` button
  94653. */
  94654. /**
  94655. * Sets the value of the `Start` button
  94656. */
  94657. buttonStart: number;
  94658. /**
  94659. * Gets the value of the `Back` button
  94660. */
  94661. /**
  94662. * Sets the value of the `Back` button
  94663. */
  94664. buttonBack: number;
  94665. /**
  94666. * Gets the value of the `Left` button
  94667. */
  94668. /**
  94669. * Sets the value of the `Left` button
  94670. */
  94671. buttonLB: number;
  94672. /**
  94673. * Gets the value of the `Right` button
  94674. */
  94675. /**
  94676. * Sets the value of the `Right` button
  94677. */
  94678. buttonRB: number;
  94679. /**
  94680. * Gets the value of the Left joystick
  94681. */
  94682. /**
  94683. * Sets the value of the Left joystick
  94684. */
  94685. buttonLeftStick: number;
  94686. /**
  94687. * Gets the value of the Right joystick
  94688. */
  94689. /**
  94690. * Sets the value of the Right joystick
  94691. */
  94692. buttonRightStick: number;
  94693. /**
  94694. * Gets the value of D-pad up
  94695. */
  94696. /**
  94697. * Sets the value of D-pad up
  94698. */
  94699. dPadUp: number;
  94700. /**
  94701. * Gets the value of D-pad down
  94702. */
  94703. /**
  94704. * Sets the value of D-pad down
  94705. */
  94706. dPadDown: number;
  94707. /**
  94708. * Gets the value of D-pad left
  94709. */
  94710. /**
  94711. * Sets the value of D-pad left
  94712. */
  94713. dPadLeft: number;
  94714. /**
  94715. * Gets the value of D-pad right
  94716. */
  94717. /**
  94718. * Sets the value of D-pad right
  94719. */
  94720. dPadRight: number;
  94721. /**
  94722. * Force the gamepad to synchronize with device values
  94723. */
  94724. update(): void;
  94725. /**
  94726. * Disposes the gamepad
  94727. */
  94728. dispose(): void;
  94729. }
  94730. }
  94731. declare module BABYLON {
  94732. /**
  94733. * Base class of materials working in push mode in babylon JS
  94734. * @hidden
  94735. */
  94736. export class PushMaterial extends Material {
  94737. protected _activeEffect: Effect;
  94738. protected _normalMatrix: Matrix;
  94739. /**
  94740. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94741. * This means that the material can keep using a previous shader while a new one is being compiled.
  94742. * This is mostly used when shader parallel compilation is supported (true by default)
  94743. */
  94744. allowShaderHotSwapping: boolean;
  94745. constructor(name: string, scene: Scene);
  94746. getEffect(): Effect;
  94747. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94748. /**
  94749. * Binds the given world matrix to the active effect
  94750. *
  94751. * @param world the matrix to bind
  94752. */
  94753. bindOnlyWorldMatrix(world: Matrix): void;
  94754. /**
  94755. * Binds the given normal matrix to the active effect
  94756. *
  94757. * @param normalMatrix the matrix to bind
  94758. */
  94759. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94760. bind(world: Matrix, mesh?: Mesh): void;
  94761. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94762. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94763. }
  94764. }
  94765. declare module BABYLON {
  94766. /**
  94767. * This groups all the flags used to control the materials channel.
  94768. */
  94769. export class MaterialFlags {
  94770. private static _DiffuseTextureEnabled;
  94771. /**
  94772. * Are diffuse textures enabled in the application.
  94773. */
  94774. static DiffuseTextureEnabled: boolean;
  94775. private static _AmbientTextureEnabled;
  94776. /**
  94777. * Are ambient textures enabled in the application.
  94778. */
  94779. static AmbientTextureEnabled: boolean;
  94780. private static _OpacityTextureEnabled;
  94781. /**
  94782. * Are opacity textures enabled in the application.
  94783. */
  94784. static OpacityTextureEnabled: boolean;
  94785. private static _ReflectionTextureEnabled;
  94786. /**
  94787. * Are reflection textures enabled in the application.
  94788. */
  94789. static ReflectionTextureEnabled: boolean;
  94790. private static _EmissiveTextureEnabled;
  94791. /**
  94792. * Are emissive textures enabled in the application.
  94793. */
  94794. static EmissiveTextureEnabled: boolean;
  94795. private static _SpecularTextureEnabled;
  94796. /**
  94797. * Are specular textures enabled in the application.
  94798. */
  94799. static SpecularTextureEnabled: boolean;
  94800. private static _BumpTextureEnabled;
  94801. /**
  94802. * Are bump textures enabled in the application.
  94803. */
  94804. static BumpTextureEnabled: boolean;
  94805. private static _LightmapTextureEnabled;
  94806. /**
  94807. * Are lightmap textures enabled in the application.
  94808. */
  94809. static LightmapTextureEnabled: boolean;
  94810. private static _RefractionTextureEnabled;
  94811. /**
  94812. * Are refraction textures enabled in the application.
  94813. */
  94814. static RefractionTextureEnabled: boolean;
  94815. private static _ColorGradingTextureEnabled;
  94816. /**
  94817. * Are color grading textures enabled in the application.
  94818. */
  94819. static ColorGradingTextureEnabled: boolean;
  94820. private static _FresnelEnabled;
  94821. /**
  94822. * Are fresnels enabled in the application.
  94823. */
  94824. static FresnelEnabled: boolean;
  94825. private static _ClearCoatTextureEnabled;
  94826. /**
  94827. * Are clear coat textures enabled in the application.
  94828. */
  94829. static ClearCoatTextureEnabled: boolean;
  94830. private static _ClearCoatBumpTextureEnabled;
  94831. /**
  94832. * Are clear coat bump textures enabled in the application.
  94833. */
  94834. static ClearCoatBumpTextureEnabled: boolean;
  94835. private static _ClearCoatTintTextureEnabled;
  94836. /**
  94837. * Are clear coat tint textures enabled in the application.
  94838. */
  94839. static ClearCoatTintTextureEnabled: boolean;
  94840. }
  94841. }
  94842. declare module BABYLON {
  94843. /** @hidden */
  94844. export var defaultFragmentDeclaration: {
  94845. name: string;
  94846. shader: string;
  94847. };
  94848. }
  94849. declare module BABYLON {
  94850. /** @hidden */
  94851. export var defaultUboDeclaration: {
  94852. name: string;
  94853. shader: string;
  94854. };
  94855. }
  94856. declare module BABYLON {
  94857. /** @hidden */
  94858. export var lightFragmentDeclaration: {
  94859. name: string;
  94860. shader: string;
  94861. };
  94862. }
  94863. declare module BABYLON {
  94864. /** @hidden */
  94865. export var lightUboDeclaration: {
  94866. name: string;
  94867. shader: string;
  94868. };
  94869. }
  94870. declare module BABYLON {
  94871. /** @hidden */
  94872. export var lightsFragmentFunctions: {
  94873. name: string;
  94874. shader: string;
  94875. };
  94876. }
  94877. declare module BABYLON {
  94878. /** @hidden */
  94879. export var shadowsFragmentFunctions: {
  94880. name: string;
  94881. shader: string;
  94882. };
  94883. }
  94884. declare module BABYLON {
  94885. /** @hidden */
  94886. export var fresnelFunction: {
  94887. name: string;
  94888. shader: string;
  94889. };
  94890. }
  94891. declare module BABYLON {
  94892. /** @hidden */
  94893. export var reflectionFunction: {
  94894. name: string;
  94895. shader: string;
  94896. };
  94897. }
  94898. declare module BABYLON {
  94899. /** @hidden */
  94900. export var bumpFragmentFunctions: {
  94901. name: string;
  94902. shader: string;
  94903. };
  94904. }
  94905. declare module BABYLON {
  94906. /** @hidden */
  94907. export var logDepthDeclaration: {
  94908. name: string;
  94909. shader: string;
  94910. };
  94911. }
  94912. declare module BABYLON {
  94913. /** @hidden */
  94914. export var bumpFragment: {
  94915. name: string;
  94916. shader: string;
  94917. };
  94918. }
  94919. declare module BABYLON {
  94920. /** @hidden */
  94921. export var depthPrePass: {
  94922. name: string;
  94923. shader: string;
  94924. };
  94925. }
  94926. declare module BABYLON {
  94927. /** @hidden */
  94928. export var lightFragment: {
  94929. name: string;
  94930. shader: string;
  94931. };
  94932. }
  94933. declare module BABYLON {
  94934. /** @hidden */
  94935. export var logDepthFragment: {
  94936. name: string;
  94937. shader: string;
  94938. };
  94939. }
  94940. declare module BABYLON {
  94941. /** @hidden */
  94942. export var defaultPixelShader: {
  94943. name: string;
  94944. shader: string;
  94945. };
  94946. }
  94947. declare module BABYLON {
  94948. /** @hidden */
  94949. export var defaultVertexDeclaration: {
  94950. name: string;
  94951. shader: string;
  94952. };
  94953. }
  94954. declare module BABYLON {
  94955. /** @hidden */
  94956. export var bumpVertexDeclaration: {
  94957. name: string;
  94958. shader: string;
  94959. };
  94960. }
  94961. declare module BABYLON {
  94962. /** @hidden */
  94963. export var bumpVertex: {
  94964. name: string;
  94965. shader: string;
  94966. };
  94967. }
  94968. declare module BABYLON {
  94969. /** @hidden */
  94970. export var fogVertex: {
  94971. name: string;
  94972. shader: string;
  94973. };
  94974. }
  94975. declare module BABYLON {
  94976. /** @hidden */
  94977. export var shadowsVertex: {
  94978. name: string;
  94979. shader: string;
  94980. };
  94981. }
  94982. declare module BABYLON {
  94983. /** @hidden */
  94984. export var pointCloudVertex: {
  94985. name: string;
  94986. shader: string;
  94987. };
  94988. }
  94989. declare module BABYLON {
  94990. /** @hidden */
  94991. export var logDepthVertex: {
  94992. name: string;
  94993. shader: string;
  94994. };
  94995. }
  94996. declare module BABYLON {
  94997. /** @hidden */
  94998. export var defaultVertexShader: {
  94999. name: string;
  95000. shader: string;
  95001. };
  95002. }
  95003. declare module BABYLON {
  95004. /** @hidden */
  95005. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95006. MAINUV1: boolean;
  95007. MAINUV2: boolean;
  95008. DIFFUSE: boolean;
  95009. DIFFUSEDIRECTUV: number;
  95010. AMBIENT: boolean;
  95011. AMBIENTDIRECTUV: number;
  95012. OPACITY: boolean;
  95013. OPACITYDIRECTUV: number;
  95014. OPACITYRGB: boolean;
  95015. REFLECTION: boolean;
  95016. EMISSIVE: boolean;
  95017. EMISSIVEDIRECTUV: number;
  95018. SPECULAR: boolean;
  95019. SPECULARDIRECTUV: number;
  95020. BUMP: boolean;
  95021. BUMPDIRECTUV: number;
  95022. PARALLAX: boolean;
  95023. PARALLAXOCCLUSION: boolean;
  95024. SPECULAROVERALPHA: boolean;
  95025. CLIPPLANE: boolean;
  95026. CLIPPLANE2: boolean;
  95027. CLIPPLANE3: boolean;
  95028. CLIPPLANE4: boolean;
  95029. ALPHATEST: boolean;
  95030. DEPTHPREPASS: boolean;
  95031. ALPHAFROMDIFFUSE: boolean;
  95032. POINTSIZE: boolean;
  95033. FOG: boolean;
  95034. SPECULARTERM: boolean;
  95035. DIFFUSEFRESNEL: boolean;
  95036. OPACITYFRESNEL: boolean;
  95037. REFLECTIONFRESNEL: boolean;
  95038. REFRACTIONFRESNEL: boolean;
  95039. EMISSIVEFRESNEL: boolean;
  95040. FRESNEL: boolean;
  95041. NORMAL: boolean;
  95042. UV1: boolean;
  95043. UV2: boolean;
  95044. VERTEXCOLOR: boolean;
  95045. VERTEXALPHA: boolean;
  95046. NUM_BONE_INFLUENCERS: number;
  95047. BonesPerMesh: number;
  95048. BONETEXTURE: boolean;
  95049. INSTANCES: boolean;
  95050. GLOSSINESS: boolean;
  95051. ROUGHNESS: boolean;
  95052. EMISSIVEASILLUMINATION: boolean;
  95053. LINKEMISSIVEWITHDIFFUSE: boolean;
  95054. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95055. LIGHTMAP: boolean;
  95056. LIGHTMAPDIRECTUV: number;
  95057. OBJECTSPACE_NORMALMAP: boolean;
  95058. USELIGHTMAPASSHADOWMAP: boolean;
  95059. REFLECTIONMAP_3D: boolean;
  95060. REFLECTIONMAP_SPHERICAL: boolean;
  95061. REFLECTIONMAP_PLANAR: boolean;
  95062. REFLECTIONMAP_CUBIC: boolean;
  95063. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95064. REFLECTIONMAP_PROJECTION: boolean;
  95065. REFLECTIONMAP_SKYBOX: boolean;
  95066. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95067. REFLECTIONMAP_EXPLICIT: boolean;
  95068. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95069. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95070. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95071. INVERTCUBICMAP: boolean;
  95072. LOGARITHMICDEPTH: boolean;
  95073. REFRACTION: boolean;
  95074. REFRACTIONMAP_3D: boolean;
  95075. REFLECTIONOVERALPHA: boolean;
  95076. TWOSIDEDLIGHTING: boolean;
  95077. SHADOWFLOAT: boolean;
  95078. MORPHTARGETS: boolean;
  95079. MORPHTARGETS_NORMAL: boolean;
  95080. MORPHTARGETS_TANGENT: boolean;
  95081. NUM_MORPH_INFLUENCERS: number;
  95082. NONUNIFORMSCALING: boolean;
  95083. PREMULTIPLYALPHA: boolean;
  95084. IMAGEPROCESSING: boolean;
  95085. VIGNETTE: boolean;
  95086. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95087. VIGNETTEBLENDMODEOPAQUE: boolean;
  95088. TONEMAPPING: boolean;
  95089. TONEMAPPING_ACES: boolean;
  95090. CONTRAST: boolean;
  95091. COLORCURVES: boolean;
  95092. COLORGRADING: boolean;
  95093. COLORGRADING3D: boolean;
  95094. SAMPLER3DGREENDEPTH: boolean;
  95095. SAMPLER3DBGRMAP: boolean;
  95096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95097. /**
  95098. * If the reflection texture on this material is in linear color space
  95099. * @hidden
  95100. */
  95101. IS_REFLECTION_LINEAR: boolean;
  95102. /**
  95103. * If the refraction texture on this material is in linear color space
  95104. * @hidden
  95105. */
  95106. IS_REFRACTION_LINEAR: boolean;
  95107. EXPOSURE: boolean;
  95108. constructor();
  95109. setReflectionMode(modeToEnable: string): void;
  95110. }
  95111. /**
  95112. * This is the default material used in Babylon. It is the best trade off between quality
  95113. * and performances.
  95114. * @see http://doc.babylonjs.com/babylon101/materials
  95115. */
  95116. export class StandardMaterial extends PushMaterial {
  95117. private _diffuseTexture;
  95118. /**
  95119. * The basic texture of the material as viewed under a light.
  95120. */
  95121. diffuseTexture: Nullable<BaseTexture>;
  95122. private _ambientTexture;
  95123. /**
  95124. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95125. */
  95126. ambientTexture: Nullable<BaseTexture>;
  95127. private _opacityTexture;
  95128. /**
  95129. * Define the transparency of the material from a texture.
  95130. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95131. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95132. */
  95133. opacityTexture: Nullable<BaseTexture>;
  95134. private _reflectionTexture;
  95135. /**
  95136. * Define the texture used to display the reflection.
  95137. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95138. */
  95139. reflectionTexture: Nullable<BaseTexture>;
  95140. private _emissiveTexture;
  95141. /**
  95142. * Define texture of the material as if self lit.
  95143. * This will be mixed in the final result even in the absence of light.
  95144. */
  95145. emissiveTexture: Nullable<BaseTexture>;
  95146. private _specularTexture;
  95147. /**
  95148. * Define how the color and intensity of the highlight given by the light in the material.
  95149. */
  95150. specularTexture: Nullable<BaseTexture>;
  95151. private _bumpTexture;
  95152. /**
  95153. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95154. * 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.
  95155. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95156. */
  95157. bumpTexture: Nullable<BaseTexture>;
  95158. private _lightmapTexture;
  95159. /**
  95160. * Complex lighting can be computationally expensive to compute at runtime.
  95161. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95162. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95163. */
  95164. lightmapTexture: Nullable<BaseTexture>;
  95165. private _refractionTexture;
  95166. /**
  95167. * Define the texture used to display the refraction.
  95168. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95169. */
  95170. refractionTexture: Nullable<BaseTexture>;
  95171. /**
  95172. * The color of the material lit by the environmental background lighting.
  95173. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95174. */
  95175. ambientColor: Color3;
  95176. /**
  95177. * The basic color of the material as viewed under a light.
  95178. */
  95179. diffuseColor: Color3;
  95180. /**
  95181. * Define how the color and intensity of the highlight given by the light in the material.
  95182. */
  95183. specularColor: Color3;
  95184. /**
  95185. * Define the color of the material as if self lit.
  95186. * This will be mixed in the final result even in the absence of light.
  95187. */
  95188. emissiveColor: Color3;
  95189. /**
  95190. * Defines how sharp are the highlights in the material.
  95191. * The bigger the value the sharper giving a more glossy feeling to the result.
  95192. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95193. */
  95194. specularPower: number;
  95195. private _useAlphaFromDiffuseTexture;
  95196. /**
  95197. * Does the transparency come from the diffuse texture alpha channel.
  95198. */
  95199. useAlphaFromDiffuseTexture: boolean;
  95200. private _useEmissiveAsIllumination;
  95201. /**
  95202. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95203. */
  95204. useEmissiveAsIllumination: boolean;
  95205. private _linkEmissiveWithDiffuse;
  95206. /**
  95207. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95208. * the emissive level when the final color is close to one.
  95209. */
  95210. linkEmissiveWithDiffuse: boolean;
  95211. private _useSpecularOverAlpha;
  95212. /**
  95213. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95214. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95215. */
  95216. useSpecularOverAlpha: boolean;
  95217. private _useReflectionOverAlpha;
  95218. /**
  95219. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95220. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95221. */
  95222. useReflectionOverAlpha: boolean;
  95223. private _disableLighting;
  95224. /**
  95225. * Does lights from the scene impacts this material.
  95226. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95227. */
  95228. disableLighting: boolean;
  95229. private _useObjectSpaceNormalMap;
  95230. /**
  95231. * Allows using an object space normal map (instead of tangent space).
  95232. */
  95233. useObjectSpaceNormalMap: boolean;
  95234. private _useParallax;
  95235. /**
  95236. * Is parallax enabled or not.
  95237. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95238. */
  95239. useParallax: boolean;
  95240. private _useParallaxOcclusion;
  95241. /**
  95242. * Is parallax occlusion enabled or not.
  95243. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95244. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95245. */
  95246. useParallaxOcclusion: boolean;
  95247. /**
  95248. * 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.
  95249. */
  95250. parallaxScaleBias: number;
  95251. private _roughness;
  95252. /**
  95253. * Helps to define how blurry the reflections should appears in the material.
  95254. */
  95255. roughness: number;
  95256. /**
  95257. * In case of refraction, define the value of the indice of refraction.
  95258. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95259. */
  95260. indexOfRefraction: number;
  95261. /**
  95262. * Invert the refraction texture alongside the y axis.
  95263. * It can be useful with procedural textures or probe for instance.
  95264. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95265. */
  95266. invertRefractionY: boolean;
  95267. /**
  95268. * Defines the alpha limits in alpha test mode.
  95269. */
  95270. alphaCutOff: number;
  95271. private _useLightmapAsShadowmap;
  95272. /**
  95273. * In case of light mapping, define whether the map contains light or shadow informations.
  95274. */
  95275. useLightmapAsShadowmap: boolean;
  95276. private _diffuseFresnelParameters;
  95277. /**
  95278. * Define the diffuse fresnel parameters of the material.
  95279. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95280. */
  95281. diffuseFresnelParameters: FresnelParameters;
  95282. private _opacityFresnelParameters;
  95283. /**
  95284. * Define the opacity fresnel parameters of the material.
  95285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95286. */
  95287. opacityFresnelParameters: FresnelParameters;
  95288. private _reflectionFresnelParameters;
  95289. /**
  95290. * Define the reflection fresnel parameters of the material.
  95291. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95292. */
  95293. reflectionFresnelParameters: FresnelParameters;
  95294. private _refractionFresnelParameters;
  95295. /**
  95296. * Define the refraction fresnel parameters of the material.
  95297. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95298. */
  95299. refractionFresnelParameters: FresnelParameters;
  95300. private _emissiveFresnelParameters;
  95301. /**
  95302. * Define the emissive fresnel parameters of the material.
  95303. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95304. */
  95305. emissiveFresnelParameters: FresnelParameters;
  95306. private _useReflectionFresnelFromSpecular;
  95307. /**
  95308. * If true automatically deducts the fresnels values from the material specularity.
  95309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95310. */
  95311. useReflectionFresnelFromSpecular: boolean;
  95312. private _useGlossinessFromSpecularMapAlpha;
  95313. /**
  95314. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95315. */
  95316. useGlossinessFromSpecularMapAlpha: boolean;
  95317. private _maxSimultaneousLights;
  95318. /**
  95319. * Defines the maximum number of lights that can be used in the material
  95320. */
  95321. maxSimultaneousLights: number;
  95322. private _invertNormalMapX;
  95323. /**
  95324. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95325. */
  95326. invertNormalMapX: boolean;
  95327. private _invertNormalMapY;
  95328. /**
  95329. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95330. */
  95331. invertNormalMapY: boolean;
  95332. private _twoSidedLighting;
  95333. /**
  95334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95335. */
  95336. twoSidedLighting: boolean;
  95337. /**
  95338. * Default configuration related to image processing available in the standard Material.
  95339. */
  95340. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95341. /**
  95342. * Gets the image processing configuration used either in this material.
  95343. */
  95344. /**
  95345. * Sets the Default image processing configuration used either in the this material.
  95346. *
  95347. * If sets to null, the scene one is in use.
  95348. */
  95349. imageProcessingConfiguration: ImageProcessingConfiguration;
  95350. /**
  95351. * Keep track of the image processing observer to allow dispose and replace.
  95352. */
  95353. private _imageProcessingObserver;
  95354. /**
  95355. * Attaches a new image processing configuration to the Standard Material.
  95356. * @param configuration
  95357. */
  95358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95359. /**
  95360. * Gets wether the color curves effect is enabled.
  95361. */
  95362. /**
  95363. * Sets wether the color curves effect is enabled.
  95364. */
  95365. cameraColorCurvesEnabled: boolean;
  95366. /**
  95367. * Gets wether the color grading effect is enabled.
  95368. */
  95369. /**
  95370. * Gets wether the color grading effect is enabled.
  95371. */
  95372. cameraColorGradingEnabled: boolean;
  95373. /**
  95374. * Gets wether tonemapping is enabled or not.
  95375. */
  95376. /**
  95377. * Sets wether tonemapping is enabled or not
  95378. */
  95379. cameraToneMappingEnabled: boolean;
  95380. /**
  95381. * The camera exposure used on this material.
  95382. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95383. * This corresponds to a photographic exposure.
  95384. */
  95385. /**
  95386. * The camera exposure used on this material.
  95387. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95388. * This corresponds to a photographic exposure.
  95389. */
  95390. cameraExposure: number;
  95391. /**
  95392. * Gets The camera contrast used on this material.
  95393. */
  95394. /**
  95395. * Sets The camera contrast used on this material.
  95396. */
  95397. cameraContrast: number;
  95398. /**
  95399. * Gets the Color Grading 2D Lookup Texture.
  95400. */
  95401. /**
  95402. * Sets the Color Grading 2D Lookup Texture.
  95403. */
  95404. cameraColorGradingTexture: Nullable<BaseTexture>;
  95405. /**
  95406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95408. * 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;
  95409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95410. */
  95411. /**
  95412. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95413. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95414. * 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;
  95415. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95416. */
  95417. cameraColorCurves: Nullable<ColorCurves>;
  95418. /**
  95419. * Custom callback helping to override the default shader used in the material.
  95420. */
  95421. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95422. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95423. protected _worldViewProjectionMatrix: Matrix;
  95424. protected _globalAmbientColor: Color3;
  95425. protected _useLogarithmicDepth: boolean;
  95426. /**
  95427. * Instantiates a new standard material.
  95428. * This is the default material used in Babylon. It is the best trade off between quality
  95429. * and performances.
  95430. * @see http://doc.babylonjs.com/babylon101/materials
  95431. * @param name Define the name of the material in the scene
  95432. * @param scene Define the scene the material belong to
  95433. */
  95434. constructor(name: string, scene: Scene);
  95435. /**
  95436. * Gets a boolean indicating that current material needs to register RTT
  95437. */
  95438. readonly hasRenderTargetTextures: boolean;
  95439. /**
  95440. * Gets the current class name of the material e.g. "StandardMaterial"
  95441. * Mainly use in serialization.
  95442. * @returns the class name
  95443. */
  95444. getClassName(): string;
  95445. /**
  95446. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95447. * You can try switching to logarithmic depth.
  95448. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95449. */
  95450. useLogarithmicDepth: boolean;
  95451. /**
  95452. * Specifies if the material will require alpha blending
  95453. * @returns a boolean specifying if alpha blending is needed
  95454. */
  95455. needAlphaBlending(): boolean;
  95456. /**
  95457. * Specifies if this material should be rendered in alpha test mode
  95458. * @returns a boolean specifying if an alpha test is needed.
  95459. */
  95460. needAlphaTesting(): boolean;
  95461. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95462. /**
  95463. * Get the texture used for alpha test purpose.
  95464. * @returns the diffuse texture in case of the standard material.
  95465. */
  95466. getAlphaTestTexture(): Nullable<BaseTexture>;
  95467. /**
  95468. * Get if the submesh is ready to be used and all its information available.
  95469. * Child classes can use it to update shaders
  95470. * @param mesh defines the mesh to check
  95471. * @param subMesh defines which submesh to check
  95472. * @param useInstances specifies that instances should be used
  95473. * @returns a boolean indicating that the submesh is ready or not
  95474. */
  95475. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95476. /**
  95477. * Builds the material UBO layouts.
  95478. * Used internally during the effect preparation.
  95479. */
  95480. buildUniformLayout(): void;
  95481. /**
  95482. * Unbinds the material from the mesh
  95483. */
  95484. unbind(): void;
  95485. /**
  95486. * Binds the submesh to this material by preparing the effect and shader to draw
  95487. * @param world defines the world transformation matrix
  95488. * @param mesh defines the mesh containing the submesh
  95489. * @param subMesh defines the submesh to bind the material to
  95490. */
  95491. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95492. /**
  95493. * Get the list of animatables in the material.
  95494. * @returns the list of animatables object used in the material
  95495. */
  95496. getAnimatables(): IAnimatable[];
  95497. /**
  95498. * Gets the active textures from the material
  95499. * @returns an array of textures
  95500. */
  95501. getActiveTextures(): BaseTexture[];
  95502. /**
  95503. * Specifies if the material uses a texture
  95504. * @param texture defines the texture to check against the material
  95505. * @returns a boolean specifying if the material uses the texture
  95506. */
  95507. hasTexture(texture: BaseTexture): boolean;
  95508. /**
  95509. * Disposes the material
  95510. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95511. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95512. */
  95513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95514. /**
  95515. * Makes a duplicate of the material, and gives it a new name
  95516. * @param name defines the new name for the duplicated material
  95517. * @returns the cloned material
  95518. */
  95519. clone(name: string): StandardMaterial;
  95520. /**
  95521. * Serializes this material in a JSON representation
  95522. * @returns the serialized material object
  95523. */
  95524. serialize(): any;
  95525. /**
  95526. * Creates a standard material from parsed material data
  95527. * @param source defines the JSON representation of the material
  95528. * @param scene defines the hosting scene
  95529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95530. * @returns a new standard material
  95531. */
  95532. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95533. /**
  95534. * Are diffuse textures enabled in the application.
  95535. */
  95536. static DiffuseTextureEnabled: boolean;
  95537. /**
  95538. * Are ambient textures enabled in the application.
  95539. */
  95540. static AmbientTextureEnabled: boolean;
  95541. /**
  95542. * Are opacity textures enabled in the application.
  95543. */
  95544. static OpacityTextureEnabled: boolean;
  95545. /**
  95546. * Are reflection textures enabled in the application.
  95547. */
  95548. static ReflectionTextureEnabled: boolean;
  95549. /**
  95550. * Are emissive textures enabled in the application.
  95551. */
  95552. static EmissiveTextureEnabled: boolean;
  95553. /**
  95554. * Are specular textures enabled in the application.
  95555. */
  95556. static SpecularTextureEnabled: boolean;
  95557. /**
  95558. * Are bump textures enabled in the application.
  95559. */
  95560. static BumpTextureEnabled: boolean;
  95561. /**
  95562. * Are lightmap textures enabled in the application.
  95563. */
  95564. static LightmapTextureEnabled: boolean;
  95565. /**
  95566. * Are refraction textures enabled in the application.
  95567. */
  95568. static RefractionTextureEnabled: boolean;
  95569. /**
  95570. * Are color grading textures enabled in the application.
  95571. */
  95572. static ColorGradingTextureEnabled: boolean;
  95573. /**
  95574. * Are fresnels enabled in the application.
  95575. */
  95576. static FresnelEnabled: boolean;
  95577. }
  95578. }
  95579. declare module BABYLON {
  95580. /**
  95581. * A class extending Texture allowing drawing on a texture
  95582. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95583. */
  95584. export class DynamicTexture extends Texture {
  95585. private _generateMipMaps;
  95586. private _canvas;
  95587. private _context;
  95588. private _engine;
  95589. /**
  95590. * Creates a DynamicTexture
  95591. * @param name defines the name of the texture
  95592. * @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
  95593. * @param scene defines the scene where you want the texture
  95594. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95595. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95596. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95597. */
  95598. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95599. /**
  95600. * Get the current class name of the texture useful for serialization or dynamic coding.
  95601. * @returns "DynamicTexture"
  95602. */
  95603. getClassName(): string;
  95604. /**
  95605. * Gets the current state of canRescale
  95606. */
  95607. readonly canRescale: boolean;
  95608. private _recreate;
  95609. /**
  95610. * Scales the texture
  95611. * @param ratio the scale factor to apply to both width and height
  95612. */
  95613. scale(ratio: number): void;
  95614. /**
  95615. * Resizes the texture
  95616. * @param width the new width
  95617. * @param height the new height
  95618. */
  95619. scaleTo(width: number, height: number): void;
  95620. /**
  95621. * Gets the context of the canvas used by the texture
  95622. * @returns the canvas context of the dynamic texture
  95623. */
  95624. getContext(): CanvasRenderingContext2D;
  95625. /**
  95626. * Clears the texture
  95627. */
  95628. clear(): void;
  95629. /**
  95630. * Updates the texture
  95631. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95632. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95633. */
  95634. update(invertY?: boolean, premulAlpha?: boolean): void;
  95635. /**
  95636. * Draws text onto the texture
  95637. * @param text defines the text to be drawn
  95638. * @param x defines the placement of the text from the left
  95639. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95640. * @param font defines the font to be used with font-style, font-size, font-name
  95641. * @param color defines the color used for the text
  95642. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95643. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95644. * @param update defines whether texture is immediately update (default is true)
  95645. */
  95646. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95647. /**
  95648. * Clones the texture
  95649. * @returns the clone of the texture.
  95650. */
  95651. clone(): DynamicTexture;
  95652. /**
  95653. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95654. * @returns a serialized dynamic texture object
  95655. */
  95656. serialize(): any;
  95657. /** @hidden */
  95658. _rebuild(): void;
  95659. }
  95660. }
  95661. declare module BABYLON {
  95662. /** @hidden */
  95663. export var imageProcessingPixelShader: {
  95664. name: string;
  95665. shader: string;
  95666. };
  95667. }
  95668. declare module BABYLON {
  95669. /**
  95670. * ImageProcessingPostProcess
  95671. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95672. */
  95673. export class ImageProcessingPostProcess extends PostProcess {
  95674. /**
  95675. * Default configuration related to image processing available in the PBR Material.
  95676. */
  95677. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95678. /**
  95679. * Gets the image processing configuration used either in this material.
  95680. */
  95681. /**
  95682. * Sets the Default image processing configuration used either in the this material.
  95683. *
  95684. * If sets to null, the scene one is in use.
  95685. */
  95686. imageProcessingConfiguration: ImageProcessingConfiguration;
  95687. /**
  95688. * Keep track of the image processing observer to allow dispose and replace.
  95689. */
  95690. private _imageProcessingObserver;
  95691. /**
  95692. * Attaches a new image processing configuration to the PBR Material.
  95693. * @param configuration
  95694. */
  95695. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95696. /**
  95697. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95698. */
  95699. /**
  95700. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95701. */
  95702. colorCurves: Nullable<ColorCurves>;
  95703. /**
  95704. * Gets wether the color curves effect is enabled.
  95705. */
  95706. /**
  95707. * Sets wether the color curves effect is enabled.
  95708. */
  95709. colorCurvesEnabled: boolean;
  95710. /**
  95711. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95712. */
  95713. /**
  95714. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95715. */
  95716. colorGradingTexture: Nullable<BaseTexture>;
  95717. /**
  95718. * Gets wether the color grading effect is enabled.
  95719. */
  95720. /**
  95721. * Gets wether the color grading effect is enabled.
  95722. */
  95723. colorGradingEnabled: boolean;
  95724. /**
  95725. * Gets exposure used in the effect.
  95726. */
  95727. /**
  95728. * Sets exposure used in the effect.
  95729. */
  95730. exposure: number;
  95731. /**
  95732. * Gets wether tonemapping is enabled or not.
  95733. */
  95734. /**
  95735. * Sets wether tonemapping is enabled or not
  95736. */
  95737. toneMappingEnabled: boolean;
  95738. /**
  95739. * Gets the type of tone mapping effect.
  95740. */
  95741. /**
  95742. * Sets the type of tone mapping effect.
  95743. */
  95744. toneMappingType: number;
  95745. /**
  95746. * Gets contrast used in the effect.
  95747. */
  95748. /**
  95749. * Sets contrast used in the effect.
  95750. */
  95751. contrast: number;
  95752. /**
  95753. * Gets Vignette stretch size.
  95754. */
  95755. /**
  95756. * Sets Vignette stretch size.
  95757. */
  95758. vignetteStretch: number;
  95759. /**
  95760. * Gets Vignette centre X Offset.
  95761. */
  95762. /**
  95763. * Sets Vignette centre X Offset.
  95764. */
  95765. vignetteCentreX: number;
  95766. /**
  95767. * Gets Vignette centre Y Offset.
  95768. */
  95769. /**
  95770. * Sets Vignette centre Y Offset.
  95771. */
  95772. vignetteCentreY: number;
  95773. /**
  95774. * Gets Vignette weight or intensity of the vignette effect.
  95775. */
  95776. /**
  95777. * Sets Vignette weight or intensity of the vignette effect.
  95778. */
  95779. vignetteWeight: number;
  95780. /**
  95781. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95782. * if vignetteEnabled is set to true.
  95783. */
  95784. /**
  95785. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95786. * if vignetteEnabled is set to true.
  95787. */
  95788. vignetteColor: Color4;
  95789. /**
  95790. * Gets Camera field of view used by the Vignette effect.
  95791. */
  95792. /**
  95793. * Sets Camera field of view used by the Vignette effect.
  95794. */
  95795. vignetteCameraFov: number;
  95796. /**
  95797. * Gets the vignette blend mode allowing different kind of effect.
  95798. */
  95799. /**
  95800. * Sets the vignette blend mode allowing different kind of effect.
  95801. */
  95802. vignetteBlendMode: number;
  95803. /**
  95804. * Gets wether the vignette effect is enabled.
  95805. */
  95806. /**
  95807. * Sets wether the vignette effect is enabled.
  95808. */
  95809. vignetteEnabled: boolean;
  95810. private _fromLinearSpace;
  95811. /**
  95812. * Gets wether the input of the processing is in Gamma or Linear Space.
  95813. */
  95814. /**
  95815. * Sets wether the input of the processing is in Gamma or Linear Space.
  95816. */
  95817. fromLinearSpace: boolean;
  95818. /**
  95819. * Defines cache preventing GC.
  95820. */
  95821. private _defines;
  95822. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95823. /**
  95824. * "ImageProcessingPostProcess"
  95825. * @returns "ImageProcessingPostProcess"
  95826. */
  95827. getClassName(): string;
  95828. protected _updateParameters(): void;
  95829. dispose(camera?: Camera): void;
  95830. }
  95831. }
  95832. declare module BABYLON {
  95833. /**
  95834. * Class containing static functions to help procedurally build meshes
  95835. */
  95836. export class GroundBuilder {
  95837. /**
  95838. * Creates a ground mesh
  95839. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95840. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95842. * @param name defines the name of the mesh
  95843. * @param options defines the options used to create the mesh
  95844. * @param scene defines the hosting scene
  95845. * @returns the ground mesh
  95846. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95847. */
  95848. static CreateGround(name: string, options: {
  95849. width?: number;
  95850. height?: number;
  95851. subdivisions?: number;
  95852. subdivisionsX?: number;
  95853. subdivisionsY?: number;
  95854. updatable?: boolean;
  95855. }, scene: any): Mesh;
  95856. /**
  95857. * Creates a tiled ground mesh
  95858. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95859. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95860. * * 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
  95861. * * 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
  95862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95863. * @param name defines the name of the mesh
  95864. * @param options defines the options used to create the mesh
  95865. * @param scene defines the hosting scene
  95866. * @returns the tiled ground mesh
  95867. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95868. */
  95869. static CreateTiledGround(name: string, options: {
  95870. xmin: number;
  95871. zmin: number;
  95872. xmax: number;
  95873. zmax: number;
  95874. subdivisions?: {
  95875. w: number;
  95876. h: number;
  95877. };
  95878. precision?: {
  95879. w: number;
  95880. h: number;
  95881. };
  95882. updatable?: boolean;
  95883. }, scene: Scene): Mesh;
  95884. /**
  95885. * Creates a ground mesh from a height map
  95886. * * The parameter `url` sets the URL of the height map image resource.
  95887. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95888. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95889. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95890. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95891. * * 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.
  95892. * * 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).
  95893. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95895. * @param name defines the name of the mesh
  95896. * @param url defines the url to the height map
  95897. * @param options defines the options used to create the mesh
  95898. * @param scene defines the hosting scene
  95899. * @returns the ground mesh
  95900. * @see https://doc.babylonjs.com/babylon101/height_map
  95901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95902. */
  95903. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95904. width?: number;
  95905. height?: number;
  95906. subdivisions?: number;
  95907. minHeight?: number;
  95908. maxHeight?: number;
  95909. colorFilter?: Color3;
  95910. alphaFilter?: number;
  95911. updatable?: boolean;
  95912. onReady?: (mesh: GroundMesh) => void;
  95913. }, scene: Scene): GroundMesh;
  95914. }
  95915. }
  95916. declare module BABYLON {
  95917. /**
  95918. * Class containing static functions to help procedurally build meshes
  95919. */
  95920. export class TorusBuilder {
  95921. /**
  95922. * Creates a torus mesh
  95923. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95924. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95925. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95929. * @param name defines the name of the mesh
  95930. * @param options defines the options used to create the mesh
  95931. * @param scene defines the hosting scene
  95932. * @returns the torus mesh
  95933. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95934. */
  95935. static CreateTorus(name: string, options: {
  95936. diameter?: number;
  95937. thickness?: number;
  95938. tessellation?: number;
  95939. updatable?: boolean;
  95940. sideOrientation?: number;
  95941. frontUVs?: Vector4;
  95942. backUVs?: Vector4;
  95943. }, scene: any): Mesh;
  95944. }
  95945. }
  95946. declare module BABYLON {
  95947. /**
  95948. * Class containing static functions to help procedurally build meshes
  95949. */
  95950. export class CylinderBuilder {
  95951. /**
  95952. * Creates a cylinder or a cone mesh
  95953. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95954. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95955. * * 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.
  95956. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95957. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95958. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95959. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95960. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95961. * * 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).
  95962. * * 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
  95963. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95964. * * 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
  95965. * * 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.
  95966. * * If `enclose` is false, a ring surface is one element.
  95967. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95968. * * 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
  95969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95972. * @param name defines the name of the mesh
  95973. * @param options defines the options used to create the mesh
  95974. * @param scene defines the hosting scene
  95975. * @returns the cylinder mesh
  95976. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95977. */
  95978. static CreateCylinder(name: string, options: {
  95979. height?: number;
  95980. diameterTop?: number;
  95981. diameterBottom?: number;
  95982. diameter?: number;
  95983. tessellation?: number;
  95984. subdivisions?: number;
  95985. arc?: number;
  95986. faceColors?: Color4[];
  95987. faceUV?: Vector4[];
  95988. updatable?: boolean;
  95989. hasRings?: boolean;
  95990. enclose?: boolean;
  95991. sideOrientation?: number;
  95992. frontUVs?: Vector4;
  95993. backUVs?: Vector4;
  95994. }, scene: any): Mesh;
  95995. }
  95996. }
  95997. declare module BABYLON {
  95998. /**
  95999. * Manager for handling gamepads
  96000. */
  96001. export class GamepadManager {
  96002. private _scene?;
  96003. private _babylonGamepads;
  96004. private _oneGamepadConnected;
  96005. /** @hidden */
  96006. _isMonitoring: boolean;
  96007. private _gamepadEventSupported;
  96008. private _gamepadSupport;
  96009. /**
  96010. * observable to be triggered when the gamepad controller has been connected
  96011. */
  96012. onGamepadConnectedObservable: Observable<Gamepad>;
  96013. /**
  96014. * observable to be triggered when the gamepad controller has been disconnected
  96015. */
  96016. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96017. private _onGamepadConnectedEvent;
  96018. private _onGamepadDisconnectedEvent;
  96019. /**
  96020. * Initializes the gamepad manager
  96021. * @param _scene BabylonJS scene
  96022. */
  96023. constructor(_scene?: Scene | undefined);
  96024. /**
  96025. * The gamepads in the game pad manager
  96026. */
  96027. readonly gamepads: Gamepad[];
  96028. /**
  96029. * Get the gamepad controllers based on type
  96030. * @param type The type of gamepad controller
  96031. * @returns Nullable gamepad
  96032. */
  96033. getGamepadByType(type?: number): Nullable<Gamepad>;
  96034. /**
  96035. * Disposes the gamepad manager
  96036. */
  96037. dispose(): void;
  96038. private _addNewGamepad;
  96039. private _startMonitoringGamepads;
  96040. private _stopMonitoringGamepads;
  96041. /** @hidden */
  96042. _checkGamepadsStatus(): void;
  96043. private _updateGamepadObjects;
  96044. }
  96045. }
  96046. declare module BABYLON {
  96047. interface Scene {
  96048. /** @hidden */
  96049. _gamepadManager: Nullable<GamepadManager>;
  96050. /**
  96051. * Gets the gamepad manager associated with the scene
  96052. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96053. */
  96054. gamepadManager: GamepadManager;
  96055. }
  96056. /**
  96057. * Interface representing a free camera inputs manager
  96058. */
  96059. interface FreeCameraInputsManager {
  96060. /**
  96061. * Adds gamepad input support to the FreeCameraInputsManager.
  96062. * @returns the FreeCameraInputsManager
  96063. */
  96064. addGamepad(): FreeCameraInputsManager;
  96065. }
  96066. /**
  96067. * Interface representing an arc rotate camera inputs manager
  96068. */
  96069. interface ArcRotateCameraInputsManager {
  96070. /**
  96071. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96072. * @returns the camera inputs manager
  96073. */
  96074. addGamepad(): ArcRotateCameraInputsManager;
  96075. }
  96076. /**
  96077. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96078. */
  96079. export class GamepadSystemSceneComponent implements ISceneComponent {
  96080. /**
  96081. * The component name helpfull to identify the component in the list of scene components.
  96082. */
  96083. readonly name: string;
  96084. /**
  96085. * The scene the component belongs to.
  96086. */
  96087. scene: Scene;
  96088. /**
  96089. * Creates a new instance of the component for the given scene
  96090. * @param scene Defines the scene to register the component in
  96091. */
  96092. constructor(scene: Scene);
  96093. /**
  96094. * Registers the component in a given scene
  96095. */
  96096. register(): void;
  96097. /**
  96098. * Rebuilds the elements related to this component in case of
  96099. * context lost for instance.
  96100. */
  96101. rebuild(): void;
  96102. /**
  96103. * Disposes the component and the associated ressources
  96104. */
  96105. dispose(): void;
  96106. private _beforeCameraUpdate;
  96107. }
  96108. }
  96109. declare module BABYLON {
  96110. /**
  96111. * Options to modify the vr teleportation behavior.
  96112. */
  96113. export interface VRTeleportationOptions {
  96114. /**
  96115. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96116. */
  96117. floorMeshName?: string;
  96118. /**
  96119. * A list of meshes to be used as the teleportation floor. (default: empty)
  96120. */
  96121. floorMeshes?: Mesh[];
  96122. }
  96123. /**
  96124. * Options to modify the vr experience helper's behavior.
  96125. */
  96126. export interface VRExperienceHelperOptions extends WebVROptions {
  96127. /**
  96128. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96129. */
  96130. createDeviceOrientationCamera?: boolean;
  96131. /**
  96132. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96133. */
  96134. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96135. /**
  96136. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96137. */
  96138. laserToggle?: boolean;
  96139. /**
  96140. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96141. */
  96142. floorMeshes?: Mesh[];
  96143. /**
  96144. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96145. */
  96146. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96147. }
  96148. /**
  96149. * Event containing information after VR has been entered
  96150. */
  96151. export class OnAfterEnteringVRObservableEvent {
  96152. /**
  96153. * If entering vr was successful
  96154. */
  96155. success: boolean;
  96156. }
  96157. /**
  96158. * Helps to quickly add VR support to an existing scene.
  96159. * See http://doc.babylonjs.com/how_to/webvr_helper
  96160. */
  96161. export class VRExperienceHelper {
  96162. /** Options to modify the vr experience helper's behavior. */
  96163. webVROptions: VRExperienceHelperOptions;
  96164. private _scene;
  96165. private _position;
  96166. private _btnVR;
  96167. private _btnVRDisplayed;
  96168. private _webVRsupported;
  96169. private _webVRready;
  96170. private _webVRrequesting;
  96171. private _webVRpresenting;
  96172. private _hasEnteredVR;
  96173. private _fullscreenVRpresenting;
  96174. private _canvas;
  96175. private _webVRCamera;
  96176. private _vrDeviceOrientationCamera;
  96177. private _deviceOrientationCamera;
  96178. private _existingCamera;
  96179. private _onKeyDown;
  96180. private _onVrDisplayPresentChange;
  96181. private _onVRDisplayChanged;
  96182. private _onVRRequestPresentStart;
  96183. private _onVRRequestPresentComplete;
  96184. /**
  96185. * Observable raised right before entering VR.
  96186. */
  96187. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96188. /**
  96189. * Observable raised when entering VR has completed.
  96190. */
  96191. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96192. /**
  96193. * Observable raised when exiting VR.
  96194. */
  96195. onExitingVRObservable: Observable<VRExperienceHelper>;
  96196. /**
  96197. * Observable raised when controller mesh is loaded.
  96198. */
  96199. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96200. /** Return this.onEnteringVRObservable
  96201. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96202. */
  96203. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96204. /** Return this.onExitingVRObservable
  96205. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96206. */
  96207. readonly onExitingVR: Observable<VRExperienceHelper>;
  96208. /** Return this.onControllerMeshLoadedObservable
  96209. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96210. */
  96211. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96212. private _rayLength;
  96213. private _useCustomVRButton;
  96214. private _teleportationRequested;
  96215. private _teleportActive;
  96216. private _floorMeshName;
  96217. private _floorMeshesCollection;
  96218. private _rotationAllowed;
  96219. private _teleportBackwardsVector;
  96220. private _teleportationTarget;
  96221. private _isDefaultTeleportationTarget;
  96222. private _postProcessMove;
  96223. private _teleportationFillColor;
  96224. private _teleportationBorderColor;
  96225. private _rotationAngle;
  96226. private _haloCenter;
  96227. private _cameraGazer;
  96228. private _padSensibilityUp;
  96229. private _padSensibilityDown;
  96230. private _leftController;
  96231. private _rightController;
  96232. /**
  96233. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96234. */
  96235. onNewMeshSelected: Observable<AbstractMesh>;
  96236. /**
  96237. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96238. */
  96239. onNewMeshPicked: Observable<PickingInfo>;
  96240. private _circleEase;
  96241. /**
  96242. * Observable raised before camera teleportation
  96243. */
  96244. onBeforeCameraTeleport: Observable<Vector3>;
  96245. /**
  96246. * Observable raised after camera teleportation
  96247. */
  96248. onAfterCameraTeleport: Observable<Vector3>;
  96249. /**
  96250. * Observable raised when current selected mesh gets unselected
  96251. */
  96252. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96253. private _raySelectionPredicate;
  96254. /**
  96255. * To be optionaly changed by user to define custom ray selection
  96256. */
  96257. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96258. /**
  96259. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96260. */
  96261. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96262. /**
  96263. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96264. */
  96265. teleportationEnabled: boolean;
  96266. private _defaultHeight;
  96267. private _teleportationInitialized;
  96268. private _interactionsEnabled;
  96269. private _interactionsRequested;
  96270. private _displayGaze;
  96271. private _displayLaserPointer;
  96272. /**
  96273. * The mesh used to display where the user is going to teleport.
  96274. */
  96275. /**
  96276. * Sets the mesh to be used to display where the user is going to teleport.
  96277. */
  96278. teleportationTarget: Mesh;
  96279. /**
  96280. * 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
  96281. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96282. * See http://doc.babylonjs.com/resources/baking_transformations
  96283. */
  96284. gazeTrackerMesh: Mesh;
  96285. /**
  96286. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96287. */
  96288. updateGazeTrackerScale: boolean;
  96289. /**
  96290. * If the gaze trackers color should be updated when selecting meshes
  96291. */
  96292. updateGazeTrackerColor: boolean;
  96293. /**
  96294. * The gaze tracking mesh corresponding to the left controller
  96295. */
  96296. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96297. /**
  96298. * The gaze tracking mesh corresponding to the right controller
  96299. */
  96300. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96301. /**
  96302. * If the ray of the gaze should be displayed.
  96303. */
  96304. /**
  96305. * Sets if the ray of the gaze should be displayed.
  96306. */
  96307. displayGaze: boolean;
  96308. /**
  96309. * If the ray of the LaserPointer should be displayed.
  96310. */
  96311. /**
  96312. * Sets if the ray of the LaserPointer should be displayed.
  96313. */
  96314. displayLaserPointer: boolean;
  96315. /**
  96316. * The deviceOrientationCamera used as the camera when not in VR.
  96317. */
  96318. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96319. /**
  96320. * Based on the current WebVR support, returns the current VR camera used.
  96321. */
  96322. readonly currentVRCamera: Nullable<Camera>;
  96323. /**
  96324. * The webVRCamera which is used when in VR.
  96325. */
  96326. readonly webVRCamera: WebVRFreeCamera;
  96327. /**
  96328. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96329. */
  96330. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96331. private readonly _teleportationRequestInitiated;
  96332. /**
  96333. * Defines wether or not Pointer lock should be requested when switching to
  96334. * full screen.
  96335. */
  96336. requestPointerLockOnFullScreen: boolean;
  96337. /**
  96338. * Instantiates a VRExperienceHelper.
  96339. * Helps to quickly add VR support to an existing scene.
  96340. * @param scene The scene the VRExperienceHelper belongs to.
  96341. * @param webVROptions Options to modify the vr experience helper's behavior.
  96342. */
  96343. constructor(scene: Scene,
  96344. /** Options to modify the vr experience helper's behavior. */
  96345. webVROptions?: VRExperienceHelperOptions);
  96346. private _onDefaultMeshLoaded;
  96347. private _onResize;
  96348. private _onFullscreenChange;
  96349. /**
  96350. * Gets a value indicating if we are currently in VR mode.
  96351. */
  96352. readonly isInVRMode: boolean;
  96353. private onVrDisplayPresentChange;
  96354. private onVRDisplayChanged;
  96355. private moveButtonToBottomRight;
  96356. private displayVRButton;
  96357. private updateButtonVisibility;
  96358. private _cachedAngularSensibility;
  96359. /**
  96360. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96361. * Otherwise, will use the fullscreen API.
  96362. */
  96363. enterVR(): void;
  96364. /**
  96365. * Attempt to exit VR, or fullscreen.
  96366. */
  96367. exitVR(): void;
  96368. /**
  96369. * The position of the vr experience helper.
  96370. */
  96371. /**
  96372. * Sets the position of the vr experience helper.
  96373. */
  96374. position: Vector3;
  96375. /**
  96376. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96377. */
  96378. enableInteractions(): void;
  96379. private readonly _noControllerIsActive;
  96380. private beforeRender;
  96381. private _isTeleportationFloor;
  96382. /**
  96383. * Adds a floor mesh to be used for teleportation.
  96384. * @param floorMesh the mesh to be used for teleportation.
  96385. */
  96386. addFloorMesh(floorMesh: Mesh): void;
  96387. /**
  96388. * Removes a floor mesh from being used for teleportation.
  96389. * @param floorMesh the mesh to be removed.
  96390. */
  96391. removeFloorMesh(floorMesh: Mesh): void;
  96392. /**
  96393. * Enables interactions and teleportation using the VR controllers and gaze.
  96394. * @param vrTeleportationOptions options to modify teleportation behavior.
  96395. */
  96396. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96397. private _onNewGamepadConnected;
  96398. private _tryEnableInteractionOnController;
  96399. private _onNewGamepadDisconnected;
  96400. private _enableInteractionOnController;
  96401. private _checkTeleportWithRay;
  96402. private _checkRotate;
  96403. private _checkTeleportBackwards;
  96404. private _enableTeleportationOnController;
  96405. private _createTeleportationCircles;
  96406. private _displayTeleportationTarget;
  96407. private _hideTeleportationTarget;
  96408. private _rotateCamera;
  96409. private _moveTeleportationSelectorTo;
  96410. private _workingVector;
  96411. private _workingQuaternion;
  96412. private _workingMatrix;
  96413. /**
  96414. * Teleports the users feet to the desired location
  96415. * @param location The location where the user's feet should be placed
  96416. */
  96417. teleportCamera(location: Vector3): void;
  96418. private _convertNormalToDirectionOfRay;
  96419. private _castRayAndSelectObject;
  96420. private _notifySelectedMeshUnselected;
  96421. /**
  96422. * Sets the color of the laser ray from the vr controllers.
  96423. * @param color new color for the ray.
  96424. */
  96425. changeLaserColor(color: Color3): void;
  96426. /**
  96427. * Sets the color of the ray from the vr headsets gaze.
  96428. * @param color new color for the ray.
  96429. */
  96430. changeGazeColor(color: Color3): void;
  96431. /**
  96432. * Exits VR and disposes of the vr experience helper
  96433. */
  96434. dispose(): void;
  96435. /**
  96436. * Gets the name of the VRExperienceHelper class
  96437. * @returns "VRExperienceHelper"
  96438. */
  96439. getClassName(): string;
  96440. }
  96441. }
  96442. declare module BABYLON {
  96443. /**
  96444. * Manages an XRSession
  96445. * @see https://doc.babylonjs.com/how_to/webxr
  96446. */
  96447. export class WebXRSessionManager implements IDisposable {
  96448. private scene;
  96449. /**
  96450. * Fires every time a new xrFrame arrives which can be used to update the camera
  96451. */
  96452. onXRFrameObservable: Observable<any>;
  96453. /**
  96454. * Fires when the xr session is ended either by the device or manually done
  96455. */
  96456. onXRSessionEnded: Observable<any>;
  96457. /** @hidden */
  96458. _xrSession: XRSession;
  96459. /** @hidden */
  96460. _frameOfReference: XRFrameOfReference;
  96461. /** @hidden */
  96462. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96463. /** @hidden */
  96464. _currentXRFrame: Nullable<XRFrame>;
  96465. private _xrNavigator;
  96466. private _xrDevice;
  96467. private _tmpMatrix;
  96468. /**
  96469. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96470. * @param scene The scene which the session should be created for
  96471. */
  96472. constructor(scene: Scene);
  96473. /**
  96474. * Initializes the manager
  96475. * After initialization enterXR can be called to start an XR session
  96476. * @returns Promise which resolves after it is initialized
  96477. */
  96478. initializeAsync(): Promise<void>;
  96479. /**
  96480. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96481. * @param sessionCreationOptions xr options to create the session with
  96482. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96483. * @returns Promise which resolves after it enters XR
  96484. */
  96485. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96486. /**
  96487. * Stops the xrSession and restores the renderloop
  96488. * @returns Promise which resolves after it exits XR
  96489. */
  96490. exitXRAsync(): Promise<void>;
  96491. /**
  96492. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96493. * @param ray ray to cast into the environment
  96494. * @returns Promise which resolves with a collision point in the environment if it exists
  96495. */
  96496. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96497. /**
  96498. * Checks if a session would be supported for the creation options specified
  96499. * @param options creation options to check if they are supported
  96500. * @returns true if supported
  96501. */
  96502. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96503. /**
  96504. * @hidden
  96505. * Converts the render layer of xrSession to a render target
  96506. * @param session session to create render target for
  96507. * @param scene scene the new render target should be created for
  96508. */
  96509. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96510. /**
  96511. * Disposes of the session manager
  96512. */
  96513. dispose(): void;
  96514. }
  96515. }
  96516. declare module BABYLON {
  96517. /**
  96518. * WebXR Camera which holds the views for the xrSession
  96519. * @see https://doc.babylonjs.com/how_to/webxr
  96520. */
  96521. export class WebXRCamera extends FreeCamera {
  96522. private static _TmpMatrix;
  96523. /**
  96524. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96525. * @param name the name of the camera
  96526. * @param scene the scene to add the camera to
  96527. */
  96528. constructor(name: string, scene: Scene);
  96529. private _updateNumberOfRigCameras;
  96530. /** @hidden */
  96531. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96532. /**
  96533. * Updates the cameras position from the current pose information of the XR session
  96534. * @param xrSessionManager the session containing pose information
  96535. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96536. */
  96537. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96538. }
  96539. }
  96540. declare module BABYLON {
  96541. /**
  96542. * States of the webXR experience
  96543. */
  96544. export enum WebXRState {
  96545. /**
  96546. * Transitioning to being in XR mode
  96547. */
  96548. ENTERING_XR = 0,
  96549. /**
  96550. * Transitioning to non XR mode
  96551. */
  96552. EXITING_XR = 1,
  96553. /**
  96554. * In XR mode and presenting
  96555. */
  96556. IN_XR = 2,
  96557. /**
  96558. * Not entered XR mode
  96559. */
  96560. NOT_IN_XR = 3
  96561. }
  96562. /**
  96563. * Helper class used to enable XR
  96564. * @see https://doc.babylonjs.com/how_to/webxr
  96565. */
  96566. export class WebXRExperienceHelper implements IDisposable {
  96567. private scene;
  96568. /**
  96569. * 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
  96570. */
  96571. container: AbstractMesh;
  96572. /**
  96573. * Camera used to render xr content
  96574. */
  96575. camera: WebXRCamera;
  96576. /**
  96577. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96578. */
  96579. state: WebXRState;
  96580. private _setState;
  96581. private static _TmpVector;
  96582. /**
  96583. * Fires when the state of the experience helper has changed
  96584. */
  96585. onStateChangedObservable: Observable<WebXRState>;
  96586. /** @hidden */
  96587. _sessionManager: WebXRSessionManager;
  96588. private _nonVRCamera;
  96589. private _originalSceneAutoClear;
  96590. private _supported;
  96591. /**
  96592. * Creates the experience helper
  96593. * @param scene the scene to attach the experience helper to
  96594. * @returns a promise for the experience helper
  96595. */
  96596. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96597. /**
  96598. * Creates a WebXRExperienceHelper
  96599. * @param scene The scene the helper should be created in
  96600. */
  96601. private constructor();
  96602. /**
  96603. * Exits XR mode and returns the scene to its original state
  96604. * @returns promise that resolves after xr mode has exited
  96605. */
  96606. exitXRAsync(): Promise<void>;
  96607. /**
  96608. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96609. * @param sessionCreationOptions options for the XR session
  96610. * @param frameOfReference frame of reference of the XR session
  96611. * @returns promise that resolves after xr mode has entered
  96612. */
  96613. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96614. /**
  96615. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96616. * @param ray ray to cast into the environment
  96617. * @returns Promise which resolves with a collision point in the environment if it exists
  96618. */
  96619. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96620. /**
  96621. * Updates the global position of the camera by moving the camera's container
  96622. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96623. * @param position The desired global position of the camera
  96624. */
  96625. setPositionOfCameraUsingContainer(position: Vector3): void;
  96626. /**
  96627. * Rotates the xr camera by rotating the camera's container around the camera's position
  96628. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96629. * @param rotation the desired quaternion rotation to apply to the camera
  96630. */
  96631. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96632. /**
  96633. * Checks if the creation options are supported by the xr session
  96634. * @param options creation options
  96635. * @returns true if supported
  96636. */
  96637. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96638. /**
  96639. * Disposes of the experience helper
  96640. */
  96641. dispose(): void;
  96642. }
  96643. }
  96644. declare module BABYLON {
  96645. /**
  96646. * Button which can be used to enter a different mode of XR
  96647. */
  96648. export class WebXREnterExitUIButton {
  96649. /** button element */
  96650. element: HTMLElement;
  96651. /** XR initialization options for the button */
  96652. initializationOptions: XRSessionCreationOptions;
  96653. /**
  96654. * Creates a WebXREnterExitUIButton
  96655. * @param element button element
  96656. * @param initializationOptions XR initialization options for the button
  96657. */
  96658. constructor(
  96659. /** button element */
  96660. element: HTMLElement,
  96661. /** XR initialization options for the button */
  96662. initializationOptions: XRSessionCreationOptions);
  96663. /**
  96664. * Overwritable function which can be used to update the button's visuals when the state changes
  96665. * @param activeButton the current active button in the UI
  96666. */
  96667. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96668. }
  96669. /**
  96670. * Options to create the webXR UI
  96671. */
  96672. export class WebXREnterExitUIOptions {
  96673. /**
  96674. * Context to enter xr with
  96675. */
  96676. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96677. /**
  96678. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96679. */
  96680. customButtons?: Array<WebXREnterExitUIButton>;
  96681. }
  96682. /**
  96683. * UI to allow the user to enter/exit XR mode
  96684. */
  96685. export class WebXREnterExitUI implements IDisposable {
  96686. private scene;
  96687. private _overlay;
  96688. private _buttons;
  96689. private _activeButton;
  96690. /**
  96691. * Fired every time the active button is changed.
  96692. *
  96693. * When xr is entered via a button that launches xr that button will be the callback parameter
  96694. *
  96695. * When exiting xr the callback parameter will be null)
  96696. */
  96697. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96698. /**
  96699. * Creates UI to allow the user to enter/exit XR mode
  96700. * @param scene the scene to add the ui to
  96701. * @param helper the xr experience helper to enter/exit xr with
  96702. * @param options options to configure the UI
  96703. * @returns the created ui
  96704. */
  96705. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96706. private constructor();
  96707. private _updateButtons;
  96708. /**
  96709. * Disposes of the object
  96710. */
  96711. dispose(): void;
  96712. }
  96713. }
  96714. declare module BABYLON {
  96715. /**
  96716. * Represents an XR input
  96717. */
  96718. export class WebXRController {
  96719. /**
  96720. * 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
  96721. */
  96722. grip?: AbstractMesh;
  96723. /**
  96724. * Pointer which can be used to select objects or attach a visible laser to
  96725. */
  96726. pointer: AbstractMesh;
  96727. /**
  96728. * Creates the controller
  96729. * @see https://doc.babylonjs.com/how_to/webxr
  96730. * @param scene the scene which the controller should be associated to
  96731. */
  96732. constructor(scene: Scene);
  96733. /**
  96734. * Disposes of the object
  96735. */
  96736. dispose(): void;
  96737. }
  96738. /**
  96739. * XR input used to track XR inputs such as controllers/rays
  96740. */
  96741. export class WebXRInput implements IDisposable {
  96742. private helper;
  96743. /**
  96744. * XR controllers being tracked
  96745. */
  96746. controllers: Array<WebXRController>;
  96747. private _tmpMatrix;
  96748. private _frameObserver;
  96749. /**
  96750. * Initializes the WebXRInput
  96751. * @param helper experience helper which the input should be created for
  96752. */
  96753. constructor(helper: WebXRExperienceHelper);
  96754. /**
  96755. * Disposes of the object
  96756. */
  96757. dispose(): void;
  96758. }
  96759. }
  96760. declare module BABYLON {
  96761. /**
  96762. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96763. */
  96764. export class WebXRManagedOutputCanvas implements IDisposable {
  96765. private _canvas;
  96766. /**
  96767. * xrpresent context of the canvas which can be used to display/mirror xr content
  96768. */
  96769. canvasContext: Nullable<WebGLRenderingContext>;
  96770. /**
  96771. * Initializes the canvas to be added/removed upon entering/exiting xr
  96772. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96773. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96774. */
  96775. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96776. /**
  96777. * Disposes of the object
  96778. */
  96779. dispose(): void;
  96780. private _setManagedOutputCanvas;
  96781. private _addCanvas;
  96782. private _removeCanvas;
  96783. }
  96784. }
  96785. declare module BABYLON {
  96786. /**
  96787. * Contains an array of blocks representing the octree
  96788. */
  96789. export interface IOctreeContainer<T> {
  96790. /**
  96791. * Blocks within the octree
  96792. */
  96793. blocks: Array<OctreeBlock<T>>;
  96794. }
  96795. /**
  96796. * Class used to store a cell in an octree
  96797. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96798. */
  96799. export class OctreeBlock<T> {
  96800. /**
  96801. * Gets the content of the current block
  96802. */
  96803. entries: T[];
  96804. /**
  96805. * Gets the list of block children
  96806. */
  96807. blocks: Array<OctreeBlock<T>>;
  96808. private _depth;
  96809. private _maxDepth;
  96810. private _capacity;
  96811. private _minPoint;
  96812. private _maxPoint;
  96813. private _boundingVectors;
  96814. private _creationFunc;
  96815. /**
  96816. * Creates a new block
  96817. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96818. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96819. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96820. * @param depth defines the current depth of this block in the octree
  96821. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96822. * @param creationFunc defines a callback to call when an element is added to the block
  96823. */
  96824. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96825. /**
  96826. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96827. */
  96828. readonly capacity: number;
  96829. /**
  96830. * Gets the minimum vector (in world space) of the block's bounding box
  96831. */
  96832. readonly minPoint: Vector3;
  96833. /**
  96834. * Gets the maximum vector (in world space) of the block's bounding box
  96835. */
  96836. readonly maxPoint: Vector3;
  96837. /**
  96838. * Add a new element to this block
  96839. * @param entry defines the element to add
  96840. */
  96841. addEntry(entry: T): void;
  96842. /**
  96843. * Remove an element from this block
  96844. * @param entry defines the element to remove
  96845. */
  96846. removeEntry(entry: T): void;
  96847. /**
  96848. * Add an array of elements to this block
  96849. * @param entries defines the array of elements to add
  96850. */
  96851. addEntries(entries: T[]): void;
  96852. /**
  96853. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96854. * @param frustumPlanes defines the frustum planes to test
  96855. * @param selection defines the array to store current content if selection is positive
  96856. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96857. */
  96858. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96859. /**
  96860. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96861. * @param sphereCenter defines the bounding sphere center
  96862. * @param sphereRadius defines the bounding sphere radius
  96863. * @param selection defines the array to store current content if selection is positive
  96864. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96865. */
  96866. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96867. /**
  96868. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96869. * @param ray defines the ray to test with
  96870. * @param selection defines the array to store current content if selection is positive
  96871. */
  96872. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96873. /**
  96874. * Subdivide the content into child blocks (this block will then be empty)
  96875. */
  96876. createInnerBlocks(): void;
  96877. /**
  96878. * @hidden
  96879. */
  96880. 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;
  96881. }
  96882. }
  96883. declare module BABYLON {
  96884. /**
  96885. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96886. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96887. */
  96888. export class Octree<T> {
  96889. /** 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.) */
  96890. maxDepth: number;
  96891. /**
  96892. * Blocks within the octree containing objects
  96893. */
  96894. blocks: Array<OctreeBlock<T>>;
  96895. /**
  96896. * Content stored in the octree
  96897. */
  96898. dynamicContent: T[];
  96899. private _maxBlockCapacity;
  96900. private _selectionContent;
  96901. private _creationFunc;
  96902. /**
  96903. * Creates a octree
  96904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96905. * @param creationFunc function to be used to instatiate the octree
  96906. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96907. * @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.)
  96908. */
  96909. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96910. /** 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.) */
  96911. maxDepth?: number);
  96912. /**
  96913. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96914. * @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);
  96915. * @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);
  96916. * @param entries meshes to be added to the octree blocks
  96917. */
  96918. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96919. /**
  96920. * Adds a mesh to the octree
  96921. * @param entry Mesh to add to the octree
  96922. */
  96923. addMesh(entry: T): void;
  96924. /**
  96925. * Remove an element from the octree
  96926. * @param entry defines the element to remove
  96927. */
  96928. removeMesh(entry: T): void;
  96929. /**
  96930. * Selects an array of meshes within the frustum
  96931. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96932. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96933. * @returns array of meshes within the frustum
  96934. */
  96935. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96936. /**
  96937. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96938. * @param sphereCenter defines the bounding sphere center
  96939. * @param sphereRadius defines the bounding sphere radius
  96940. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96941. * @returns an array of objects that intersect the sphere
  96942. */
  96943. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96944. /**
  96945. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96946. * @param ray defines the ray to test with
  96947. * @returns array of intersected objects
  96948. */
  96949. intersectsRay(ray: Ray): SmartArray<T>;
  96950. /**
  96951. * Adds a mesh into the octree block if it intersects the block
  96952. */
  96953. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96954. /**
  96955. * Adds a submesh into the octree block if it intersects the block
  96956. */
  96957. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96958. }
  96959. }
  96960. declare module BABYLON {
  96961. interface Scene {
  96962. /**
  96963. * @hidden
  96964. * Backing Filed
  96965. */
  96966. _selectionOctree: Octree<AbstractMesh>;
  96967. /**
  96968. * Gets the octree used to boost mesh selection (picking)
  96969. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96970. */
  96971. selectionOctree: Octree<AbstractMesh>;
  96972. /**
  96973. * Creates or updates the octree used to boost selection (picking)
  96974. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96975. * @param maxCapacity defines the maximum capacity per leaf
  96976. * @param maxDepth defines the maximum depth of the octree
  96977. * @returns an octree of AbstractMesh
  96978. */
  96979. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96980. }
  96981. interface AbstractMesh {
  96982. /**
  96983. * @hidden
  96984. * Backing Field
  96985. */
  96986. _submeshesOctree: Octree<SubMesh>;
  96987. /**
  96988. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96989. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96990. * @param maxCapacity defines the maximum size of each block (64 by default)
  96991. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96992. * @returns the new octree
  96993. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96995. */
  96996. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96997. }
  96998. /**
  96999. * Defines the octree scene component responsible to manage any octrees
  97000. * in a given scene.
  97001. */
  97002. export class OctreeSceneComponent {
  97003. /**
  97004. * The component name helpfull to identify the component in the list of scene components.
  97005. */
  97006. readonly name: string;
  97007. /**
  97008. * The scene the component belongs to.
  97009. */
  97010. scene: Scene;
  97011. /**
  97012. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97013. */
  97014. readonly checksIsEnabled: boolean;
  97015. /**
  97016. * Creates a new instance of the component for the given scene
  97017. * @param scene Defines the scene to register the component in
  97018. */
  97019. constructor(scene: Scene);
  97020. /**
  97021. * Registers the component in a given scene
  97022. */
  97023. register(): void;
  97024. /**
  97025. * Return the list of active meshes
  97026. * @returns the list of active meshes
  97027. */
  97028. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97029. /**
  97030. * Return the list of active sub meshes
  97031. * @param mesh The mesh to get the candidates sub meshes from
  97032. * @returns the list of active sub meshes
  97033. */
  97034. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97035. private _tempRay;
  97036. /**
  97037. * Return the list of sub meshes intersecting with a given local ray
  97038. * @param mesh defines the mesh to find the submesh for
  97039. * @param localRay defines the ray in local space
  97040. * @returns the list of intersecting sub meshes
  97041. */
  97042. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97043. /**
  97044. * Return the list of sub meshes colliding with a collider
  97045. * @param mesh defines the mesh to find the submesh for
  97046. * @param collider defines the collider to evaluate the collision against
  97047. * @returns the list of colliding sub meshes
  97048. */
  97049. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97050. /**
  97051. * Rebuilds the elements related to this component in case of
  97052. * context lost for instance.
  97053. */
  97054. rebuild(): void;
  97055. /**
  97056. * Disposes the component and the associated ressources.
  97057. */
  97058. dispose(): void;
  97059. }
  97060. }
  97061. declare module BABYLON {
  97062. /**
  97063. * Class containing static functions to help procedurally build meshes
  97064. */
  97065. export class LinesBuilder {
  97066. /**
  97067. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97068. * * 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
  97069. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97070. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97071. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97072. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97073. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97074. * * 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
  97075. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97078. * @param name defines the name of the new line system
  97079. * @param options defines the options used to create the line system
  97080. * @param scene defines the hosting scene
  97081. * @returns a new line system mesh
  97082. */
  97083. static CreateLineSystem(name: string, options: {
  97084. lines: Vector3[][];
  97085. updatable?: boolean;
  97086. instance?: Nullable<LinesMesh>;
  97087. colors?: Nullable<Color4[][]>;
  97088. useVertexAlpha?: boolean;
  97089. }, scene: Nullable<Scene>): LinesMesh;
  97090. /**
  97091. * Creates a line mesh
  97092. * 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
  97093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97094. * * The parameter `points` is an array successive Vector3
  97095. * * 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
  97096. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97098. * * When updating an instance, remember that only point positions can change, not the number of points
  97099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97101. * @param name defines the name of the new line system
  97102. * @param options defines the options used to create the line system
  97103. * @param scene defines the hosting scene
  97104. * @returns a new line mesh
  97105. */
  97106. static CreateLines(name: string, options: {
  97107. points: Vector3[];
  97108. updatable?: boolean;
  97109. instance?: Nullable<LinesMesh>;
  97110. colors?: Color4[];
  97111. useVertexAlpha?: boolean;
  97112. }, scene?: Nullable<Scene>): LinesMesh;
  97113. /**
  97114. * Creates a dashed line mesh
  97115. * * 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
  97116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97117. * * The parameter `points` is an array successive Vector3
  97118. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97119. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97120. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97121. * * 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
  97122. * * When updating an instance, remember that only point positions can change, not the number of points
  97123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97124. * @param name defines the name of the mesh
  97125. * @param options defines the options used to create the mesh
  97126. * @param scene defines the hosting scene
  97127. * @returns the dashed line mesh
  97128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97129. */
  97130. static CreateDashedLines(name: string, options: {
  97131. points: Vector3[];
  97132. dashSize?: number;
  97133. gapSize?: number;
  97134. dashNb?: number;
  97135. updatable?: boolean;
  97136. instance?: LinesMesh;
  97137. }, scene?: Nullable<Scene>): LinesMesh;
  97138. }
  97139. }
  97140. declare module BABYLON {
  97141. /**
  97142. * Renders a layer on top of an existing scene
  97143. */
  97144. export class UtilityLayerRenderer implements IDisposable {
  97145. /** the original scene that will be rendered on top of */
  97146. originalScene: Scene;
  97147. private _pointerCaptures;
  97148. private _lastPointerEvents;
  97149. private static _DefaultUtilityLayer;
  97150. private static _DefaultKeepDepthUtilityLayer;
  97151. /**
  97152. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97153. */
  97154. pickUtilitySceneFirst: boolean;
  97155. /**
  97156. * 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)
  97157. */
  97158. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97159. /**
  97160. * 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)
  97161. */
  97162. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97163. /**
  97164. * The scene that is rendered on top of the original scene
  97165. */
  97166. utilityLayerScene: Scene;
  97167. /**
  97168. * If the utility layer should automatically be rendered on top of existing scene
  97169. */
  97170. shouldRender: boolean;
  97171. /**
  97172. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97173. */
  97174. onlyCheckPointerDownEvents: boolean;
  97175. /**
  97176. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97177. */
  97178. processAllEvents: boolean;
  97179. /**
  97180. * Observable raised when the pointer move from the utility layer scene to the main scene
  97181. */
  97182. onPointerOutObservable: Observable<number>;
  97183. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97184. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97185. private _afterRenderObserver;
  97186. private _sceneDisposeObserver;
  97187. private _originalPointerObserver;
  97188. /**
  97189. * Instantiates a UtilityLayerRenderer
  97190. * @param originalScene the original scene that will be rendered on top of
  97191. * @param handleEvents boolean indicating if the utility layer should handle events
  97192. */
  97193. constructor(
  97194. /** the original scene that will be rendered on top of */
  97195. originalScene: Scene, handleEvents?: boolean);
  97196. private _notifyObservers;
  97197. /**
  97198. * Renders the utility layers scene on top of the original scene
  97199. */
  97200. render(): void;
  97201. /**
  97202. * Disposes of the renderer
  97203. */
  97204. dispose(): void;
  97205. private _updateCamera;
  97206. }
  97207. }
  97208. declare module BABYLON {
  97209. /**
  97210. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97211. */
  97212. export class Gizmo implements IDisposable {
  97213. /** The utility layer the gizmo will be added to */
  97214. gizmoLayer: UtilityLayerRenderer;
  97215. /**
  97216. * The root mesh of the gizmo
  97217. */
  97218. _rootMesh: Mesh;
  97219. private _attachedMesh;
  97220. /**
  97221. * Ratio for the scale of the gizmo (Default: 1)
  97222. */
  97223. scaleRatio: number;
  97224. private _tmpMatrix;
  97225. /**
  97226. * If a custom mesh has been set (Default: false)
  97227. */
  97228. protected _customMeshSet: boolean;
  97229. /**
  97230. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97231. * * When set, interactions will be enabled
  97232. */
  97233. attachedMesh: Nullable<AbstractMesh>;
  97234. /**
  97235. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97236. * @param mesh The mesh to replace the default mesh of the gizmo
  97237. */
  97238. setCustomMesh(mesh: Mesh): void;
  97239. /**
  97240. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97241. */
  97242. updateGizmoRotationToMatchAttachedMesh: boolean;
  97243. /**
  97244. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97245. */
  97246. updateGizmoPositionToMatchAttachedMesh: boolean;
  97247. /**
  97248. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97249. */
  97250. protected _updateScale: boolean;
  97251. protected _interactionsEnabled: boolean;
  97252. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97253. private _beforeRenderObserver;
  97254. /**
  97255. * Creates a gizmo
  97256. * @param gizmoLayer The utility layer the gizmo will be added to
  97257. */
  97258. constructor(
  97259. /** The utility layer the gizmo will be added to */
  97260. gizmoLayer?: UtilityLayerRenderer);
  97261. private _tempVector;
  97262. /**
  97263. * @hidden
  97264. * Updates the gizmo to match the attached mesh's position/rotation
  97265. */
  97266. protected _update(): void;
  97267. /**
  97268. * Disposes of the gizmo
  97269. */
  97270. dispose(): void;
  97271. }
  97272. }
  97273. declare module BABYLON {
  97274. /**
  97275. * Single axis drag gizmo
  97276. */
  97277. export class AxisDragGizmo extends Gizmo {
  97278. /**
  97279. * Drag behavior responsible for the gizmos dragging interactions
  97280. */
  97281. dragBehavior: PointerDragBehavior;
  97282. private _pointerObserver;
  97283. /**
  97284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97285. */
  97286. snapDistance: number;
  97287. /**
  97288. * Event that fires each time the gizmo snaps to a new location.
  97289. * * snapDistance is the the change in distance
  97290. */
  97291. onSnapObservable: Observable<{
  97292. snapDistance: number;
  97293. }>;
  97294. /** @hidden */
  97295. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97296. /** @hidden */
  97297. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97298. /**
  97299. * Creates an AxisDragGizmo
  97300. * @param gizmoLayer The utility layer the gizmo will be added to
  97301. * @param dragAxis The axis which the gizmo will be able to drag on
  97302. * @param color The color of the gizmo
  97303. */
  97304. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97305. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97306. /**
  97307. * Disposes of the gizmo
  97308. */
  97309. dispose(): void;
  97310. }
  97311. }
  97312. declare module BABYLON.Debug {
  97313. /**
  97314. * The Axes viewer will show 3 axes in a specific point in space
  97315. */
  97316. export class AxesViewer {
  97317. private _xAxis;
  97318. private _yAxis;
  97319. private _zAxis;
  97320. private _scaleLinesFactor;
  97321. private _instanced;
  97322. /**
  97323. * Gets the hosting scene
  97324. */
  97325. scene: Scene;
  97326. /**
  97327. * Gets or sets a number used to scale line length
  97328. */
  97329. scaleLines: number;
  97330. /** Gets the node hierarchy used to render x-axis */
  97331. readonly xAxis: TransformNode;
  97332. /** Gets the node hierarchy used to render y-axis */
  97333. readonly yAxis: TransformNode;
  97334. /** Gets the node hierarchy used to render z-axis */
  97335. readonly zAxis: TransformNode;
  97336. /**
  97337. * Creates a new AxesViewer
  97338. * @param scene defines the hosting scene
  97339. * @param scaleLines defines a number used to scale line length (1 by default)
  97340. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97341. * @param xAxis defines the node hierarchy used to render the x-axis
  97342. * @param yAxis defines the node hierarchy used to render the y-axis
  97343. * @param zAxis defines the node hierarchy used to render the z-axis
  97344. */
  97345. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97346. /**
  97347. * Force the viewer to update
  97348. * @param position defines the position of the viewer
  97349. * @param xaxis defines the x axis of the viewer
  97350. * @param yaxis defines the y axis of the viewer
  97351. * @param zaxis defines the z axis of the viewer
  97352. */
  97353. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97354. /**
  97355. * Creates an instance of this axes viewer.
  97356. * @returns a new axes viewer with instanced meshes
  97357. */
  97358. createInstance(): AxesViewer;
  97359. /** Releases resources */
  97360. dispose(): void;
  97361. private static _SetRenderingGroupId;
  97362. }
  97363. }
  97364. declare module BABYLON.Debug {
  97365. /**
  97366. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97367. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97368. */
  97369. export class BoneAxesViewer extends AxesViewer {
  97370. /**
  97371. * Gets or sets the target mesh where to display the axes viewer
  97372. */
  97373. mesh: Nullable<Mesh>;
  97374. /**
  97375. * Gets or sets the target bone where to display the axes viewer
  97376. */
  97377. bone: Nullable<Bone>;
  97378. /** Gets current position */
  97379. pos: Vector3;
  97380. /** Gets direction of X axis */
  97381. xaxis: Vector3;
  97382. /** Gets direction of Y axis */
  97383. yaxis: Vector3;
  97384. /** Gets direction of Z axis */
  97385. zaxis: Vector3;
  97386. /**
  97387. * Creates a new BoneAxesViewer
  97388. * @param scene defines the hosting scene
  97389. * @param bone defines the target bone
  97390. * @param mesh defines the target mesh
  97391. * @param scaleLines defines a scaling factor for line length (1 by default)
  97392. */
  97393. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97394. /**
  97395. * Force the viewer to update
  97396. */
  97397. update(): void;
  97398. /** Releases resources */
  97399. dispose(): void;
  97400. }
  97401. }
  97402. declare module BABYLON {
  97403. /**
  97404. * Interface used to define scene explorer extensibility option
  97405. */
  97406. export interface IExplorerExtensibilityOption {
  97407. /**
  97408. * Define the option label
  97409. */
  97410. label: string;
  97411. /**
  97412. * Defines the action to execute on click
  97413. */
  97414. action: (entity: any) => void;
  97415. }
  97416. /**
  97417. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97418. */
  97419. export interface IExplorerExtensibilityGroup {
  97420. /**
  97421. * Defines a predicate to test if a given type mut be extended
  97422. */
  97423. predicate: (entity: any) => boolean;
  97424. /**
  97425. * Gets the list of options added to a type
  97426. */
  97427. entries: IExplorerExtensibilityOption[];
  97428. }
  97429. /**
  97430. * Interface used to define the options to use to create the Inspector
  97431. */
  97432. export interface IInspectorOptions {
  97433. /**
  97434. * Display in overlay mode (default: false)
  97435. */
  97436. overlay?: boolean;
  97437. /**
  97438. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97439. */
  97440. globalRoot?: HTMLElement;
  97441. /**
  97442. * Display the Scene explorer
  97443. */
  97444. showExplorer?: boolean;
  97445. /**
  97446. * Display the property inspector
  97447. */
  97448. showInspector?: boolean;
  97449. /**
  97450. * Display in embed mode (both panes on the right)
  97451. */
  97452. embedMode?: boolean;
  97453. /**
  97454. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97455. */
  97456. handleResize?: boolean;
  97457. /**
  97458. * Allow the panes to popup (default: true)
  97459. */
  97460. enablePopup?: boolean;
  97461. /**
  97462. * Allow the panes to be closed by users (default: true)
  97463. */
  97464. enableClose?: boolean;
  97465. /**
  97466. * Optional list of extensibility entries
  97467. */
  97468. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97469. /**
  97470. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97471. */
  97472. inspectorURL?: string;
  97473. }
  97474. interface Scene {
  97475. /**
  97476. * @hidden
  97477. * Backing field
  97478. */
  97479. _debugLayer: DebugLayer;
  97480. /**
  97481. * Gets the debug layer (aka Inspector) associated with the scene
  97482. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97483. */
  97484. debugLayer: DebugLayer;
  97485. }
  97486. /**
  97487. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97488. * what is happening in your scene
  97489. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97490. */
  97491. export class DebugLayer {
  97492. /**
  97493. * Define the url to get the inspector script from.
  97494. * By default it uses the babylonjs CDN.
  97495. * @ignoreNaming
  97496. */
  97497. static InspectorURL: string;
  97498. private _scene;
  97499. private BJSINSPECTOR;
  97500. /**
  97501. * Observable triggered when a property is changed through the inspector.
  97502. */
  97503. onPropertyChangedObservable: Observable<{
  97504. object: any;
  97505. property: string;
  97506. value: any;
  97507. initialValue: any;
  97508. }>;
  97509. /**
  97510. * Instantiates a new debug layer.
  97511. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97512. * what is happening in your scene
  97513. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97514. * @param scene Defines the scene to inspect
  97515. */
  97516. constructor(scene: Scene);
  97517. /** Creates the inspector window. */
  97518. private _createInspector;
  97519. /**
  97520. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97521. * @param entity defines the entity to select
  97522. * @param lineContainerTitle defines the specific block to highlight
  97523. */
  97524. select(entity: any, lineContainerTitle?: string): void;
  97525. /** Get the inspector from bundle or global */
  97526. private _getGlobalInspector;
  97527. /**
  97528. * Get if the inspector is visible or not.
  97529. * @returns true if visible otherwise, false
  97530. */
  97531. isVisible(): boolean;
  97532. /**
  97533. * Hide the inspector and close its window.
  97534. */
  97535. hide(): void;
  97536. /**
  97537. * Launch the debugLayer.
  97538. * @param config Define the configuration of the inspector
  97539. * @return a promise fulfilled when the debug layer is visible
  97540. */
  97541. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97542. }
  97543. }
  97544. declare module BABYLON {
  97545. /**
  97546. * Class containing static functions to help procedurally build meshes
  97547. */
  97548. export class BoxBuilder {
  97549. /**
  97550. * Creates a box mesh
  97551. * * The parameter `size` sets the size (float) of each box side (default 1)
  97552. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97553. * * 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)
  97554. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97558. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97559. * @param name defines the name of the mesh
  97560. * @param options defines the options used to create the mesh
  97561. * @param scene defines the hosting scene
  97562. * @returns the box mesh
  97563. */
  97564. static CreateBox(name: string, options: {
  97565. size?: number;
  97566. width?: number;
  97567. height?: number;
  97568. depth?: number;
  97569. faceUV?: Vector4[];
  97570. faceColors?: Color4[];
  97571. sideOrientation?: number;
  97572. frontUVs?: Vector4;
  97573. backUVs?: Vector4;
  97574. updatable?: boolean;
  97575. }, scene?: Nullable<Scene>): Mesh;
  97576. }
  97577. }
  97578. declare module BABYLON {
  97579. /**
  97580. * Class containing static functions to help procedurally build meshes
  97581. */
  97582. export class SphereBuilder {
  97583. /**
  97584. * Creates a sphere mesh
  97585. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97586. * * 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`)
  97587. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97588. * * 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
  97589. * * 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)
  97590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97593. * @param name defines the name of the mesh
  97594. * @param options defines the options used to create the mesh
  97595. * @param scene defines the hosting scene
  97596. * @returns the sphere mesh
  97597. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97598. */
  97599. static CreateSphere(name: string, options: {
  97600. segments?: number;
  97601. diameter?: number;
  97602. diameterX?: number;
  97603. diameterY?: number;
  97604. diameterZ?: number;
  97605. arc?: number;
  97606. slice?: number;
  97607. sideOrientation?: number;
  97608. frontUVs?: Vector4;
  97609. backUVs?: Vector4;
  97610. updatable?: boolean;
  97611. }, scene: any): Mesh;
  97612. }
  97613. }
  97614. declare module BABYLON.Debug {
  97615. /**
  97616. * Used to show the physics impostor around the specific mesh
  97617. */
  97618. export class PhysicsViewer {
  97619. /** @hidden */
  97620. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97621. /** @hidden */
  97622. protected _meshes: Array<Nullable<AbstractMesh>>;
  97623. /** @hidden */
  97624. protected _scene: Nullable<Scene>;
  97625. /** @hidden */
  97626. protected _numMeshes: number;
  97627. /** @hidden */
  97628. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97629. private _renderFunction;
  97630. private _utilityLayer;
  97631. private _debugBoxMesh;
  97632. private _debugSphereMesh;
  97633. private _debugMaterial;
  97634. /**
  97635. * Creates a new PhysicsViewer
  97636. * @param scene defines the hosting scene
  97637. */
  97638. constructor(scene: Scene);
  97639. /** @hidden */
  97640. protected _updateDebugMeshes(): void;
  97641. /**
  97642. * Renders a specified physic impostor
  97643. * @param impostor defines the impostor to render
  97644. * @returns the new debug mesh used to render the impostor
  97645. */
  97646. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97647. /**
  97648. * Hides a specified physic impostor
  97649. * @param impostor defines the impostor to hide
  97650. */
  97651. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97652. private _getDebugMaterial;
  97653. private _getDebugBoxMesh;
  97654. private _getDebugSphereMesh;
  97655. private _getDebugMesh;
  97656. /** Releases all resources */
  97657. dispose(): void;
  97658. }
  97659. }
  97660. declare module BABYLON {
  97661. /**
  97662. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97663. * in order to better appreciate the issue one might have.
  97664. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97665. */
  97666. export class RayHelper {
  97667. /**
  97668. * Defines the ray we are currently tryin to visualize.
  97669. */
  97670. ray: Nullable<Ray>;
  97671. private _renderPoints;
  97672. private _renderLine;
  97673. private _renderFunction;
  97674. private _scene;
  97675. private _updateToMeshFunction;
  97676. private _attachedToMesh;
  97677. private _meshSpaceDirection;
  97678. private _meshSpaceOrigin;
  97679. /**
  97680. * Helper function to create a colored helper in a scene in one line.
  97681. * @param ray Defines the ray we are currently tryin to visualize
  97682. * @param scene Defines the scene the ray is used in
  97683. * @param color Defines the color we want to see the ray in
  97684. * @returns The newly created ray helper.
  97685. */
  97686. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97687. /**
  97688. * Instantiate a new ray helper.
  97689. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97690. * in order to better appreciate the issue one might have.
  97691. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97692. * @param ray Defines the ray we are currently tryin to visualize
  97693. */
  97694. constructor(ray: Ray);
  97695. /**
  97696. * Shows the ray we are willing to debug.
  97697. * @param scene Defines the scene the ray needs to be rendered in
  97698. * @param color Defines the color the ray needs to be rendered in
  97699. */
  97700. show(scene: Scene, color?: Color3): void;
  97701. /**
  97702. * Hides the ray we are debugging.
  97703. */
  97704. hide(): void;
  97705. private _render;
  97706. /**
  97707. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97708. * @param mesh Defines the mesh we want the helper attached to
  97709. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97710. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97711. * @param length Defines the length of the ray
  97712. */
  97713. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97714. /**
  97715. * Detach the ray helper from the mesh it has previously been attached to.
  97716. */
  97717. detachFromMesh(): void;
  97718. private _updateToMesh;
  97719. /**
  97720. * Dispose the helper and release its associated resources.
  97721. */
  97722. dispose(): void;
  97723. }
  97724. }
  97725. declare module BABYLON.Debug {
  97726. /**
  97727. * Class used to render a debug view of a given skeleton
  97728. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97729. */
  97730. export class SkeletonViewer {
  97731. /** defines the skeleton to render */
  97732. skeleton: Skeleton;
  97733. /** defines the mesh attached to the skeleton */
  97734. mesh: AbstractMesh;
  97735. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97736. autoUpdateBonesMatrices: boolean;
  97737. /** defines the rendering group id to use with the viewer */
  97738. renderingGroupId: number;
  97739. /** Gets or sets the color used to render the skeleton */
  97740. color: Color3;
  97741. private _scene;
  97742. private _debugLines;
  97743. private _debugMesh;
  97744. private _isEnabled;
  97745. private _renderFunction;
  97746. private _utilityLayer;
  97747. /**
  97748. * Returns the mesh used to render the bones
  97749. */
  97750. readonly debugMesh: Nullable<LinesMesh>;
  97751. /**
  97752. * Creates a new SkeletonViewer
  97753. * @param skeleton defines the skeleton to render
  97754. * @param mesh defines the mesh attached to the skeleton
  97755. * @param scene defines the hosting scene
  97756. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97757. * @param renderingGroupId defines the rendering group id to use with the viewer
  97758. */
  97759. constructor(
  97760. /** defines the skeleton to render */
  97761. skeleton: Skeleton,
  97762. /** defines the mesh attached to the skeleton */
  97763. mesh: AbstractMesh, scene: Scene,
  97764. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97765. autoUpdateBonesMatrices?: boolean,
  97766. /** defines the rendering group id to use with the viewer */
  97767. renderingGroupId?: number);
  97768. /** Gets or sets a boolean indicating if the viewer is enabled */
  97769. isEnabled: boolean;
  97770. private _getBonePosition;
  97771. private _getLinesForBonesWithLength;
  97772. private _getLinesForBonesNoLength;
  97773. /** Update the viewer to sync with current skeleton state */
  97774. update(): void;
  97775. /** Release associated resources */
  97776. dispose(): void;
  97777. }
  97778. }
  97779. declare module BABYLON {
  97780. /**
  97781. * Options to create the null engine
  97782. */
  97783. export class NullEngineOptions {
  97784. /**
  97785. * Render width (Default: 512)
  97786. */
  97787. renderWidth: number;
  97788. /**
  97789. * Render height (Default: 256)
  97790. */
  97791. renderHeight: number;
  97792. /**
  97793. * Texture size (Default: 512)
  97794. */
  97795. textureSize: number;
  97796. /**
  97797. * If delta time between frames should be constant
  97798. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97799. */
  97800. deterministicLockstep: boolean;
  97801. /**
  97802. * Maximum about of steps between frames (Default: 4)
  97803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97804. */
  97805. lockstepMaxSteps: number;
  97806. }
  97807. /**
  97808. * The null engine class provides support for headless version of babylon.js.
  97809. * This can be used in server side scenario or for testing purposes
  97810. */
  97811. export class NullEngine extends Engine {
  97812. private _options;
  97813. /**
  97814. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97815. */
  97816. isDeterministicLockStep(): boolean;
  97817. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97818. getLockstepMaxSteps(): number;
  97819. /**
  97820. * Sets hardware scaling, used to save performance if needed
  97821. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97822. */
  97823. getHardwareScalingLevel(): number;
  97824. constructor(options?: NullEngineOptions);
  97825. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97826. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97827. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97828. getRenderWidth(useScreen?: boolean): number;
  97829. getRenderHeight(useScreen?: boolean): number;
  97830. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97831. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97832. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97833. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97834. bindSamplers(effect: Effect): void;
  97835. enableEffect(effect: Effect): void;
  97836. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97837. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97838. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97839. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97840. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97841. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97842. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97843. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97844. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97845. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97846. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97847. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97848. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97849. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97850. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97851. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97852. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97853. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97854. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97855. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97856. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97857. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97858. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97859. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97860. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97861. bindBuffers(vertexBuffers: {
  97862. [key: string]: VertexBuffer;
  97863. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97864. wipeCaches(bruteForce?: boolean): void;
  97865. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97866. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97867. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97868. /** @hidden */
  97869. _createTexture(): WebGLTexture;
  97870. /** @hidden */
  97871. _releaseTexture(texture: InternalTexture): void;
  97872. 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;
  97873. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97874. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97875. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97876. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97877. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97878. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97879. areAllEffectsReady(): boolean;
  97880. /**
  97881. * @hidden
  97882. * Get the current error code of the webGL context
  97883. * @returns the error code
  97884. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97885. */
  97886. getError(): number;
  97887. /** @hidden */
  97888. _getUnpackAlignement(): number;
  97889. /** @hidden */
  97890. _unpackFlipY(value: boolean): void;
  97891. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97892. /**
  97893. * Updates a dynamic vertex buffer.
  97894. * @param vertexBuffer the vertex buffer to update
  97895. * @param data the data used to update the vertex buffer
  97896. * @param byteOffset the byte offset of the data (optional)
  97897. * @param byteLength the byte length of the data (optional)
  97898. */
  97899. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97900. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97901. /** @hidden */
  97902. _bindTexture(channel: number, texture: InternalTexture): void;
  97903. /** @hidden */
  97904. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97905. releaseEffects(): void;
  97906. displayLoadingUI(): void;
  97907. hideLoadingUI(): void;
  97908. /** @hidden */
  97909. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97910. /** @hidden */
  97911. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97912. /** @hidden */
  97913. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97914. /** @hidden */
  97915. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97916. }
  97917. }
  97918. declare module BABYLON {
  97919. /** @hidden */
  97920. export class _OcclusionDataStorage {
  97921. /** @hidden */
  97922. occlusionInternalRetryCounter: number;
  97923. /** @hidden */
  97924. isOcclusionQueryInProgress: boolean;
  97925. /** @hidden */
  97926. isOccluded: boolean;
  97927. /** @hidden */
  97928. occlusionRetryCount: number;
  97929. /** @hidden */
  97930. occlusionType: number;
  97931. /** @hidden */
  97932. occlusionQueryAlgorithmType: number;
  97933. }
  97934. interface Engine {
  97935. /**
  97936. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97937. * @return the new query
  97938. */
  97939. createQuery(): WebGLQuery;
  97940. /**
  97941. * Delete and release a webGL query
  97942. * @param query defines the query to delete
  97943. * @return the current engine
  97944. */
  97945. deleteQuery(query: WebGLQuery): Engine;
  97946. /**
  97947. * Check if a given query has resolved and got its value
  97948. * @param query defines the query to check
  97949. * @returns true if the query got its value
  97950. */
  97951. isQueryResultAvailable(query: WebGLQuery): boolean;
  97952. /**
  97953. * Gets the value of a given query
  97954. * @param query defines the query to check
  97955. * @returns the value of the query
  97956. */
  97957. getQueryResult(query: WebGLQuery): number;
  97958. /**
  97959. * Initiates an occlusion query
  97960. * @param algorithmType defines the algorithm to use
  97961. * @param query defines the query to use
  97962. * @returns the current engine
  97963. * @see http://doc.babylonjs.com/features/occlusionquery
  97964. */
  97965. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97966. /**
  97967. * Ends an occlusion query
  97968. * @see http://doc.babylonjs.com/features/occlusionquery
  97969. * @param algorithmType defines the algorithm to use
  97970. * @returns the current engine
  97971. */
  97972. endOcclusionQuery(algorithmType: number): Engine;
  97973. /**
  97974. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97975. * Please note that only one query can be issued at a time
  97976. * @returns a time token used to track the time span
  97977. */
  97978. startTimeQuery(): Nullable<_TimeToken>;
  97979. /**
  97980. * Ends a time query
  97981. * @param token defines the token used to measure the time span
  97982. * @returns the time spent (in ns)
  97983. */
  97984. endTimeQuery(token: _TimeToken): int;
  97985. /** @hidden */
  97986. _currentNonTimestampToken: Nullable<_TimeToken>;
  97987. /** @hidden */
  97988. _createTimeQuery(): WebGLQuery;
  97989. /** @hidden */
  97990. _deleteTimeQuery(query: WebGLQuery): void;
  97991. /** @hidden */
  97992. _getGlAlgorithmType(algorithmType: number): number;
  97993. /** @hidden */
  97994. _getTimeQueryResult(query: WebGLQuery): any;
  97995. /** @hidden */
  97996. _getTimeQueryAvailability(query: WebGLQuery): any;
  97997. }
  97998. interface AbstractMesh {
  97999. /**
  98000. * Backing filed
  98001. * @hidden
  98002. */
  98003. __occlusionDataStorage: _OcclusionDataStorage;
  98004. /**
  98005. * Access property
  98006. * @hidden
  98007. */
  98008. _occlusionDataStorage: _OcclusionDataStorage;
  98009. /**
  98010. * 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.
  98011. * The default value is -1 which means don't break the query and wait till the result
  98012. * @see http://doc.babylonjs.com/features/occlusionquery
  98013. */
  98014. occlusionRetryCount: number;
  98015. /**
  98016. * 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:
  98017. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98018. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98019. * * 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.
  98020. * @see http://doc.babylonjs.com/features/occlusionquery
  98021. */
  98022. occlusionType: number;
  98023. /**
  98024. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98025. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98026. * * 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.
  98027. * @see http://doc.babylonjs.com/features/occlusionquery
  98028. */
  98029. occlusionQueryAlgorithmType: number;
  98030. /**
  98031. * 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
  98032. * @see http://doc.babylonjs.com/features/occlusionquery
  98033. */
  98034. isOccluded: boolean;
  98035. /**
  98036. * Flag to check the progress status of the query
  98037. * @see http://doc.babylonjs.com/features/occlusionquery
  98038. */
  98039. isOcclusionQueryInProgress: boolean;
  98040. }
  98041. }
  98042. declare module BABYLON {
  98043. /** @hidden */
  98044. export var _forceTransformFeedbackToBundle: boolean;
  98045. interface Engine {
  98046. /**
  98047. * Creates a webGL transform feedback object
  98048. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98049. * @returns the webGL transform feedback object
  98050. */
  98051. createTransformFeedback(): WebGLTransformFeedback;
  98052. /**
  98053. * Delete a webGL transform feedback object
  98054. * @param value defines the webGL transform feedback object to delete
  98055. */
  98056. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98057. /**
  98058. * Bind a webGL transform feedback object to the webgl context
  98059. * @param value defines the webGL transform feedback object to bind
  98060. */
  98061. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98062. /**
  98063. * Begins a transform feedback operation
  98064. * @param usePoints defines if points or triangles must be used
  98065. */
  98066. beginTransformFeedback(usePoints: boolean): void;
  98067. /**
  98068. * Ends a transform feedback operation
  98069. */
  98070. endTransformFeedback(): void;
  98071. /**
  98072. * Specify the varyings to use with transform feedback
  98073. * @param program defines the associated webGL program
  98074. * @param value defines the list of strings representing the varying names
  98075. */
  98076. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98077. /**
  98078. * Bind a webGL buffer for a transform feedback operation
  98079. * @param value defines the webGL buffer to bind
  98080. */
  98081. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98082. }
  98083. }
  98084. declare module BABYLON {
  98085. /**
  98086. * Gather the list of clipboard event types as constants.
  98087. */
  98088. export class ClipboardEventTypes {
  98089. /**
  98090. * The clipboard event is fired when a copy command is active (pressed).
  98091. */
  98092. static readonly COPY: number;
  98093. /**
  98094. * The clipboard event is fired when a cut command is active (pressed).
  98095. */
  98096. static readonly CUT: number;
  98097. /**
  98098. * The clipboard event is fired when a paste command is active (pressed).
  98099. */
  98100. static readonly PASTE: number;
  98101. }
  98102. /**
  98103. * This class is used to store clipboard related info for the onClipboardObservable event.
  98104. */
  98105. export class ClipboardInfo {
  98106. /**
  98107. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98108. */
  98109. type: number;
  98110. /**
  98111. * Defines the related dom event
  98112. */
  98113. event: ClipboardEvent;
  98114. /**
  98115. *Creates an instance of ClipboardInfo.
  98116. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98117. * @param event Defines the related dom event
  98118. */
  98119. constructor(
  98120. /**
  98121. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98122. */
  98123. type: number,
  98124. /**
  98125. * Defines the related dom event
  98126. */
  98127. event: ClipboardEvent);
  98128. /**
  98129. * Get the clipboard event's type from the keycode.
  98130. * @param keyCode Defines the keyCode for the current keyboard event.
  98131. * @return {number}
  98132. */
  98133. static GetTypeFromCharacter(keyCode: number): number;
  98134. }
  98135. }
  98136. declare module BABYLON {
  98137. /**
  98138. * Class used to represent data loading progression
  98139. */
  98140. export class SceneLoaderProgressEvent {
  98141. /** defines if data length to load can be evaluated */
  98142. readonly lengthComputable: boolean;
  98143. /** defines the loaded data length */
  98144. readonly loaded: number;
  98145. /** defines the data length to load */
  98146. readonly total: number;
  98147. /**
  98148. * Create a new progress event
  98149. * @param lengthComputable defines if data length to load can be evaluated
  98150. * @param loaded defines the loaded data length
  98151. * @param total defines the data length to load
  98152. */
  98153. constructor(
  98154. /** defines if data length to load can be evaluated */
  98155. lengthComputable: boolean,
  98156. /** defines the loaded data length */
  98157. loaded: number,
  98158. /** defines the data length to load */
  98159. total: number);
  98160. /**
  98161. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98162. * @param event defines the source event
  98163. * @returns a new SceneLoaderProgressEvent
  98164. */
  98165. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98166. }
  98167. /**
  98168. * Interface used by SceneLoader plugins to define supported file extensions
  98169. */
  98170. export interface ISceneLoaderPluginExtensions {
  98171. /**
  98172. * Defines the list of supported extensions
  98173. */
  98174. [extension: string]: {
  98175. isBinary: boolean;
  98176. };
  98177. }
  98178. /**
  98179. * Interface used by SceneLoader plugin factory
  98180. */
  98181. export interface ISceneLoaderPluginFactory {
  98182. /**
  98183. * Defines the name of the factory
  98184. */
  98185. name: string;
  98186. /**
  98187. * Function called to create a new plugin
  98188. * @return the new plugin
  98189. */
  98190. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98191. /**
  98192. * Boolean indicating if the plugin can direct load specific data
  98193. */
  98194. canDirectLoad?: (data: string) => boolean;
  98195. }
  98196. /**
  98197. * Interface used to define a SceneLoader plugin
  98198. */
  98199. export interface ISceneLoaderPlugin {
  98200. /**
  98201. * The friendly name of this plugin.
  98202. */
  98203. name: string;
  98204. /**
  98205. * The file extensions supported by this plugin.
  98206. */
  98207. extensions: string | ISceneLoaderPluginExtensions;
  98208. /**
  98209. * Import meshes into a scene.
  98210. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98211. * @param scene The scene to import into
  98212. * @param data The data to import
  98213. * @param rootUrl The root url for scene and resources
  98214. * @param meshes The meshes array to import into
  98215. * @param particleSystems The particle systems array to import into
  98216. * @param skeletons The skeletons array to import into
  98217. * @param onError The callback when import fails
  98218. * @returns True if successful or false otherwise
  98219. */
  98220. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98221. /**
  98222. * Load into a scene.
  98223. * @param scene The scene to load into
  98224. * @param data The data to import
  98225. * @param rootUrl The root url for scene and resources
  98226. * @param onError The callback when import fails
  98227. * @returns true if successful or false otherwise
  98228. */
  98229. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98230. /**
  98231. * The callback that returns true if the data can be directly loaded.
  98232. */
  98233. canDirectLoad?: (data: string) => boolean;
  98234. /**
  98235. * The callback that allows custom handling of the root url based on the response url.
  98236. */
  98237. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98238. /**
  98239. * Load into an asset container.
  98240. * @param scene The scene to load into
  98241. * @param data The data to import
  98242. * @param rootUrl The root url for scene and resources
  98243. * @param onError The callback when import fails
  98244. * @returns The loaded asset container
  98245. */
  98246. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98247. }
  98248. /**
  98249. * Interface used to define an async SceneLoader plugin
  98250. */
  98251. export interface ISceneLoaderPluginAsync {
  98252. /**
  98253. * The friendly name of this plugin.
  98254. */
  98255. name: string;
  98256. /**
  98257. * The file extensions supported by this plugin.
  98258. */
  98259. extensions: string | ISceneLoaderPluginExtensions;
  98260. /**
  98261. * Import meshes into a scene.
  98262. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98263. * @param scene The scene to import into
  98264. * @param data The data to import
  98265. * @param rootUrl The root url for scene and resources
  98266. * @param onProgress The callback when the load progresses
  98267. * @param fileName Defines the name of the file to load
  98268. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98269. */
  98270. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98271. meshes: AbstractMesh[];
  98272. particleSystems: IParticleSystem[];
  98273. skeletons: Skeleton[];
  98274. animationGroups: AnimationGroup[];
  98275. }>;
  98276. /**
  98277. * Load into a scene.
  98278. * @param scene The scene to load into
  98279. * @param data The data to import
  98280. * @param rootUrl The root url for scene and resources
  98281. * @param onProgress The callback when the load progresses
  98282. * @param fileName Defines the name of the file to load
  98283. * @returns Nothing
  98284. */
  98285. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98286. /**
  98287. * The callback that returns true if the data can be directly loaded.
  98288. */
  98289. canDirectLoad?: (data: string) => boolean;
  98290. /**
  98291. * The callback that allows custom handling of the root url based on the response url.
  98292. */
  98293. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98294. /**
  98295. * Load into an asset container.
  98296. * @param scene The scene to load into
  98297. * @param data The data to import
  98298. * @param rootUrl The root url for scene and resources
  98299. * @param onProgress The callback when the load progresses
  98300. * @param fileName Defines the name of the file to load
  98301. * @returns The loaded asset container
  98302. */
  98303. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98304. }
  98305. /**
  98306. * Class used to load scene from various file formats using registered plugins
  98307. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98308. */
  98309. export class SceneLoader {
  98310. /**
  98311. * No logging while loading
  98312. */
  98313. static readonly NO_LOGGING: number;
  98314. /**
  98315. * Minimal logging while loading
  98316. */
  98317. static readonly MINIMAL_LOGGING: number;
  98318. /**
  98319. * Summary logging while loading
  98320. */
  98321. static readonly SUMMARY_LOGGING: number;
  98322. /**
  98323. * Detailled logging while loading
  98324. */
  98325. static readonly DETAILED_LOGGING: number;
  98326. /**
  98327. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98328. */
  98329. static ForceFullSceneLoadingForIncremental: boolean;
  98330. /**
  98331. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98332. */
  98333. static ShowLoadingScreen: boolean;
  98334. /**
  98335. * Defines the current logging level (while loading the scene)
  98336. * @ignorenaming
  98337. */
  98338. static loggingLevel: number;
  98339. /**
  98340. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98341. */
  98342. static CleanBoneMatrixWeights: boolean;
  98343. /**
  98344. * Event raised when a plugin is used to load a scene
  98345. */
  98346. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98347. private static _registeredPlugins;
  98348. private static _getDefaultPlugin;
  98349. private static _getPluginForExtension;
  98350. private static _getPluginForDirectLoad;
  98351. private static _getPluginForFilename;
  98352. private static _getDirectLoad;
  98353. private static _loadData;
  98354. private static _getFileInfo;
  98355. /**
  98356. * Gets a plugin that can load the given extension
  98357. * @param extension defines the extension to load
  98358. * @returns a plugin or null if none works
  98359. */
  98360. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98361. /**
  98362. * Gets a boolean indicating that the given extension can be loaded
  98363. * @param extension defines the extension to load
  98364. * @returns true if the extension is supported
  98365. */
  98366. static IsPluginForExtensionAvailable(extension: string): boolean;
  98367. /**
  98368. * Adds a new plugin to the list of registered plugins
  98369. * @param plugin defines the plugin to add
  98370. */
  98371. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98372. /**
  98373. * Import meshes into a scene
  98374. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98375. * @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)
  98376. * @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)
  98377. * @param scene the instance of BABYLON.Scene to append to
  98378. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98379. * @param onProgress a callback with a progress event for each file being loaded
  98380. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98381. * @param pluginExtension the extension used to determine the plugin
  98382. * @returns The loaded plugin
  98383. */
  98384. 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>;
  98385. /**
  98386. * Import meshes into a scene
  98387. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98388. * @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)
  98389. * @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)
  98390. * @param scene the instance of BABYLON.Scene to append to
  98391. * @param onProgress a callback with a progress event for each file being loaded
  98392. * @param pluginExtension the extension used to determine the plugin
  98393. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98394. */
  98395. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98396. meshes: AbstractMesh[];
  98397. particleSystems: IParticleSystem[];
  98398. skeletons: Skeleton[];
  98399. animationGroups: AnimationGroup[];
  98400. }>;
  98401. /**
  98402. * Load a scene
  98403. * @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)
  98404. * @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)
  98405. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98406. * @param onSuccess a callback with the scene when import succeeds
  98407. * @param onProgress a callback with a progress event for each file being loaded
  98408. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98409. * @param pluginExtension the extension used to determine the plugin
  98410. * @returns The loaded plugin
  98411. */
  98412. 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>;
  98413. /**
  98414. * Load a scene
  98415. * @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)
  98416. * @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)
  98417. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98418. * @param onProgress a callback with a progress event for each file being loaded
  98419. * @param pluginExtension the extension used to determine the plugin
  98420. * @returns The loaded scene
  98421. */
  98422. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98423. /**
  98424. * Append a scene
  98425. * @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)
  98426. * @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)
  98427. * @param scene is the instance of BABYLON.Scene to append to
  98428. * @param onSuccess a callback with the scene when import succeeds
  98429. * @param onProgress a callback with a progress event for each file being loaded
  98430. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98431. * @param pluginExtension the extension used to determine the plugin
  98432. * @returns The loaded plugin
  98433. */
  98434. 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>;
  98435. /**
  98436. * Append a scene
  98437. * @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)
  98438. * @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)
  98439. * @param scene is the instance of BABYLON.Scene to append to
  98440. * @param onProgress a callback with a progress event for each file being loaded
  98441. * @param pluginExtension the extension used to determine the plugin
  98442. * @returns The given scene
  98443. */
  98444. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98445. /**
  98446. * Load a scene into an asset container
  98447. * @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)
  98448. * @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)
  98449. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98450. * @param onSuccess a callback with the scene when import succeeds
  98451. * @param onProgress a callback with a progress event for each file being loaded
  98452. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98453. * @param pluginExtension the extension used to determine the plugin
  98454. * @returns The loaded plugin
  98455. */
  98456. 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>;
  98457. /**
  98458. * Load a scene into an asset container
  98459. * @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)
  98460. * @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)
  98461. * @param scene is the instance of Scene to append to
  98462. * @param onProgress a callback with a progress event for each file being loaded
  98463. * @param pluginExtension the extension used to determine the plugin
  98464. * @returns The loaded asset container
  98465. */
  98466. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98467. }
  98468. }
  98469. declare module BABYLON {
  98470. /**
  98471. * Google Daydream controller
  98472. */
  98473. export class DaydreamController extends WebVRController {
  98474. /**
  98475. * Base Url for the controller model.
  98476. */
  98477. static MODEL_BASE_URL: string;
  98478. /**
  98479. * File name for the controller model.
  98480. */
  98481. static MODEL_FILENAME: string;
  98482. /**
  98483. * Gamepad Id prefix used to identify Daydream Controller.
  98484. */
  98485. static readonly GAMEPAD_ID_PREFIX: string;
  98486. /**
  98487. * Creates a new DaydreamController from a gamepad
  98488. * @param vrGamepad the gamepad that the controller should be created from
  98489. */
  98490. constructor(vrGamepad: any);
  98491. /**
  98492. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98493. * @param scene scene in which to add meshes
  98494. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98495. */
  98496. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98497. /**
  98498. * Called once for each button that changed state since the last frame
  98499. * @param buttonIdx Which button index changed
  98500. * @param state New state of the button
  98501. * @param changes Which properties on the state changed since last frame
  98502. */
  98503. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98504. }
  98505. }
  98506. declare module BABYLON {
  98507. /**
  98508. * Gear VR Controller
  98509. */
  98510. export class GearVRController extends WebVRController {
  98511. /**
  98512. * Base Url for the controller model.
  98513. */
  98514. static MODEL_BASE_URL: string;
  98515. /**
  98516. * File name for the controller model.
  98517. */
  98518. static MODEL_FILENAME: string;
  98519. /**
  98520. * Gamepad Id prefix used to identify this controller.
  98521. */
  98522. static readonly GAMEPAD_ID_PREFIX: string;
  98523. private readonly _buttonIndexToObservableNameMap;
  98524. /**
  98525. * Creates a new GearVRController from a gamepad
  98526. * @param vrGamepad the gamepad that the controller should be created from
  98527. */
  98528. constructor(vrGamepad: any);
  98529. /**
  98530. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98531. * @param scene scene in which to add meshes
  98532. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98533. */
  98534. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98535. /**
  98536. * Called once for each button that changed state since the last frame
  98537. * @param buttonIdx Which button index changed
  98538. * @param state New state of the button
  98539. * @param changes Which properties on the state changed since last frame
  98540. */
  98541. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98542. }
  98543. }
  98544. declare module BABYLON {
  98545. /**
  98546. * Generic Controller
  98547. */
  98548. export class GenericController extends WebVRController {
  98549. /**
  98550. * Base Url for the controller model.
  98551. */
  98552. static readonly MODEL_BASE_URL: string;
  98553. /**
  98554. * File name for the controller model.
  98555. */
  98556. static readonly MODEL_FILENAME: string;
  98557. /**
  98558. * Creates a new GenericController from a gamepad
  98559. * @param vrGamepad the gamepad that the controller should be created from
  98560. */
  98561. constructor(vrGamepad: any);
  98562. /**
  98563. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98564. * @param scene scene in which to add meshes
  98565. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98566. */
  98567. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98568. /**
  98569. * Called once for each button that changed state since the last frame
  98570. * @param buttonIdx Which button index changed
  98571. * @param state New state of the button
  98572. * @param changes Which properties on the state changed since last frame
  98573. */
  98574. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98575. }
  98576. }
  98577. declare module BABYLON {
  98578. /**
  98579. * Oculus Touch Controller
  98580. */
  98581. export class OculusTouchController extends WebVRController {
  98582. /**
  98583. * Base Url for the controller model.
  98584. */
  98585. static MODEL_BASE_URL: string;
  98586. /**
  98587. * File name for the left controller model.
  98588. */
  98589. static MODEL_LEFT_FILENAME: string;
  98590. /**
  98591. * File name for the right controller model.
  98592. */
  98593. static MODEL_RIGHT_FILENAME: string;
  98594. /**
  98595. * Fired when the secondary trigger on this controller is modified
  98596. */
  98597. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98598. /**
  98599. * Fired when the thumb rest on this controller is modified
  98600. */
  98601. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98602. /**
  98603. * Creates a new OculusTouchController from a gamepad
  98604. * @param vrGamepad the gamepad that the controller should be created from
  98605. */
  98606. constructor(vrGamepad: any);
  98607. /**
  98608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98609. * @param scene scene in which to add meshes
  98610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98611. */
  98612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98613. /**
  98614. * Fired when the A button on this controller is modified
  98615. */
  98616. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98617. /**
  98618. * Fired when the B button on this controller is modified
  98619. */
  98620. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98621. /**
  98622. * Fired when the X button on this controller is modified
  98623. */
  98624. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98625. /**
  98626. * Fired when the Y button on this controller is modified
  98627. */
  98628. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98629. /**
  98630. * Called once for each button that changed state since the last frame
  98631. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98632. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98633. * 2) secondary trigger (same)
  98634. * 3) A (right) X (left), touch, pressed = value
  98635. * 4) B / Y
  98636. * 5) thumb rest
  98637. * @param buttonIdx Which button index changed
  98638. * @param state New state of the button
  98639. * @param changes Which properties on the state changed since last frame
  98640. */
  98641. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98642. }
  98643. }
  98644. declare module BABYLON {
  98645. /**
  98646. * Vive Controller
  98647. */
  98648. export class ViveController extends WebVRController {
  98649. /**
  98650. * Base Url for the controller model.
  98651. */
  98652. static MODEL_BASE_URL: string;
  98653. /**
  98654. * File name for the controller model.
  98655. */
  98656. static MODEL_FILENAME: string;
  98657. /**
  98658. * Creates a new ViveController from a gamepad
  98659. * @param vrGamepad the gamepad that the controller should be created from
  98660. */
  98661. constructor(vrGamepad: any);
  98662. /**
  98663. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98664. * @param scene scene in which to add meshes
  98665. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98666. */
  98667. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98668. /**
  98669. * Fired when the left button on this controller is modified
  98670. */
  98671. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98672. /**
  98673. * Fired when the right button on this controller is modified
  98674. */
  98675. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98676. /**
  98677. * Fired when the menu button on this controller is modified
  98678. */
  98679. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98680. /**
  98681. * Called once for each button that changed state since the last frame
  98682. * Vive mapping:
  98683. * 0: touchpad
  98684. * 1: trigger
  98685. * 2: left AND right buttons
  98686. * 3: menu button
  98687. * @param buttonIdx Which button index changed
  98688. * @param state New state of the button
  98689. * @param changes Which properties on the state changed since last frame
  98690. */
  98691. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98692. }
  98693. }
  98694. declare module BABYLON {
  98695. /**
  98696. * Defines the WindowsMotionController object that the state of the windows motion controller
  98697. */
  98698. export class WindowsMotionController extends WebVRController {
  98699. /**
  98700. * The base url used to load the left and right controller models
  98701. */
  98702. static MODEL_BASE_URL: string;
  98703. /**
  98704. * The name of the left controller model file
  98705. */
  98706. static MODEL_LEFT_FILENAME: string;
  98707. /**
  98708. * The name of the right controller model file
  98709. */
  98710. static MODEL_RIGHT_FILENAME: string;
  98711. /**
  98712. * The controller name prefix for this controller type
  98713. */
  98714. static readonly GAMEPAD_ID_PREFIX: string;
  98715. /**
  98716. * The controller id pattern for this controller type
  98717. */
  98718. private static readonly GAMEPAD_ID_PATTERN;
  98719. private _loadedMeshInfo;
  98720. private readonly _mapping;
  98721. /**
  98722. * Fired when the trackpad on this controller is clicked
  98723. */
  98724. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98725. /**
  98726. * Fired when the trackpad on this controller is modified
  98727. */
  98728. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98729. /**
  98730. * The current x and y values of this controller's trackpad
  98731. */
  98732. trackpad: StickValues;
  98733. /**
  98734. * Creates a new WindowsMotionController from a gamepad
  98735. * @param vrGamepad the gamepad that the controller should be created from
  98736. */
  98737. constructor(vrGamepad: any);
  98738. /**
  98739. * Fired when the trigger on this controller is modified
  98740. */
  98741. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98742. /**
  98743. * Fired when the menu button on this controller is modified
  98744. */
  98745. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98746. /**
  98747. * Fired when the grip button on this controller is modified
  98748. */
  98749. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98750. /**
  98751. * Fired when the thumbstick button on this controller is modified
  98752. */
  98753. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98754. /**
  98755. * Fired when the touchpad button on this controller is modified
  98756. */
  98757. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98758. /**
  98759. * Fired when the touchpad values on this controller are modified
  98760. */
  98761. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98762. private _updateTrackpad;
  98763. /**
  98764. * Called once per frame by the engine.
  98765. */
  98766. update(): void;
  98767. /**
  98768. * Called once for each button that changed state since the last frame
  98769. * @param buttonIdx Which button index changed
  98770. * @param state New state of the button
  98771. * @param changes Which properties on the state changed since last frame
  98772. */
  98773. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98774. /**
  98775. * Moves the buttons on the controller mesh based on their current state
  98776. * @param buttonName the name of the button to move
  98777. * @param buttonValue the value of the button which determines the buttons new position
  98778. */
  98779. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98780. /**
  98781. * Moves the axis on the controller mesh based on its current state
  98782. * @param axis the index of the axis
  98783. * @param axisValue the value of the axis which determines the meshes new position
  98784. * @hidden
  98785. */
  98786. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98787. /**
  98788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98789. * @param scene scene in which to add meshes
  98790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98791. */
  98792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98793. /**
  98794. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98795. * can be transformed by button presses and axes values, based on this._mapping.
  98796. *
  98797. * @param scene scene in which the meshes exist
  98798. * @param meshes list of meshes that make up the controller model to process
  98799. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98800. */
  98801. private processModel;
  98802. private createMeshInfo;
  98803. /**
  98804. * Gets the ray of the controller in the direction the controller is pointing
  98805. * @param length the length the resulting ray should be
  98806. * @returns a ray in the direction the controller is pointing
  98807. */
  98808. getForwardRay(length?: number): Ray;
  98809. /**
  98810. * Disposes of the controller
  98811. */
  98812. dispose(): void;
  98813. }
  98814. }
  98815. declare module BABYLON {
  98816. /**
  98817. * Single axis scale gizmo
  98818. */
  98819. export class AxisScaleGizmo extends Gizmo {
  98820. private _coloredMaterial;
  98821. /**
  98822. * Drag behavior responsible for the gizmos dragging interactions
  98823. */
  98824. dragBehavior: PointerDragBehavior;
  98825. private _pointerObserver;
  98826. /**
  98827. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98828. */
  98829. snapDistance: number;
  98830. /**
  98831. * Event that fires each time the gizmo snaps to a new location.
  98832. * * snapDistance is the the change in distance
  98833. */
  98834. onSnapObservable: Observable<{
  98835. snapDistance: number;
  98836. }>;
  98837. /**
  98838. * If the scaling operation should be done on all axis (default: false)
  98839. */
  98840. uniformScaling: boolean;
  98841. /**
  98842. * Creates an AxisScaleGizmo
  98843. * @param gizmoLayer The utility layer the gizmo will be added to
  98844. * @param dragAxis The axis which the gizmo will be able to scale on
  98845. * @param color The color of the gizmo
  98846. */
  98847. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98848. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98849. /**
  98850. * Disposes of the gizmo
  98851. */
  98852. dispose(): void;
  98853. /**
  98854. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98855. * @param mesh The mesh to replace the default mesh of the gizmo
  98856. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98857. */
  98858. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98859. }
  98860. }
  98861. declare module BABYLON {
  98862. /**
  98863. * Bounding box gizmo
  98864. */
  98865. export class BoundingBoxGizmo extends Gizmo {
  98866. private _lineBoundingBox;
  98867. private _rotateSpheresParent;
  98868. private _scaleBoxesParent;
  98869. private _boundingDimensions;
  98870. private _renderObserver;
  98871. private _pointerObserver;
  98872. private _scaleDragSpeed;
  98873. private _tmpQuaternion;
  98874. private _tmpVector;
  98875. private _tmpRotationMatrix;
  98876. /**
  98877. * 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)
  98878. */
  98879. ignoreChildren: boolean;
  98880. /**
  98881. * 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)
  98882. */
  98883. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98884. /**
  98885. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98886. */
  98887. rotationSphereSize: number;
  98888. /**
  98889. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98890. */
  98891. scaleBoxSize: number;
  98892. /**
  98893. * 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)
  98894. */
  98895. fixedDragMeshScreenSize: boolean;
  98896. /**
  98897. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98898. */
  98899. fixedDragMeshScreenSizeDistanceFactor: number;
  98900. /**
  98901. * Fired when a rotation sphere or scale box is dragged
  98902. */
  98903. onDragStartObservable: Observable<{}>;
  98904. /**
  98905. * Fired when a scale box is dragged
  98906. */
  98907. onScaleBoxDragObservable: Observable<{}>;
  98908. /**
  98909. * Fired when a scale box drag is ended
  98910. */
  98911. onScaleBoxDragEndObservable: Observable<{}>;
  98912. /**
  98913. * Fired when a rotation sphere is dragged
  98914. */
  98915. onRotationSphereDragObservable: Observable<{}>;
  98916. /**
  98917. * Fired when a rotation sphere drag is ended
  98918. */
  98919. onRotationSphereDragEndObservable: Observable<{}>;
  98920. /**
  98921. * 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)
  98922. */
  98923. scalePivot: Nullable<Vector3>;
  98924. private _anchorMesh;
  98925. private _existingMeshScale;
  98926. private _dragMesh;
  98927. private pointerDragBehavior;
  98928. private coloredMaterial;
  98929. private hoverColoredMaterial;
  98930. /**
  98931. * Sets the color of the bounding box gizmo
  98932. * @param color the color to set
  98933. */
  98934. setColor(color: Color3): void;
  98935. /**
  98936. * Creates an BoundingBoxGizmo
  98937. * @param gizmoLayer The utility layer the gizmo will be added to
  98938. * @param color The color of the gizmo
  98939. */
  98940. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98942. private _selectNode;
  98943. /**
  98944. * Updates the bounding box information for the Gizmo
  98945. */
  98946. updateBoundingBox(): void;
  98947. private _updateRotationSpheres;
  98948. private _updateScaleBoxes;
  98949. /**
  98950. * Enables rotation on the specified axis and disables rotation on the others
  98951. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98952. */
  98953. setEnabledRotationAxis(axis: string): void;
  98954. /**
  98955. * Enables/disables scaling
  98956. * @param enable if scaling should be enabled
  98957. */
  98958. setEnabledScaling(enable: boolean): void;
  98959. private _updateDummy;
  98960. /**
  98961. * Enables a pointer drag behavior on the bounding box of the gizmo
  98962. */
  98963. enableDragBehavior(): void;
  98964. /**
  98965. * Disposes of the gizmo
  98966. */
  98967. dispose(): void;
  98968. /**
  98969. * 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)
  98970. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98971. * @returns the bounding box mesh with the passed in mesh as a child
  98972. */
  98973. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98974. /**
  98975. * CustomMeshes are not supported by this gizmo
  98976. * @param mesh The mesh to replace the default mesh of the gizmo
  98977. */
  98978. setCustomMesh(mesh: Mesh): void;
  98979. }
  98980. }
  98981. declare module BABYLON {
  98982. /**
  98983. * Single plane rotation gizmo
  98984. */
  98985. export class PlaneRotationGizmo extends Gizmo {
  98986. /**
  98987. * Drag behavior responsible for the gizmos dragging interactions
  98988. */
  98989. dragBehavior: PointerDragBehavior;
  98990. private _pointerObserver;
  98991. /**
  98992. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98993. */
  98994. snapDistance: number;
  98995. /**
  98996. * Event that fires each time the gizmo snaps to a new location.
  98997. * * snapDistance is the the change in distance
  98998. */
  98999. onSnapObservable: Observable<{
  99000. snapDistance: number;
  99001. }>;
  99002. /**
  99003. * Creates a PlaneRotationGizmo
  99004. * @param gizmoLayer The utility layer the gizmo will be added to
  99005. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99006. * @param color The color of the gizmo
  99007. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99008. */
  99009. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99010. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99011. /**
  99012. * Disposes of the gizmo
  99013. */
  99014. dispose(): void;
  99015. }
  99016. }
  99017. declare module BABYLON {
  99018. /**
  99019. * Gizmo that enables rotating a mesh along 3 axis
  99020. */
  99021. export class RotationGizmo extends Gizmo {
  99022. /**
  99023. * Internal gizmo used for interactions on the x axis
  99024. */
  99025. xGizmo: PlaneRotationGizmo;
  99026. /**
  99027. * Internal gizmo used for interactions on the y axis
  99028. */
  99029. yGizmo: PlaneRotationGizmo;
  99030. /**
  99031. * Internal gizmo used for interactions on the z axis
  99032. */
  99033. zGizmo: PlaneRotationGizmo;
  99034. /** Fires an event when any of it's sub gizmos are dragged */
  99035. onDragStartObservable: Observable<{}>;
  99036. /** Fires an event when any of it's sub gizmos are released from dragging */
  99037. onDragEndObservable: Observable<{}>;
  99038. attachedMesh: Nullable<AbstractMesh>;
  99039. /**
  99040. * Creates a RotationGizmo
  99041. * @param gizmoLayer The utility layer the gizmo will be added to
  99042. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99043. */
  99044. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99045. updateGizmoRotationToMatchAttachedMesh: boolean;
  99046. /**
  99047. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99048. */
  99049. snapDistance: number;
  99050. /**
  99051. * Ratio for the scale of the gizmo (Default: 1)
  99052. */
  99053. scaleRatio: number;
  99054. /**
  99055. * Disposes of the gizmo
  99056. */
  99057. dispose(): void;
  99058. /**
  99059. * CustomMeshes are not supported by this gizmo
  99060. * @param mesh The mesh to replace the default mesh of the gizmo
  99061. */
  99062. setCustomMesh(mesh: Mesh): void;
  99063. }
  99064. }
  99065. declare module BABYLON {
  99066. /**
  99067. * Gizmo that enables dragging a mesh along 3 axis
  99068. */
  99069. export class PositionGizmo extends Gizmo {
  99070. /**
  99071. * Internal gizmo used for interactions on the x axis
  99072. */
  99073. xGizmo: AxisDragGizmo;
  99074. /**
  99075. * Internal gizmo used for interactions on the y axis
  99076. */
  99077. yGizmo: AxisDragGizmo;
  99078. /**
  99079. * Internal gizmo used for interactions on the z axis
  99080. */
  99081. zGizmo: AxisDragGizmo;
  99082. /** Fires an event when any of it's sub gizmos are dragged */
  99083. onDragStartObservable: Observable<{}>;
  99084. /** Fires an event when any of it's sub gizmos are released from dragging */
  99085. onDragEndObservable: Observable<{}>;
  99086. attachedMesh: Nullable<AbstractMesh>;
  99087. /**
  99088. * Creates a PositionGizmo
  99089. * @param gizmoLayer The utility layer the gizmo will be added to
  99090. */
  99091. constructor(gizmoLayer?: UtilityLayerRenderer);
  99092. updateGizmoRotationToMatchAttachedMesh: boolean;
  99093. /**
  99094. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99095. */
  99096. snapDistance: number;
  99097. /**
  99098. * Ratio for the scale of the gizmo (Default: 1)
  99099. */
  99100. scaleRatio: number;
  99101. /**
  99102. * Disposes of the gizmo
  99103. */
  99104. dispose(): void;
  99105. /**
  99106. * CustomMeshes are not supported by this gizmo
  99107. * @param mesh The mesh to replace the default mesh of the gizmo
  99108. */
  99109. setCustomMesh(mesh: Mesh): void;
  99110. }
  99111. }
  99112. declare module BABYLON {
  99113. /**
  99114. * Class containing static functions to help procedurally build meshes
  99115. */
  99116. export class PolyhedronBuilder {
  99117. /**
  99118. * Creates a polyhedron mesh
  99119. * * 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
  99120. * * The parameter `size` (positive float, default 1) sets the polygon size
  99121. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99122. * * 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`
  99123. * * 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
  99124. * * 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)`)
  99125. * * 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
  99126. * * 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
  99127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99130. * @param name defines the name of the mesh
  99131. * @param options defines the options used to create the mesh
  99132. * @param scene defines the hosting scene
  99133. * @returns the polyhedron mesh
  99134. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99135. */
  99136. static CreatePolyhedron(name: string, options: {
  99137. type?: number;
  99138. size?: number;
  99139. sizeX?: number;
  99140. sizeY?: number;
  99141. sizeZ?: number;
  99142. custom?: any;
  99143. faceUV?: Vector4[];
  99144. faceColors?: Color4[];
  99145. flat?: boolean;
  99146. updatable?: boolean;
  99147. sideOrientation?: number;
  99148. frontUVs?: Vector4;
  99149. backUVs?: Vector4;
  99150. }, scene: Scene): Mesh;
  99151. }
  99152. }
  99153. declare module BABYLON {
  99154. /**
  99155. * Gizmo that enables scaling a mesh along 3 axis
  99156. */
  99157. export class ScaleGizmo extends Gizmo {
  99158. /**
  99159. * Internal gizmo used for interactions on the x axis
  99160. */
  99161. xGizmo: AxisScaleGizmo;
  99162. /**
  99163. * Internal gizmo used for interactions on the y axis
  99164. */
  99165. yGizmo: AxisScaleGizmo;
  99166. /**
  99167. * Internal gizmo used for interactions on the z axis
  99168. */
  99169. zGizmo: AxisScaleGizmo;
  99170. /**
  99171. * Internal gizmo used to scale all axis equally
  99172. */
  99173. uniformScaleGizmo: AxisScaleGizmo;
  99174. /** Fires an event when any of it's sub gizmos are dragged */
  99175. onDragStartObservable: Observable<{}>;
  99176. /** Fires an event when any of it's sub gizmos are released from dragging */
  99177. onDragEndObservable: Observable<{}>;
  99178. attachedMesh: Nullable<AbstractMesh>;
  99179. /**
  99180. * Creates a ScaleGizmo
  99181. * @param gizmoLayer The utility layer the gizmo will be added to
  99182. */
  99183. constructor(gizmoLayer?: UtilityLayerRenderer);
  99184. updateGizmoRotationToMatchAttachedMesh: boolean;
  99185. /**
  99186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99187. */
  99188. snapDistance: number;
  99189. /**
  99190. * Ratio for the scale of the gizmo (Default: 1)
  99191. */
  99192. scaleRatio: number;
  99193. /**
  99194. * Disposes of the gizmo
  99195. */
  99196. dispose(): void;
  99197. }
  99198. }
  99199. declare module BABYLON {
  99200. /**
  99201. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99202. */
  99203. export class GizmoManager implements IDisposable {
  99204. private scene;
  99205. /**
  99206. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99207. */
  99208. gizmos: {
  99209. positionGizmo: Nullable<PositionGizmo>;
  99210. rotationGizmo: Nullable<RotationGizmo>;
  99211. scaleGizmo: Nullable<ScaleGizmo>;
  99212. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99213. };
  99214. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99215. clearGizmoOnEmptyPointerEvent: boolean;
  99216. /** Fires an event when the manager is attached to a mesh */
  99217. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99218. private _gizmosEnabled;
  99219. private _pointerObserver;
  99220. private _attachedMesh;
  99221. private _boundingBoxColor;
  99222. private _defaultUtilityLayer;
  99223. private _defaultKeepDepthUtilityLayer;
  99224. /**
  99225. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99226. */
  99227. boundingBoxDragBehavior: SixDofDragBehavior;
  99228. /**
  99229. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99230. */
  99231. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99232. /**
  99233. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99234. */
  99235. usePointerToAttachGizmos: boolean;
  99236. /**
  99237. * Instatiates a gizmo manager
  99238. * @param scene the scene to overlay the gizmos on top of
  99239. */
  99240. constructor(scene: Scene);
  99241. /**
  99242. * Attaches a set of gizmos to the specified mesh
  99243. * @param mesh The mesh the gizmo's should be attached to
  99244. */
  99245. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99246. /**
  99247. * If the position gizmo is enabled
  99248. */
  99249. positionGizmoEnabled: boolean;
  99250. /**
  99251. * If the rotation gizmo is enabled
  99252. */
  99253. rotationGizmoEnabled: boolean;
  99254. /**
  99255. * If the scale gizmo is enabled
  99256. */
  99257. scaleGizmoEnabled: boolean;
  99258. /**
  99259. * If the boundingBox gizmo is enabled
  99260. */
  99261. boundingBoxGizmoEnabled: boolean;
  99262. /**
  99263. * Disposes of the gizmo manager
  99264. */
  99265. dispose(): void;
  99266. }
  99267. }
  99268. declare module BABYLON {
  99269. /**
  99270. * Gizmo that enables viewing a light
  99271. */
  99272. export class LightGizmo extends Gizmo {
  99273. private _box;
  99274. /**
  99275. * Creates a LightGizmo
  99276. * @param gizmoLayer The utility layer the gizmo will be added to
  99277. */
  99278. constructor(gizmoLayer?: UtilityLayerRenderer);
  99279. private _light;
  99280. /**
  99281. * The light that the gizmo is attached to
  99282. */
  99283. light: Nullable<Light>;
  99284. /**
  99285. * @hidden
  99286. * Updates the gizmo to match the attached mesh's position/rotation
  99287. */
  99288. protected _update(): void;
  99289. }
  99290. }
  99291. declare module BABYLON {
  99292. /** @hidden */
  99293. export var backgroundFragmentDeclaration: {
  99294. name: string;
  99295. shader: string;
  99296. };
  99297. }
  99298. declare module BABYLON {
  99299. /** @hidden */
  99300. export var backgroundUboDeclaration: {
  99301. name: string;
  99302. shader: string;
  99303. };
  99304. }
  99305. declare module BABYLON {
  99306. /** @hidden */
  99307. export var backgroundPixelShader: {
  99308. name: string;
  99309. shader: string;
  99310. };
  99311. }
  99312. declare module BABYLON {
  99313. /** @hidden */
  99314. export var backgroundVertexDeclaration: {
  99315. name: string;
  99316. shader: string;
  99317. };
  99318. }
  99319. declare module BABYLON {
  99320. /** @hidden */
  99321. export var backgroundVertexShader: {
  99322. name: string;
  99323. shader: string;
  99324. };
  99325. }
  99326. declare module BABYLON {
  99327. /**
  99328. * Background material used to create an efficient environement around your scene.
  99329. */
  99330. export class BackgroundMaterial extends PushMaterial {
  99331. /**
  99332. * Standard reflectance value at parallel view angle.
  99333. */
  99334. static StandardReflectance0: number;
  99335. /**
  99336. * Standard reflectance value at grazing angle.
  99337. */
  99338. static StandardReflectance90: number;
  99339. protected _primaryColor: Color3;
  99340. /**
  99341. * Key light Color (multiply against the environement texture)
  99342. */
  99343. primaryColor: Color3;
  99344. protected __perceptualColor: Nullable<Color3>;
  99345. /**
  99346. * Experimental Internal Use Only.
  99347. *
  99348. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99349. * This acts as a helper to set the primary color to a more "human friendly" value.
  99350. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99351. * output color as close as possible from the chosen value.
  99352. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99353. * part of lighting setup.)
  99354. */
  99355. _perceptualColor: Nullable<Color3>;
  99356. protected _primaryColorShadowLevel: float;
  99357. /**
  99358. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99359. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99360. */
  99361. primaryColorShadowLevel: float;
  99362. protected _primaryColorHighlightLevel: float;
  99363. /**
  99364. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99365. * The primary color is used at the level chosen to define what the white area would look.
  99366. */
  99367. primaryColorHighlightLevel: float;
  99368. protected _reflectionTexture: Nullable<BaseTexture>;
  99369. /**
  99370. * Reflection Texture used in the material.
  99371. * Should be author in a specific way for the best result (refer to the documentation).
  99372. */
  99373. reflectionTexture: Nullable<BaseTexture>;
  99374. protected _reflectionBlur: float;
  99375. /**
  99376. * Reflection Texture level of blur.
  99377. *
  99378. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99379. * texture twice.
  99380. */
  99381. reflectionBlur: float;
  99382. protected _diffuseTexture: Nullable<BaseTexture>;
  99383. /**
  99384. * Diffuse Texture used in the material.
  99385. * Should be author in a specific way for the best result (refer to the documentation).
  99386. */
  99387. diffuseTexture: Nullable<BaseTexture>;
  99388. protected _shadowLights: Nullable<IShadowLight[]>;
  99389. /**
  99390. * Specify the list of lights casting shadow on the material.
  99391. * All scene shadow lights will be included if null.
  99392. */
  99393. shadowLights: Nullable<IShadowLight[]>;
  99394. protected _shadowLevel: float;
  99395. /**
  99396. * Helps adjusting the shadow to a softer level if required.
  99397. * 0 means black shadows and 1 means no shadows.
  99398. */
  99399. shadowLevel: float;
  99400. protected _sceneCenter: Vector3;
  99401. /**
  99402. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99403. * It is usually zero but might be interesting to modify according to your setup.
  99404. */
  99405. sceneCenter: Vector3;
  99406. protected _opacityFresnel: boolean;
  99407. /**
  99408. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99409. * This helps ensuring a nice transition when the camera goes under the ground.
  99410. */
  99411. opacityFresnel: boolean;
  99412. protected _reflectionFresnel: boolean;
  99413. /**
  99414. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99415. * This helps adding a mirror texture on the ground.
  99416. */
  99417. reflectionFresnel: boolean;
  99418. protected _reflectionFalloffDistance: number;
  99419. /**
  99420. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99421. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99422. */
  99423. reflectionFalloffDistance: number;
  99424. protected _reflectionAmount: number;
  99425. /**
  99426. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99427. */
  99428. reflectionAmount: number;
  99429. protected _reflectionReflectance0: number;
  99430. /**
  99431. * This specifies the weight of the reflection at grazing angle.
  99432. */
  99433. reflectionReflectance0: number;
  99434. protected _reflectionReflectance90: number;
  99435. /**
  99436. * This specifies the weight of the reflection at a perpendicular point of view.
  99437. */
  99438. reflectionReflectance90: number;
  99439. /**
  99440. * Sets the reflection reflectance fresnel values according to the default standard
  99441. * empirically know to work well :-)
  99442. */
  99443. reflectionStandardFresnelWeight: number;
  99444. protected _useRGBColor: boolean;
  99445. /**
  99446. * Helps to directly use the maps channels instead of their level.
  99447. */
  99448. useRGBColor: boolean;
  99449. protected _enableNoise: boolean;
  99450. /**
  99451. * This helps reducing the banding effect that could occur on the background.
  99452. */
  99453. enableNoise: boolean;
  99454. /**
  99455. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99456. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99457. * Recommended to be keep at 1.0 except for special cases.
  99458. */
  99459. fovMultiplier: number;
  99460. private _fovMultiplier;
  99461. /**
  99462. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99463. */
  99464. useEquirectangularFOV: boolean;
  99465. private _maxSimultaneousLights;
  99466. /**
  99467. * Number of Simultaneous lights allowed on the material.
  99468. */
  99469. maxSimultaneousLights: int;
  99470. /**
  99471. * Default configuration related to image processing available in the Background Material.
  99472. */
  99473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99474. /**
  99475. * Keep track of the image processing observer to allow dispose and replace.
  99476. */
  99477. private _imageProcessingObserver;
  99478. /**
  99479. * Attaches a new image processing configuration to the PBR Material.
  99480. * @param configuration (if null the scene configuration will be use)
  99481. */
  99482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99483. /**
  99484. * Gets the image processing configuration used either in this material.
  99485. */
  99486. /**
  99487. * Sets the Default image processing configuration used either in the this material.
  99488. *
  99489. * If sets to null, the scene one is in use.
  99490. */
  99491. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99492. /**
  99493. * Gets wether the color curves effect is enabled.
  99494. */
  99495. /**
  99496. * Sets wether the color curves effect is enabled.
  99497. */
  99498. cameraColorCurvesEnabled: boolean;
  99499. /**
  99500. * Gets wether the color grading effect is enabled.
  99501. */
  99502. /**
  99503. * Gets wether the color grading effect is enabled.
  99504. */
  99505. cameraColorGradingEnabled: boolean;
  99506. /**
  99507. * Gets wether tonemapping is enabled or not.
  99508. */
  99509. /**
  99510. * Sets wether tonemapping is enabled or not
  99511. */
  99512. cameraToneMappingEnabled: boolean;
  99513. /**
  99514. * The camera exposure used on this material.
  99515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99516. * This corresponds to a photographic exposure.
  99517. */
  99518. /**
  99519. * The camera exposure used on this material.
  99520. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99521. * This corresponds to a photographic exposure.
  99522. */
  99523. cameraExposure: float;
  99524. /**
  99525. * Gets The camera contrast used on this material.
  99526. */
  99527. /**
  99528. * Sets The camera contrast used on this material.
  99529. */
  99530. cameraContrast: float;
  99531. /**
  99532. * Gets the Color Grading 2D Lookup Texture.
  99533. */
  99534. /**
  99535. * Sets the Color Grading 2D Lookup Texture.
  99536. */
  99537. cameraColorGradingTexture: Nullable<BaseTexture>;
  99538. /**
  99539. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99540. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99541. * 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;
  99542. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99543. */
  99544. /**
  99545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99547. * 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;
  99548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99549. */
  99550. cameraColorCurves: Nullable<ColorCurves>;
  99551. /**
  99552. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99553. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99554. */
  99555. switchToBGR: boolean;
  99556. private _renderTargets;
  99557. private _reflectionControls;
  99558. private _white;
  99559. private _primaryShadowColor;
  99560. private _primaryHighlightColor;
  99561. /**
  99562. * Instantiates a Background Material in the given scene
  99563. * @param name The friendly name of the material
  99564. * @param scene The scene to add the material to
  99565. */
  99566. constructor(name: string, scene: Scene);
  99567. /**
  99568. * Gets a boolean indicating that current material needs to register RTT
  99569. */
  99570. readonly hasRenderTargetTextures: boolean;
  99571. /**
  99572. * The entire material has been created in order to prevent overdraw.
  99573. * @returns false
  99574. */
  99575. needAlphaTesting(): boolean;
  99576. /**
  99577. * The entire material has been created in order to prevent overdraw.
  99578. * @returns true if blending is enable
  99579. */
  99580. needAlphaBlending(): boolean;
  99581. /**
  99582. * Checks wether the material is ready to be rendered for a given mesh.
  99583. * @param mesh The mesh to render
  99584. * @param subMesh The submesh to check against
  99585. * @param useInstances Specify wether or not the material is used with instances
  99586. * @returns true if all the dependencies are ready (Textures, Effects...)
  99587. */
  99588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99589. /**
  99590. * Compute the primary color according to the chosen perceptual color.
  99591. */
  99592. private _computePrimaryColorFromPerceptualColor;
  99593. /**
  99594. * Compute the highlights and shadow colors according to their chosen levels.
  99595. */
  99596. private _computePrimaryColors;
  99597. /**
  99598. * Build the uniform buffer used in the material.
  99599. */
  99600. buildUniformLayout(): void;
  99601. /**
  99602. * Unbind the material.
  99603. */
  99604. unbind(): void;
  99605. /**
  99606. * Bind only the world matrix to the material.
  99607. * @param world The world matrix to bind.
  99608. */
  99609. bindOnlyWorldMatrix(world: Matrix): void;
  99610. /**
  99611. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99612. * @param world The world matrix to bind.
  99613. * @param subMesh The submesh to bind for.
  99614. */
  99615. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99616. /**
  99617. * Dispose the material.
  99618. * @param forceDisposeEffect Force disposal of the associated effect.
  99619. * @param forceDisposeTextures Force disposal of the associated textures.
  99620. */
  99621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99622. /**
  99623. * Clones the material.
  99624. * @param name The cloned name.
  99625. * @returns The cloned material.
  99626. */
  99627. clone(name: string): BackgroundMaterial;
  99628. /**
  99629. * Serializes the current material to its JSON representation.
  99630. * @returns The JSON representation.
  99631. */
  99632. serialize(): any;
  99633. /**
  99634. * Gets the class name of the material
  99635. * @returns "BackgroundMaterial"
  99636. */
  99637. getClassName(): string;
  99638. /**
  99639. * Parse a JSON input to create back a background material.
  99640. * @param source The JSON data to parse
  99641. * @param scene The scene to create the parsed material in
  99642. * @param rootUrl The root url of the assets the material depends upon
  99643. * @returns the instantiated BackgroundMaterial.
  99644. */
  99645. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99646. }
  99647. }
  99648. declare module BABYLON {
  99649. /**
  99650. * Represents the different options available during the creation of
  99651. * a Environment helper.
  99652. *
  99653. * This can control the default ground, skybox and image processing setup of your scene.
  99654. */
  99655. export interface IEnvironmentHelperOptions {
  99656. /**
  99657. * Specifies wether or not to create a ground.
  99658. * True by default.
  99659. */
  99660. createGround: boolean;
  99661. /**
  99662. * Specifies the ground size.
  99663. * 15 by default.
  99664. */
  99665. groundSize: number;
  99666. /**
  99667. * The texture used on the ground for the main color.
  99668. * Comes from the BabylonJS CDN by default.
  99669. *
  99670. * Remarks: Can be either a texture or a url.
  99671. */
  99672. groundTexture: string | BaseTexture;
  99673. /**
  99674. * The color mixed in the ground texture by default.
  99675. * BabylonJS clearColor by default.
  99676. */
  99677. groundColor: Color3;
  99678. /**
  99679. * Specifies the ground opacity.
  99680. * 1 by default.
  99681. */
  99682. groundOpacity: number;
  99683. /**
  99684. * Enables the ground to receive shadows.
  99685. * True by default.
  99686. */
  99687. enableGroundShadow: boolean;
  99688. /**
  99689. * Helps preventing the shadow to be fully black on the ground.
  99690. * 0.5 by default.
  99691. */
  99692. groundShadowLevel: number;
  99693. /**
  99694. * Creates a mirror texture attach to the ground.
  99695. * false by default.
  99696. */
  99697. enableGroundMirror: boolean;
  99698. /**
  99699. * Specifies the ground mirror size ratio.
  99700. * 0.3 by default as the default kernel is 64.
  99701. */
  99702. groundMirrorSizeRatio: number;
  99703. /**
  99704. * Specifies the ground mirror blur kernel size.
  99705. * 64 by default.
  99706. */
  99707. groundMirrorBlurKernel: number;
  99708. /**
  99709. * Specifies the ground mirror visibility amount.
  99710. * 1 by default
  99711. */
  99712. groundMirrorAmount: number;
  99713. /**
  99714. * Specifies the ground mirror reflectance weight.
  99715. * This uses the standard weight of the background material to setup the fresnel effect
  99716. * of the mirror.
  99717. * 1 by default.
  99718. */
  99719. groundMirrorFresnelWeight: number;
  99720. /**
  99721. * Specifies the ground mirror Falloff distance.
  99722. * This can helps reducing the size of the reflection.
  99723. * 0 by Default.
  99724. */
  99725. groundMirrorFallOffDistance: number;
  99726. /**
  99727. * Specifies the ground mirror texture type.
  99728. * Unsigned Int by Default.
  99729. */
  99730. groundMirrorTextureType: number;
  99731. /**
  99732. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99733. * the shown objects.
  99734. */
  99735. groundYBias: number;
  99736. /**
  99737. * Specifies wether or not to create a skybox.
  99738. * True by default.
  99739. */
  99740. createSkybox: boolean;
  99741. /**
  99742. * Specifies the skybox size.
  99743. * 20 by default.
  99744. */
  99745. skyboxSize: number;
  99746. /**
  99747. * The texture used on the skybox for the main color.
  99748. * Comes from the BabylonJS CDN by default.
  99749. *
  99750. * Remarks: Can be either a texture or a url.
  99751. */
  99752. skyboxTexture: string | BaseTexture;
  99753. /**
  99754. * The color mixed in the skybox texture by default.
  99755. * BabylonJS clearColor by default.
  99756. */
  99757. skyboxColor: Color3;
  99758. /**
  99759. * The background rotation around the Y axis of the scene.
  99760. * This helps aligning the key lights of your scene with the background.
  99761. * 0 by default.
  99762. */
  99763. backgroundYRotation: number;
  99764. /**
  99765. * Compute automatically the size of the elements to best fit with the scene.
  99766. */
  99767. sizeAuto: boolean;
  99768. /**
  99769. * Default position of the rootMesh if autoSize is not true.
  99770. */
  99771. rootPosition: Vector3;
  99772. /**
  99773. * Sets up the image processing in the scene.
  99774. * true by default.
  99775. */
  99776. setupImageProcessing: boolean;
  99777. /**
  99778. * The texture used as your environment texture in the scene.
  99779. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99780. *
  99781. * Remarks: Can be either a texture or a url.
  99782. */
  99783. environmentTexture: string | BaseTexture;
  99784. /**
  99785. * The value of the exposure to apply to the scene.
  99786. * 0.6 by default if setupImageProcessing is true.
  99787. */
  99788. cameraExposure: number;
  99789. /**
  99790. * The value of the contrast to apply to the scene.
  99791. * 1.6 by default if setupImageProcessing is true.
  99792. */
  99793. cameraContrast: number;
  99794. /**
  99795. * Specifies wether or not tonemapping should be enabled in the scene.
  99796. * true by default if setupImageProcessing is true.
  99797. */
  99798. toneMappingEnabled: boolean;
  99799. }
  99800. /**
  99801. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99802. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99803. * It also helps with the default setup of your imageProcessing configuration.
  99804. */
  99805. export class EnvironmentHelper {
  99806. /**
  99807. * Default ground texture URL.
  99808. */
  99809. private static _groundTextureCDNUrl;
  99810. /**
  99811. * Default skybox texture URL.
  99812. */
  99813. private static _skyboxTextureCDNUrl;
  99814. /**
  99815. * Default environment texture URL.
  99816. */
  99817. private static _environmentTextureCDNUrl;
  99818. /**
  99819. * Creates the default options for the helper.
  99820. */
  99821. private static _getDefaultOptions;
  99822. private _rootMesh;
  99823. /**
  99824. * Gets the root mesh created by the helper.
  99825. */
  99826. readonly rootMesh: Mesh;
  99827. private _skybox;
  99828. /**
  99829. * Gets the skybox created by the helper.
  99830. */
  99831. readonly skybox: Nullable<Mesh>;
  99832. private _skyboxTexture;
  99833. /**
  99834. * Gets the skybox texture created by the helper.
  99835. */
  99836. readonly skyboxTexture: Nullable<BaseTexture>;
  99837. private _skyboxMaterial;
  99838. /**
  99839. * Gets the skybox material created by the helper.
  99840. */
  99841. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99842. private _ground;
  99843. /**
  99844. * Gets the ground mesh created by the helper.
  99845. */
  99846. readonly ground: Nullable<Mesh>;
  99847. private _groundTexture;
  99848. /**
  99849. * Gets the ground texture created by the helper.
  99850. */
  99851. readonly groundTexture: Nullable<BaseTexture>;
  99852. private _groundMirror;
  99853. /**
  99854. * Gets the ground mirror created by the helper.
  99855. */
  99856. readonly groundMirror: Nullable<MirrorTexture>;
  99857. /**
  99858. * Gets the ground mirror render list to helps pushing the meshes
  99859. * you wish in the ground reflection.
  99860. */
  99861. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99862. private _groundMaterial;
  99863. /**
  99864. * Gets the ground material created by the helper.
  99865. */
  99866. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99867. /**
  99868. * Stores the creation options.
  99869. */
  99870. private readonly _scene;
  99871. private _options;
  99872. /**
  99873. * This observable will be notified with any error during the creation of the environment,
  99874. * mainly texture creation errors.
  99875. */
  99876. onErrorObservable: Observable<{
  99877. message?: string;
  99878. exception?: any;
  99879. }>;
  99880. /**
  99881. * constructor
  99882. * @param options Defines the options we want to customize the helper
  99883. * @param scene The scene to add the material to
  99884. */
  99885. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99886. /**
  99887. * Updates the background according to the new options
  99888. * @param options
  99889. */
  99890. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99891. /**
  99892. * Sets the primary color of all the available elements.
  99893. * @param color the main color to affect to the ground and the background
  99894. */
  99895. setMainColor(color: Color3): void;
  99896. /**
  99897. * Setup the image processing according to the specified options.
  99898. */
  99899. private _setupImageProcessing;
  99900. /**
  99901. * Setup the environment texture according to the specified options.
  99902. */
  99903. private _setupEnvironmentTexture;
  99904. /**
  99905. * Setup the background according to the specified options.
  99906. */
  99907. private _setupBackground;
  99908. /**
  99909. * Get the scene sizes according to the setup.
  99910. */
  99911. private _getSceneSize;
  99912. /**
  99913. * Setup the ground according to the specified options.
  99914. */
  99915. private _setupGround;
  99916. /**
  99917. * Setup the ground material according to the specified options.
  99918. */
  99919. private _setupGroundMaterial;
  99920. /**
  99921. * Setup the ground diffuse texture according to the specified options.
  99922. */
  99923. private _setupGroundDiffuseTexture;
  99924. /**
  99925. * Setup the ground mirror texture according to the specified options.
  99926. */
  99927. private _setupGroundMirrorTexture;
  99928. /**
  99929. * Setup the ground to receive the mirror texture.
  99930. */
  99931. private _setupMirrorInGroundMaterial;
  99932. /**
  99933. * Setup the skybox according to the specified options.
  99934. */
  99935. private _setupSkybox;
  99936. /**
  99937. * Setup the skybox material according to the specified options.
  99938. */
  99939. private _setupSkyboxMaterial;
  99940. /**
  99941. * Setup the skybox reflection texture according to the specified options.
  99942. */
  99943. private _setupSkyboxReflectionTexture;
  99944. private _errorHandler;
  99945. /**
  99946. * Dispose all the elements created by the Helper.
  99947. */
  99948. dispose(): void;
  99949. }
  99950. }
  99951. declare module BABYLON {
  99952. /**
  99953. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99954. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99955. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99956. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99957. */
  99958. export class PhotoDome extends TransformNode {
  99959. private _useDirectMapping;
  99960. /**
  99961. * The texture being displayed on the sphere
  99962. */
  99963. protected _photoTexture: Texture;
  99964. /**
  99965. * Gets or sets the texture being displayed on the sphere
  99966. */
  99967. photoTexture: Texture;
  99968. /**
  99969. * Observable raised when an error occured while loading the 360 image
  99970. */
  99971. onLoadErrorObservable: Observable<string>;
  99972. /**
  99973. * The skybox material
  99974. */
  99975. protected _material: BackgroundMaterial;
  99976. /**
  99977. * The surface used for the skybox
  99978. */
  99979. protected _mesh: Mesh;
  99980. /**
  99981. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99982. * Also see the options.resolution property.
  99983. */
  99984. fovMultiplier: number;
  99985. /**
  99986. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99987. * @param name Element's name, child elements will append suffixes for their own names.
  99988. * @param urlsOfPhoto defines the url of the photo to display
  99989. * @param options defines an object containing optional or exposed sub element properties
  99990. * @param onError defines a callback called when an error occured while loading the texture
  99991. */
  99992. constructor(name: string, urlOfPhoto: string, options: {
  99993. resolution?: number;
  99994. size?: number;
  99995. useDirectMapping?: boolean;
  99996. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99997. /**
  99998. * Releases resources associated with this node.
  99999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100001. */
  100002. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100003. }
  100004. }
  100005. declare module BABYLON {
  100006. /**
  100007. * Class used to host texture specific utilities
  100008. */
  100009. export class TextureTools {
  100010. /**
  100011. * Uses the GPU to create a copy texture rescaled at a given size
  100012. * @param texture Texture to copy from
  100013. * @param width defines the desired width
  100014. * @param height defines the desired height
  100015. * @param useBilinearMode defines if bilinear mode has to be used
  100016. * @return the generated texture
  100017. */
  100018. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100019. /**
  100020. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100021. * @param scene defines the hosting scene
  100022. * @returns the environment BRDF texture
  100023. */
  100024. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100025. private static _environmentBRDFBase64Texture;
  100026. }
  100027. }
  100028. declare module BABYLON {
  100029. /**
  100030. * @hidden
  100031. */
  100032. export interface IMaterialClearCoatDefines {
  100033. CLEARCOAT: boolean;
  100034. CLEARCOAT_DEFAULTIOR: boolean;
  100035. CLEARCOAT_TEXTURE: boolean;
  100036. CLEARCOAT_TEXTUREDIRECTUV: number;
  100037. CLEARCOAT_BUMP: boolean;
  100038. CLEARCOAT_BUMPDIRECTUV: number;
  100039. CLEARCOAT_TINT: boolean;
  100040. CLEARCOAT_TINT_TEXTURE: boolean;
  100041. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100042. /** @hidden */
  100043. _areTexturesDirty: boolean;
  100044. }
  100045. /**
  100046. * Define the code related to the clear coat parameters of the pbr material.
  100047. */
  100048. export class PBRClearCoatConfiguration {
  100049. /**
  100050. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100051. * The default fits with a polyurethane material.
  100052. */
  100053. private static readonly _DefaultIndiceOfRefraction;
  100054. private _isEnabled;
  100055. /**
  100056. * Defines if the clear coat is enabled in the material.
  100057. */
  100058. isEnabled: boolean;
  100059. /**
  100060. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100061. */
  100062. intensity: number;
  100063. /**
  100064. * Defines the clear coat layer roughness.
  100065. */
  100066. roughness: number;
  100067. private _indiceOfRefraction;
  100068. /**
  100069. * Defines the indice of refraction of the clear coat.
  100070. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100071. * The default fits with a polyurethane material.
  100072. * Changing the default value is more performance intensive.
  100073. */
  100074. indiceOfRefraction: number;
  100075. private _texture;
  100076. /**
  100077. * Stores the clear coat values in a texture.
  100078. */
  100079. texture: Nullable<BaseTexture>;
  100080. private _bumpTexture;
  100081. /**
  100082. * Define the clear coat specific bump texture.
  100083. */
  100084. bumpTexture: Nullable<BaseTexture>;
  100085. private _isTintEnabled;
  100086. /**
  100087. * Defines if the clear coat tint is enabled in the material.
  100088. */
  100089. isTintEnabled: boolean;
  100090. /**
  100091. * Defines if the clear coat tint is enabled in the material.
  100092. * This is only use if tint is enabled
  100093. */
  100094. tintColor: Color3;
  100095. /**
  100096. * Defines if the distance at which the tint color should be found in the
  100097. * clear coat media.
  100098. * This is only use if tint is enabled
  100099. */
  100100. tintColorAtDistance: number;
  100101. /**
  100102. * Defines the clear coat layer thickness.
  100103. * This is only use if tint is enabled
  100104. */
  100105. tintThickness: number;
  100106. private _tintTexture;
  100107. /**
  100108. * Stores the clear tint values in a texture.
  100109. * rgb is tint
  100110. * a is a thickness factor
  100111. */
  100112. tintTexture: Nullable<BaseTexture>;
  100113. /** @hidden */
  100114. private _internalMarkAllSubMeshesAsTexturesDirty;
  100115. /** @hidden */
  100116. _markAllSubMeshesAsTexturesDirty(): void;
  100117. /**
  100118. * Instantiate a new istance of clear coat configuration.
  100119. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100120. */
  100121. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100122. /**
  100123. * Specifies that the submesh is ready to be used.
  100124. * @param defines the list of "defines" to update.
  100125. * @param scene defines the scene the material belongs to.
  100126. * @param engine defines the engine the material belongs to.
  100127. * @param disableBumpMap defines wether the material disables bump or not.
  100128. * @returns - boolean indicating that the submesh is ready or not.
  100129. */
  100130. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100131. /**
  100132. * Checks to see if a texture is used in the material.
  100133. * @param defines the list of "defines" to update.
  100134. * @param scene defines the scene to the material belongs to.
  100135. */
  100136. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100137. /**
  100138. * Binds the material data.
  100139. * @param uniformBuffer defines the Uniform buffer to fill in.
  100140. * @param scene defines the scene the material belongs to.
  100141. * @param engine defines the engine the material belongs to.
  100142. * @param disableBumpMap defines wether the material disables bump or not.
  100143. * @param isFrozen defines wether the material is frozen or not.
  100144. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100145. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100146. */
  100147. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100148. /**
  100149. * Checks to see if a texture is used in the material.
  100150. * @param texture - Base texture to use.
  100151. * @returns - Boolean specifying if a texture is used in the material.
  100152. */
  100153. hasTexture(texture: BaseTexture): boolean;
  100154. /**
  100155. * Returns an array of the actively used textures.
  100156. * @param activeTextures Array of BaseTextures
  100157. */
  100158. getActiveTextures(activeTextures: BaseTexture[]): void;
  100159. /**
  100160. * Returns the animatable textures.
  100161. * @param animatables Array of animatable textures.
  100162. */
  100163. getAnimatables(animatables: IAnimatable[]): void;
  100164. /**
  100165. * Disposes the resources of the material.
  100166. * @param forceDisposeTextures - Forces the disposal of all textures.
  100167. */
  100168. dispose(forceDisposeTextures?: boolean): void;
  100169. /**
  100170. * Get the current class name of the texture useful for serialization or dynamic coding.
  100171. * @returns "PBRClearCoatConfiguration"
  100172. */
  100173. getClassName(): string;
  100174. /**
  100175. * Makes a duplicate of the current configuration into another one.
  100176. * @param clearCoatConfiguration define the config where to copy the info
  100177. */
  100178. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100179. /**
  100180. * Serializes this clear coat configuration.
  100181. * @returns - An object with the serialized config.
  100182. */
  100183. serialize(): any;
  100184. /**
  100185. * Parses a Clear Coat Configuration from a serialized object.
  100186. * @param source - Serialized object.
  100187. */
  100188. parse(source: any): void;
  100189. /**
  100190. * Add fallbacks to the effect fallbacks list.
  100191. * @param defines defines the Base texture to use.
  100192. * @param fallbacks defines the current fallback list.
  100193. * @param currentRank defines the current fallback rank.
  100194. * @returns the new fallback rank.
  100195. */
  100196. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100197. /**
  100198. * Add the required uniforms to the current list.
  100199. * @param uniforms defines the current uniform list.
  100200. */
  100201. static AddUniforms(uniforms: string[]): void;
  100202. /**
  100203. * Add the required samplers to the current list.
  100204. * @param samplers defines the current sampler list.
  100205. */
  100206. static AddSamplers(samplers: string[]): void;
  100207. /**
  100208. * Add the required uniforms to the current buffer.
  100209. * @param uniformBuffer defines the current uniform buffer.
  100210. */
  100211. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100212. }
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * @hidden
  100217. */
  100218. export interface IMaterialAnisotropicDefines {
  100219. ANISOTROPIC: boolean;
  100220. MAINUV1: boolean;
  100221. _areMiscDirty: boolean;
  100222. _needUVs: boolean;
  100223. }
  100224. /**
  100225. * Define the code related to the anisotropic parameters of the pbr material.
  100226. */
  100227. export class PBRAnisotropicConfiguration {
  100228. private _isEnabled;
  100229. /**
  100230. * Defines if the anisotropy is enabled in the material.
  100231. */
  100232. isEnabled: boolean;
  100233. /**
  100234. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100235. */
  100236. intensity: number;
  100237. /**
  100238. * Defines if the effect is along the tangents or bitangents.
  100239. * By default, the effect is "strectching" the highlights along the tangents.
  100240. */
  100241. followTangents: boolean;
  100242. /** @hidden */
  100243. private _internalMarkAllSubMeshesAsMiscDirty;
  100244. /** @hidden */
  100245. _markAllSubMeshesAsMiscDirty(): void;
  100246. /**
  100247. * Instantiate a new istance of clear coat configuration.
  100248. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100249. */
  100250. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100251. /**
  100252. * Checks to see if a texture is used in the material.
  100253. * @param defines the list of "defines" to update.
  100254. * @param mesh the mesh we are preparing the defines for.
  100255. */
  100256. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  100257. /**
  100258. * Binds the material data.
  100259. * @param uniformBuffer defines the Uniform buffer to fill in.
  100260. * @param isFrozen defines wether the material is frozen or not.
  100261. */
  100262. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  100263. /**
  100264. * Get the current class name of the texture useful for serialization or dynamic coding.
  100265. * @returns "PBRAnisotropicConfiguration"
  100266. */
  100267. getClassName(): string;
  100268. /**
  100269. * Makes a duplicate of the current configuration into another one.
  100270. * @param anisotropicConfiguration define the config where to copy the info
  100271. */
  100272. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100273. /**
  100274. * Serializes this clear coat configuration.
  100275. * @returns - An object with the serialized config.
  100276. */
  100277. serialize(): any;
  100278. /**
  100279. * Parses a Clear Coat Configuration from a serialized object.
  100280. * @param source - Serialized object.
  100281. */
  100282. parse(source: any): void;
  100283. /**
  100284. * Add fallbacks to the effect fallbacks list.
  100285. * @param defines defines the Base texture to use.
  100286. * @param fallbacks defines the current fallback list.
  100287. * @param currentRank defines the current fallback rank.
  100288. * @returns the new fallback rank.
  100289. */
  100290. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100291. /**
  100292. * Add the required uniforms to the current list.
  100293. * @param uniforms defines the current uniform list.
  100294. */
  100295. static AddUniforms(uniforms: string[]): void;
  100296. /**
  100297. * Add the required uniforms to the current buffer.
  100298. * @param uniformBuffer defines the current uniform buffer.
  100299. */
  100300. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100301. }
  100302. }
  100303. declare module BABYLON {
  100304. /**
  100305. * @hidden
  100306. */
  100307. export interface IMaterialBRDFDefines {
  100308. BRDF_V_HEIGHT_CORRELATED: boolean;
  100309. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100310. /** @hidden */
  100311. _areMiscDirty: boolean;
  100312. }
  100313. /**
  100314. * Define the code related to the BRDF parameters of the pbr material.
  100315. */
  100316. export class PBRBRDFConfiguration {
  100317. private _useEnergyConservation;
  100318. /**
  100319. * Defines if the material uses energy conservation.
  100320. */
  100321. useEnergyConservation: boolean;
  100322. private _useSmithVisibilityHeightCorrelated;
  100323. /**
  100324. * LEGACY Mode set to false
  100325. * Defines if the material uses height smith correlated visibility term.
  100326. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100327. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100328. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100329. * Not relying on height correlated will also disable energy conservation.
  100330. */
  100331. useSmithVisibilityHeightCorrelated: boolean;
  100332. /** @hidden */
  100333. private _internalMarkAllSubMeshesAsMiscDirty;
  100334. /** @hidden */
  100335. _markAllSubMeshesAsMiscDirty(): void;
  100336. /**
  100337. * Instantiate a new istance of clear coat configuration.
  100338. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100339. */
  100340. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100341. /**
  100342. * Checks to see if a texture is used in the material.
  100343. * @param defines the list of "defines" to update.
  100344. */
  100345. prepareDefines(defines: IMaterialBRDFDefines): void;
  100346. /**
  100347. * Get the current class name of the texture useful for serialization or dynamic coding.
  100348. * @returns "PBRClearCoatConfiguration"
  100349. */
  100350. getClassName(): string;
  100351. /**
  100352. * Makes a duplicate of the current configuration into another one.
  100353. * @param brdfConfiguration define the config where to copy the info
  100354. */
  100355. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100356. /**
  100357. * Serializes this BRDF configuration.
  100358. * @returns - An object with the serialized config.
  100359. */
  100360. serialize(): any;
  100361. /**
  100362. * Parses a BRDF Configuration from a serialized object.
  100363. * @param source - Serialized object.
  100364. */
  100365. parse(source: any): void;
  100366. }
  100367. }
  100368. declare module BABYLON {
  100369. /** @hidden */
  100370. export var pbrFragmentDeclaration: {
  100371. name: string;
  100372. shader: string;
  100373. };
  100374. }
  100375. declare module BABYLON {
  100376. /** @hidden */
  100377. export var pbrUboDeclaration: {
  100378. name: string;
  100379. shader: string;
  100380. };
  100381. }
  100382. declare module BABYLON {
  100383. /** @hidden */
  100384. export var pbrFunctions: {
  100385. name: string;
  100386. shader: string;
  100387. };
  100388. }
  100389. declare module BABYLON {
  100390. /** @hidden */
  100391. export var harmonicsFunctions: {
  100392. name: string;
  100393. shader: string;
  100394. };
  100395. }
  100396. declare module BABYLON {
  100397. /** @hidden */
  100398. export var pbrPreLightingFunctions: {
  100399. name: string;
  100400. shader: string;
  100401. };
  100402. }
  100403. declare module BABYLON {
  100404. /** @hidden */
  100405. export var pbrFalloffLightingFunctions: {
  100406. name: string;
  100407. shader: string;
  100408. };
  100409. }
  100410. declare module BABYLON {
  100411. /** @hidden */
  100412. export var pbrLightingFunctions: {
  100413. name: string;
  100414. shader: string;
  100415. };
  100416. }
  100417. declare module BABYLON {
  100418. /** @hidden */
  100419. export var pbrDebug: {
  100420. name: string;
  100421. shader: string;
  100422. };
  100423. }
  100424. declare module BABYLON {
  100425. /** @hidden */
  100426. export var pbrPixelShader: {
  100427. name: string;
  100428. shader: string;
  100429. };
  100430. }
  100431. declare module BABYLON {
  100432. /** @hidden */
  100433. export var pbrVertexDeclaration: {
  100434. name: string;
  100435. shader: string;
  100436. };
  100437. }
  100438. declare module BABYLON {
  100439. /** @hidden */
  100440. export var pbrVertexShader: {
  100441. name: string;
  100442. shader: string;
  100443. };
  100444. }
  100445. declare module BABYLON {
  100446. /**
  100447. * The Physically based material base class of BJS.
  100448. *
  100449. * This offers the main features of a standard PBR material.
  100450. * For more information, please refer to the documentation :
  100451. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100452. */
  100453. export abstract class PBRBaseMaterial extends PushMaterial {
  100454. /**
  100455. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100456. */
  100457. static readonly PBRMATERIAL_OPAQUE: number;
  100458. /**
  100459. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100460. */
  100461. static readonly PBRMATERIAL_ALPHATEST: number;
  100462. /**
  100463. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100464. */
  100465. static readonly PBRMATERIAL_ALPHABLEND: number;
  100466. /**
  100467. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100468. * They are also discarded below the alpha cutoff threshold to improve performances.
  100469. */
  100470. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100471. /**
  100472. * Defines the default value of how much AO map is occluding the analytical lights
  100473. * (point spot...).
  100474. */
  100475. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100476. /**
  100477. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100478. */
  100479. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100480. /**
  100481. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100482. * to enhance interoperability with other engines.
  100483. */
  100484. static readonly LIGHTFALLOFF_GLTF: number;
  100485. /**
  100486. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100487. * to enhance interoperability with other materials.
  100488. */
  100489. static readonly LIGHTFALLOFF_STANDARD: number;
  100490. /**
  100491. * Intensity of the direct lights e.g. the four lights available in your scene.
  100492. * This impacts both the direct diffuse and specular highlights.
  100493. */
  100494. protected _directIntensity: number;
  100495. /**
  100496. * Intensity of the emissive part of the material.
  100497. * This helps controlling the emissive effect without modifying the emissive color.
  100498. */
  100499. protected _emissiveIntensity: number;
  100500. /**
  100501. * Intensity of the environment e.g. how much the environment will light the object
  100502. * either through harmonics for rough material or through the refelction for shiny ones.
  100503. */
  100504. protected _environmentIntensity: number;
  100505. /**
  100506. * This is a special control allowing the reduction of the specular highlights coming from the
  100507. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100508. */
  100509. protected _specularIntensity: number;
  100510. /**
  100511. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100512. */
  100513. private _lightingInfos;
  100514. /**
  100515. * Debug Control allowing disabling the bump map on this material.
  100516. */
  100517. protected _disableBumpMap: boolean;
  100518. /**
  100519. * AKA Diffuse Texture in standard nomenclature.
  100520. */
  100521. protected _albedoTexture: BaseTexture;
  100522. /**
  100523. * AKA Occlusion Texture in other nomenclature.
  100524. */
  100525. protected _ambientTexture: BaseTexture;
  100526. /**
  100527. * AKA Occlusion Texture Intensity in other nomenclature.
  100528. */
  100529. protected _ambientTextureStrength: number;
  100530. /**
  100531. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100532. * 1 means it completely occludes it
  100533. * 0 mean it has no impact
  100534. */
  100535. protected _ambientTextureImpactOnAnalyticalLights: number;
  100536. /**
  100537. * Stores the alpha values in a texture.
  100538. */
  100539. protected _opacityTexture: BaseTexture;
  100540. /**
  100541. * Stores the reflection values in a texture.
  100542. */
  100543. protected _reflectionTexture: BaseTexture;
  100544. /**
  100545. * Stores the refraction values in a texture.
  100546. */
  100547. protected _refractionTexture: BaseTexture;
  100548. /**
  100549. * Stores the emissive values in a texture.
  100550. */
  100551. protected _emissiveTexture: BaseTexture;
  100552. /**
  100553. * AKA Specular texture in other nomenclature.
  100554. */
  100555. protected _reflectivityTexture: BaseTexture;
  100556. /**
  100557. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100558. */
  100559. protected _metallicTexture: BaseTexture;
  100560. /**
  100561. * Specifies the metallic scalar of the metallic/roughness workflow.
  100562. * Can also be used to scale the metalness values of the metallic texture.
  100563. */
  100564. protected _metallic: Nullable<number>;
  100565. /**
  100566. * Specifies the roughness scalar of the metallic/roughness workflow.
  100567. * Can also be used to scale the roughness values of the metallic texture.
  100568. */
  100569. protected _roughness: Nullable<number>;
  100570. /**
  100571. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100572. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100573. */
  100574. protected _microSurfaceTexture: BaseTexture;
  100575. /**
  100576. * Stores surface normal data used to displace a mesh in a texture.
  100577. */
  100578. protected _bumpTexture: BaseTexture;
  100579. /**
  100580. * Stores the pre-calculated light information of a mesh in a texture.
  100581. */
  100582. protected _lightmapTexture: BaseTexture;
  100583. /**
  100584. * The color of a material in ambient lighting.
  100585. */
  100586. protected _ambientColor: Color3;
  100587. /**
  100588. * AKA Diffuse Color in other nomenclature.
  100589. */
  100590. protected _albedoColor: Color3;
  100591. /**
  100592. * AKA Specular Color in other nomenclature.
  100593. */
  100594. protected _reflectivityColor: Color3;
  100595. /**
  100596. * The color applied when light is reflected from a material.
  100597. */
  100598. protected _reflectionColor: Color3;
  100599. /**
  100600. * The color applied when light is emitted from a material.
  100601. */
  100602. protected _emissiveColor: Color3;
  100603. /**
  100604. * AKA Glossiness in other nomenclature.
  100605. */
  100606. protected _microSurface: number;
  100607. /**
  100608. * source material index of refraction (IOR)' / 'destination material IOR.
  100609. */
  100610. protected _indexOfRefraction: number;
  100611. /**
  100612. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100613. */
  100614. protected _invertRefractionY: boolean;
  100615. /**
  100616. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100617. * Materials half opaque for instance using refraction could benefit from this control.
  100618. */
  100619. protected _linkRefractionWithTransparency: boolean;
  100620. /**
  100621. * Specifies that the material will use the light map as a show map.
  100622. */
  100623. protected _useLightmapAsShadowmap: boolean;
  100624. /**
  100625. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100626. * makes the reflect vector face the model (under horizon).
  100627. */
  100628. protected _useHorizonOcclusion: boolean;
  100629. /**
  100630. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100631. * too much the area relying on ambient texture to define their ambient occlusion.
  100632. */
  100633. protected _useRadianceOcclusion: boolean;
  100634. /**
  100635. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100636. */
  100637. protected _useAlphaFromAlbedoTexture: boolean;
  100638. /**
  100639. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  100640. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100641. */
  100642. protected _useSpecularOverAlpha: boolean;
  100643. /**
  100644. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100645. */
  100646. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100647. /**
  100648. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100649. */
  100650. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  100651. /**
  100652. * Specifies if the metallic texture contains the roughness information in its green channel.
  100653. */
  100654. protected _useRoughnessFromMetallicTextureGreen: boolean;
  100655. /**
  100656. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100657. */
  100658. protected _useMetallnessFromMetallicTextureBlue: boolean;
  100659. /**
  100660. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100661. */
  100662. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  100663. /**
  100664. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100665. */
  100666. protected _useAmbientInGrayScale: boolean;
  100667. /**
  100668. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100669. * The material will try to infer what glossiness each pixel should be.
  100670. */
  100671. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  100672. /**
  100673. * Defines the falloff type used in this material.
  100674. * It by default is Physical.
  100675. */
  100676. protected _lightFalloff: number;
  100677. /**
  100678. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100679. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100680. */
  100681. protected _useRadianceOverAlpha: boolean;
  100682. /**
  100683. * Allows using an object space normal map (instead of tangent space).
  100684. */
  100685. protected _useObjectSpaceNormalMap: boolean;
  100686. /**
  100687. * Allows using the bump map in parallax mode.
  100688. */
  100689. protected _useParallax: boolean;
  100690. /**
  100691. * Allows using the bump map in parallax occlusion mode.
  100692. */
  100693. protected _useParallaxOcclusion: boolean;
  100694. /**
  100695. * Controls the scale bias of the parallax mode.
  100696. */
  100697. protected _parallaxScaleBias: number;
  100698. /**
  100699. * If sets to true, disables all the lights affecting the material.
  100700. */
  100701. protected _disableLighting: boolean;
  100702. /**
  100703. * Number of Simultaneous lights allowed on the material.
  100704. */
  100705. protected _maxSimultaneousLights: number;
  100706. /**
  100707. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100708. */
  100709. protected _invertNormalMapX: boolean;
  100710. /**
  100711. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100712. */
  100713. protected _invertNormalMapY: boolean;
  100714. /**
  100715. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100716. */
  100717. protected _twoSidedLighting: boolean;
  100718. /**
  100719. * Defines the alpha limits in alpha test mode.
  100720. */
  100721. protected _alphaCutOff: number;
  100722. /**
  100723. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100724. */
  100725. protected _forceAlphaTest: boolean;
  100726. /**
  100727. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100728. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100729. */
  100730. protected _useAlphaFresnel: boolean;
  100731. /**
  100732. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100733. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100734. */
  100735. protected _useLinearAlphaFresnel: boolean;
  100736. /**
  100737. * The transparency mode of the material.
  100738. */
  100739. protected _transparencyMode: Nullable<number>;
  100740. /**
  100741. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  100742. * from cos thetav and roughness:
  100743. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  100744. */
  100745. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  100746. /**
  100747. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100748. */
  100749. protected _forceIrradianceInFragment: boolean;
  100750. /**
  100751. * Force normal to face away from face.
  100752. */
  100753. protected _forceNormalForward: boolean;
  100754. /**
  100755. * Enables specular anti aliasing in the PBR shader.
  100756. * It will both interacts on the Geometry for analytical and IBL lighting.
  100757. * It also prefilter the roughness map based on the bump values.
  100758. */
  100759. protected _enableSpecularAntiAliasing: boolean;
  100760. /**
  100761. * Default configuration related to image processing available in the PBR Material.
  100762. */
  100763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100764. /**
  100765. * Keep track of the image processing observer to allow dispose and replace.
  100766. */
  100767. private _imageProcessingObserver;
  100768. /**
  100769. * Attaches a new image processing configuration to the PBR Material.
  100770. * @param configuration
  100771. */
  100772. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100773. /**
  100774. * Stores the available render targets.
  100775. */
  100776. private _renderTargets;
  100777. /**
  100778. * Sets the global ambient color for the material used in lighting calculations.
  100779. */
  100780. private _globalAmbientColor;
  100781. /**
  100782. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  100783. */
  100784. private _useLogarithmicDepth;
  100785. /**
  100786. * If set to true, no lighting calculations will be applied.
  100787. */
  100788. private _unlit;
  100789. private _debugMode;
  100790. /**
  100791. * @hidden
  100792. * This is reserved for the inspector.
  100793. * Defines the material debug mode.
  100794. * It helps seeing only some components of the material while troubleshooting.
  100795. */
  100796. debugMode: number;
  100797. /**
  100798. * @hidden
  100799. * This is reserved for the inspector.
  100800. * Specify from where on screen the debug mode should start.
  100801. * The value goes from -1 (full screen) to 1 (not visible)
  100802. * It helps with side by side comparison against the final render
  100803. * This defaults to -1
  100804. */
  100805. private debugLimit;
  100806. /**
  100807. * @hidden
  100808. * This is reserved for the inspector.
  100809. * As the default viewing range might not be enough (if the ambient is really small for instance)
  100810. * You can use the factor to better multiply the final value.
  100811. */
  100812. private debugFactor;
  100813. /**
  100814. * Defines the clear coat layer parameters for the material.
  100815. */
  100816. readonly clearCoat: PBRClearCoatConfiguration;
  100817. /**
  100818. * Defines the anisotropic parameters for the material.
  100819. */
  100820. readonly anisotropy: PBRAnisotropicConfiguration;
  100821. /**
  100822. * Defines the BRDF parameters for the material.
  100823. */
  100824. readonly brdf: PBRBRDFConfiguration;
  100825. /**
  100826. * Instantiates a new PBRMaterial instance.
  100827. *
  100828. * @param name The material name
  100829. * @param scene The scene the material will be use in.
  100830. */
  100831. constructor(name: string, scene: Scene);
  100832. /**
  100833. * Gets a boolean indicating that current material needs to register RTT
  100834. */
  100835. readonly hasRenderTargetTextures: boolean;
  100836. /**
  100837. * Gets the name of the material class.
  100838. */
  100839. getClassName(): string;
  100840. /**
  100841. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100842. */
  100843. /**
  100844. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100845. */
  100846. useLogarithmicDepth: boolean;
  100847. /**
  100848. * Gets the current transparency mode.
  100849. */
  100850. /**
  100851. * Sets the transparency mode of the material.
  100852. *
  100853. * | Value | Type | Description |
  100854. * | ----- | ----------------------------------- | ----------- |
  100855. * | 0 | OPAQUE | |
  100856. * | 1 | ALPHATEST | |
  100857. * | 2 | ALPHABLEND | |
  100858. * | 3 | ALPHATESTANDBLEND | |
  100859. *
  100860. */
  100861. transparencyMode: Nullable<number>;
  100862. /**
  100863. * Returns true if alpha blending should be disabled.
  100864. */
  100865. private readonly _disableAlphaBlending;
  100866. /**
  100867. * Specifies whether or not this material should be rendered in alpha blend mode.
  100868. */
  100869. needAlphaBlending(): boolean;
  100870. /**
  100871. * Specifies if the mesh will require alpha blending.
  100872. * @param mesh - BJS mesh.
  100873. */
  100874. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100875. /**
  100876. * Specifies whether or not this material should be rendered in alpha test mode.
  100877. */
  100878. needAlphaTesting(): boolean;
  100879. /**
  100880. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100881. */
  100882. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100883. /**
  100884. * Gets the texture used for the alpha test.
  100885. */
  100886. getAlphaTestTexture(): BaseTexture;
  100887. /**
  100888. * Specifies that the submesh is ready to be used.
  100889. * @param mesh - BJS mesh.
  100890. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100891. * @param useInstances - Specifies that instances should be used.
  100892. * @returns - boolean indicating that the submesh is ready or not.
  100893. */
  100894. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100895. /**
  100896. * Specifies if the material uses metallic roughness workflow.
  100897. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100898. */
  100899. isMetallicWorkflow(): boolean;
  100900. private _prepareEffect;
  100901. private _prepareDefines;
  100902. /**
  100903. * Force shader compilation
  100904. */
  100905. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100906. clipPlane: boolean;
  100907. }>): void;
  100908. /**
  100909. * Initializes the uniform buffer layout for the shader.
  100910. */
  100911. buildUniformLayout(): void;
  100912. /**
  100913. * Unbinds the textures.
  100914. */
  100915. unbind(): void;
  100916. /**
  100917. * Binds the submesh data.
  100918. * @param world - The world matrix.
  100919. * @param mesh - The BJS mesh.
  100920. * @param subMesh - A submesh of the BJS mesh.
  100921. */
  100922. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100923. /**
  100924. * Returns the animatable textures.
  100925. * @returns - Array of animatable textures.
  100926. */
  100927. getAnimatables(): IAnimatable[];
  100928. /**
  100929. * Returns the texture used for reflections.
  100930. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100931. */
  100932. private _getReflectionTexture;
  100933. /**
  100934. * Returns the texture used for refraction or null if none is used.
  100935. * @returns - Refection texture if present. If no refraction texture and refraction
  100936. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100937. */
  100938. private _getRefractionTexture;
  100939. /**
  100940. * Returns an array of the actively used textures.
  100941. * @returns - Array of BaseTextures
  100942. */
  100943. getActiveTextures(): BaseTexture[];
  100944. /**
  100945. * Checks to see if a texture is used in the material.
  100946. * @param texture - Base texture to use.
  100947. * @returns - Boolean specifying if a texture is used in the material.
  100948. */
  100949. hasTexture(texture: BaseTexture): boolean;
  100950. /**
  100951. * Disposes the resources of the material.
  100952. * @param forceDisposeEffect - Forces the disposal of effects.
  100953. * @param forceDisposeTextures - Forces the disposal of all textures.
  100954. */
  100955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100956. }
  100957. }
  100958. declare module BABYLON {
  100959. /**
  100960. * The Physically based material of BJS.
  100961. *
  100962. * This offers the main features of a standard PBR material.
  100963. * For more information, please refer to the documentation :
  100964. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100965. */
  100966. export class PBRMaterial extends PBRBaseMaterial {
  100967. /**
  100968. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100969. */
  100970. static readonly PBRMATERIAL_OPAQUE: number;
  100971. /**
  100972. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100973. */
  100974. static readonly PBRMATERIAL_ALPHATEST: number;
  100975. /**
  100976. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100977. */
  100978. static readonly PBRMATERIAL_ALPHABLEND: number;
  100979. /**
  100980. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100981. * They are also discarded below the alpha cutoff threshold to improve performances.
  100982. */
  100983. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100984. /**
  100985. * Defines the default value of how much AO map is occluding the analytical lights
  100986. * (point spot...).
  100987. */
  100988. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100989. /**
  100990. * Intensity of the direct lights e.g. the four lights available in your scene.
  100991. * This impacts both the direct diffuse and specular highlights.
  100992. */
  100993. directIntensity: number;
  100994. /**
  100995. * Intensity of the emissive part of the material.
  100996. * This helps controlling the emissive effect without modifying the emissive color.
  100997. */
  100998. emissiveIntensity: number;
  100999. /**
  101000. * Intensity of the environment e.g. how much the environment will light the object
  101001. * either through harmonics for rough material or through the refelction for shiny ones.
  101002. */
  101003. environmentIntensity: number;
  101004. /**
  101005. * This is a special control allowing the reduction of the specular highlights coming from the
  101006. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101007. */
  101008. specularIntensity: number;
  101009. /**
  101010. * Debug Control allowing disabling the bump map on this material.
  101011. */
  101012. disableBumpMap: boolean;
  101013. /**
  101014. * AKA Diffuse Texture in standard nomenclature.
  101015. */
  101016. albedoTexture: BaseTexture;
  101017. /**
  101018. * AKA Occlusion Texture in other nomenclature.
  101019. */
  101020. ambientTexture: BaseTexture;
  101021. /**
  101022. * AKA Occlusion Texture Intensity in other nomenclature.
  101023. */
  101024. ambientTextureStrength: number;
  101025. /**
  101026. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101027. * 1 means it completely occludes it
  101028. * 0 mean it has no impact
  101029. */
  101030. ambientTextureImpactOnAnalyticalLights: number;
  101031. /**
  101032. * Stores the alpha values in a texture.
  101033. */
  101034. opacityTexture: BaseTexture;
  101035. /**
  101036. * Stores the reflection values in a texture.
  101037. */
  101038. reflectionTexture: Nullable<BaseTexture>;
  101039. /**
  101040. * Stores the emissive values in a texture.
  101041. */
  101042. emissiveTexture: BaseTexture;
  101043. /**
  101044. * AKA Specular texture in other nomenclature.
  101045. */
  101046. reflectivityTexture: BaseTexture;
  101047. /**
  101048. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101049. */
  101050. metallicTexture: BaseTexture;
  101051. /**
  101052. * Specifies the metallic scalar of the metallic/roughness workflow.
  101053. * Can also be used to scale the metalness values of the metallic texture.
  101054. */
  101055. metallic: Nullable<number>;
  101056. /**
  101057. * Specifies the roughness scalar of the metallic/roughness workflow.
  101058. * Can also be used to scale the roughness values of the metallic texture.
  101059. */
  101060. roughness: Nullable<number>;
  101061. /**
  101062. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101063. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101064. */
  101065. microSurfaceTexture: BaseTexture;
  101066. /**
  101067. * Stores surface normal data used to displace a mesh in a texture.
  101068. */
  101069. bumpTexture: BaseTexture;
  101070. /**
  101071. * Stores the pre-calculated light information of a mesh in a texture.
  101072. */
  101073. lightmapTexture: BaseTexture;
  101074. /**
  101075. * Stores the refracted light information in a texture.
  101076. */
  101077. refractionTexture: BaseTexture;
  101078. /**
  101079. * The color of a material in ambient lighting.
  101080. */
  101081. ambientColor: Color3;
  101082. /**
  101083. * AKA Diffuse Color in other nomenclature.
  101084. */
  101085. albedoColor: Color3;
  101086. /**
  101087. * AKA Specular Color in other nomenclature.
  101088. */
  101089. reflectivityColor: Color3;
  101090. /**
  101091. * The color reflected from the material.
  101092. */
  101093. reflectionColor: Color3;
  101094. /**
  101095. * The color emitted from the material.
  101096. */
  101097. emissiveColor: Color3;
  101098. /**
  101099. * AKA Glossiness in other nomenclature.
  101100. */
  101101. microSurface: number;
  101102. /**
  101103. * source material index of refraction (IOR)' / 'destination material IOR.
  101104. */
  101105. indexOfRefraction: number;
  101106. /**
  101107. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101108. */
  101109. invertRefractionY: boolean;
  101110. /**
  101111. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101112. * Materials half opaque for instance using refraction could benefit from this control.
  101113. */
  101114. linkRefractionWithTransparency: boolean;
  101115. /**
  101116. * If true, the light map contains occlusion information instead of lighting info.
  101117. */
  101118. useLightmapAsShadowmap: boolean;
  101119. /**
  101120. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101121. */
  101122. useAlphaFromAlbedoTexture: boolean;
  101123. /**
  101124. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101125. */
  101126. forceAlphaTest: boolean;
  101127. /**
  101128. * Defines the alpha limits in alpha test mode.
  101129. */
  101130. alphaCutOff: number;
  101131. /**
  101132. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101133. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101134. */
  101135. useSpecularOverAlpha: boolean;
  101136. /**
  101137. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101138. */
  101139. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101140. /**
  101141. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101142. */
  101143. useRoughnessFromMetallicTextureAlpha: boolean;
  101144. /**
  101145. * Specifies if the metallic texture contains the roughness information in its green channel.
  101146. */
  101147. useRoughnessFromMetallicTextureGreen: boolean;
  101148. /**
  101149. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101150. */
  101151. useMetallnessFromMetallicTextureBlue: boolean;
  101152. /**
  101153. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101154. */
  101155. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101156. /**
  101157. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101158. */
  101159. useAmbientInGrayScale: boolean;
  101160. /**
  101161. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101162. * The material will try to infer what glossiness each pixel should be.
  101163. */
  101164. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101165. /**
  101166. * BJS is using an harcoded light falloff based on a manually sets up range.
  101167. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101168. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101169. */
  101170. /**
  101171. * BJS is using an harcoded light falloff based on a manually sets up range.
  101172. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101173. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101174. */
  101175. usePhysicalLightFalloff: boolean;
  101176. /**
  101177. * In order to support the falloff compatibility with gltf, a special mode has been added
  101178. * to reproduce the gltf light falloff.
  101179. */
  101180. /**
  101181. * In order to support the falloff compatibility with gltf, a special mode has been added
  101182. * to reproduce the gltf light falloff.
  101183. */
  101184. useGLTFLightFalloff: boolean;
  101185. /**
  101186. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101187. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101188. */
  101189. useRadianceOverAlpha: boolean;
  101190. /**
  101191. * Allows using an object space normal map (instead of tangent space).
  101192. */
  101193. useObjectSpaceNormalMap: boolean;
  101194. /**
  101195. * Allows using the bump map in parallax mode.
  101196. */
  101197. useParallax: boolean;
  101198. /**
  101199. * Allows using the bump map in parallax occlusion mode.
  101200. */
  101201. useParallaxOcclusion: boolean;
  101202. /**
  101203. * Controls the scale bias of the parallax mode.
  101204. */
  101205. parallaxScaleBias: number;
  101206. /**
  101207. * If sets to true, disables all the lights affecting the material.
  101208. */
  101209. disableLighting: boolean;
  101210. /**
  101211. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101212. */
  101213. forceIrradianceInFragment: boolean;
  101214. /**
  101215. * Number of Simultaneous lights allowed on the material.
  101216. */
  101217. maxSimultaneousLights: number;
  101218. /**
  101219. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101220. */
  101221. invertNormalMapX: boolean;
  101222. /**
  101223. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101224. */
  101225. invertNormalMapY: boolean;
  101226. /**
  101227. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101228. */
  101229. twoSidedLighting: boolean;
  101230. /**
  101231. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101232. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101233. */
  101234. useAlphaFresnel: boolean;
  101235. /**
  101236. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101237. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101238. */
  101239. useLinearAlphaFresnel: boolean;
  101240. /**
  101241. * Let user defines the brdf lookup texture used for IBL.
  101242. * A default 8bit version is embedded but you could point at :
  101243. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101244. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101245. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101246. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101247. */
  101248. environmentBRDFTexture: Nullable<BaseTexture>;
  101249. /**
  101250. * Force normal to face away from face.
  101251. */
  101252. forceNormalForward: boolean;
  101253. /**
  101254. * Enables specular anti aliasing in the PBR shader.
  101255. * It will both interacts on the Geometry for analytical and IBL lighting.
  101256. * It also prefilter the roughness map based on the bump values.
  101257. */
  101258. enableSpecularAntiAliasing: boolean;
  101259. /**
  101260. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101261. * makes the reflect vector face the model (under horizon).
  101262. */
  101263. useHorizonOcclusion: boolean;
  101264. /**
  101265. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101266. * too much the area relying on ambient texture to define their ambient occlusion.
  101267. */
  101268. useRadianceOcclusion: boolean;
  101269. /**
  101270. * If set to true, no lighting calculations will be applied.
  101271. */
  101272. unlit: boolean;
  101273. /**
  101274. * Gets the image processing configuration used either in this material.
  101275. */
  101276. /**
  101277. * Sets the Default image processing configuration used either in the this material.
  101278. *
  101279. * If sets to null, the scene one is in use.
  101280. */
  101281. imageProcessingConfiguration: ImageProcessingConfiguration;
  101282. /**
  101283. * Gets wether the color curves effect is enabled.
  101284. */
  101285. /**
  101286. * Sets wether the color curves effect is enabled.
  101287. */
  101288. cameraColorCurvesEnabled: boolean;
  101289. /**
  101290. * Gets wether the color grading effect is enabled.
  101291. */
  101292. /**
  101293. * Gets wether the color grading effect is enabled.
  101294. */
  101295. cameraColorGradingEnabled: boolean;
  101296. /**
  101297. * Gets wether tonemapping is enabled or not.
  101298. */
  101299. /**
  101300. * Sets wether tonemapping is enabled or not
  101301. */
  101302. cameraToneMappingEnabled: boolean;
  101303. /**
  101304. * The camera exposure used on this material.
  101305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101306. * This corresponds to a photographic exposure.
  101307. */
  101308. /**
  101309. * The camera exposure used on this material.
  101310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101311. * This corresponds to a photographic exposure.
  101312. */
  101313. cameraExposure: number;
  101314. /**
  101315. * Gets The camera contrast used on this material.
  101316. */
  101317. /**
  101318. * Sets The camera contrast used on this material.
  101319. */
  101320. cameraContrast: number;
  101321. /**
  101322. * Gets the Color Grading 2D Lookup Texture.
  101323. */
  101324. /**
  101325. * Sets the Color Grading 2D Lookup Texture.
  101326. */
  101327. cameraColorGradingTexture: Nullable<BaseTexture>;
  101328. /**
  101329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101331. * 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;
  101332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101333. */
  101334. /**
  101335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101337. * 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;
  101338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101339. */
  101340. cameraColorCurves: Nullable<ColorCurves>;
  101341. /**
  101342. * Instantiates a new PBRMaterial instance.
  101343. *
  101344. * @param name The material name
  101345. * @param scene The scene the material will be use in.
  101346. */
  101347. constructor(name: string, scene: Scene);
  101348. /**
  101349. * Returns the name of this material class.
  101350. */
  101351. getClassName(): string;
  101352. /**
  101353. * Makes a duplicate of the current material.
  101354. * @param name - name to use for the new material.
  101355. */
  101356. clone(name: string): PBRMaterial;
  101357. /**
  101358. * Serializes this PBR Material.
  101359. * @returns - An object with the serialized material.
  101360. */
  101361. serialize(): any;
  101362. /**
  101363. * Parses a PBR Material from a serialized object.
  101364. * @param source - Serialized object.
  101365. * @param scene - BJS scene instance.
  101366. * @param rootUrl - url for the scene object
  101367. * @returns - PBRMaterial
  101368. */
  101369. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101370. }
  101371. }
  101372. declare module BABYLON {
  101373. /** @hidden */
  101374. export var _forceSceneHelpersToBundle: boolean;
  101375. interface Scene {
  101376. /**
  101377. * Creates a default light for the scene.
  101378. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  101379. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  101380. */
  101381. createDefaultLight(replace?: boolean): void;
  101382. /**
  101383. * Creates a default camera for the scene.
  101384. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  101385. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101386. * @param replace has default false, when true replaces the active camera in the scene
  101387. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  101388. */
  101389. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101390. /**
  101391. * Creates a default camera and a default light.
  101392. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  101393. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101394. * @param replace has the default false, when true replaces the active camera/light in the scene
  101395. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  101396. */
  101397. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101398. /**
  101399. * Creates a new sky box
  101400. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  101401. * @param environmentTexture defines the texture to use as environment texture
  101402. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  101403. * @param scale defines the overall scale of the skybox
  101404. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  101405. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  101406. * @returns a new mesh holding the sky box
  101407. */
  101408. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  101409. /**
  101410. * Creates a new environment
  101411. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  101412. * @param options defines the options you can use to configure the environment
  101413. * @returns the new EnvironmentHelper
  101414. */
  101415. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  101416. /**
  101417. * Creates a new VREXperienceHelper
  101418. * @see http://doc.babylonjs.com/how_to/webvr_helper
  101419. * @param webVROptions defines the options used to create the new VREXperienceHelper
  101420. * @returns a new VREXperienceHelper
  101421. */
  101422. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  101423. /**
  101424. * Creates a new XREXperienceHelper
  101425. * @see http://doc.babylonjs.com/how_to/webxr
  101426. * @returns a promise for a new XREXperienceHelper
  101427. */
  101428. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  101429. }
  101430. }
  101431. declare module BABYLON {
  101432. /**
  101433. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  101434. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  101435. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  101436. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101437. */
  101438. export class VideoDome extends TransformNode {
  101439. /**
  101440. * Define the video source as a Monoscopic panoramic 360 video.
  101441. */
  101442. static readonly MODE_MONOSCOPIC: number;
  101443. /**
  101444. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101445. */
  101446. static readonly MODE_TOPBOTTOM: number;
  101447. /**
  101448. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101449. */
  101450. static readonly MODE_SIDEBYSIDE: number;
  101451. private _useDirectMapping;
  101452. /**
  101453. * The video texture being displayed on the sphere
  101454. */
  101455. protected _videoTexture: VideoTexture;
  101456. /**
  101457. * Gets the video texture being displayed on the sphere
  101458. */
  101459. readonly videoTexture: VideoTexture;
  101460. /**
  101461. * The skybox material
  101462. */
  101463. protected _material: BackgroundMaterial;
  101464. /**
  101465. * The surface used for the skybox
  101466. */
  101467. protected _mesh: Mesh;
  101468. /**
  101469. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101470. * Also see the options.resolution property.
  101471. */
  101472. fovMultiplier: number;
  101473. private _videoMode;
  101474. /**
  101475. * Gets or set the current video mode for the video. It can be:
  101476. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  101477. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101478. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101479. */
  101480. videoMode: number;
  101481. /**
  101482. * Oberserver used in Stereoscopic VR Mode.
  101483. */
  101484. private _onBeforeCameraRenderObserver;
  101485. /**
  101486. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  101487. * @param name Element's name, child elements will append suffixes for their own names.
  101488. * @param urlsOrVideo defines the url(s) or the video element to use
  101489. * @param options An object containing optional or exposed sub element properties
  101490. */
  101491. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  101492. resolution?: number;
  101493. clickToPlay?: boolean;
  101494. autoPlay?: boolean;
  101495. loop?: boolean;
  101496. size?: number;
  101497. poster?: string;
  101498. useDirectMapping?: boolean;
  101499. }, scene: Scene);
  101500. private _changeVideoMode;
  101501. /**
  101502. * Releases resources associated with this node.
  101503. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101504. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101505. */
  101506. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101507. }
  101508. }
  101509. declare module BABYLON {
  101510. /**
  101511. * This class can be used to get instrumentation data from a Babylon engine
  101512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101513. */
  101514. export class EngineInstrumentation implements IDisposable {
  101515. /**
  101516. * Define the instrumented engine.
  101517. */
  101518. engine: Engine;
  101519. private _captureGPUFrameTime;
  101520. private _gpuFrameTimeToken;
  101521. private _gpuFrameTime;
  101522. private _captureShaderCompilationTime;
  101523. private _shaderCompilationTime;
  101524. private _onBeginFrameObserver;
  101525. private _onEndFrameObserver;
  101526. private _onBeforeShaderCompilationObserver;
  101527. private _onAfterShaderCompilationObserver;
  101528. /**
  101529. * Gets the perf counter used for GPU frame time
  101530. */
  101531. readonly gpuFrameTimeCounter: PerfCounter;
  101532. /**
  101533. * Gets the GPU frame time capture status
  101534. */
  101535. /**
  101536. * Enable or disable the GPU frame time capture
  101537. */
  101538. captureGPUFrameTime: boolean;
  101539. /**
  101540. * Gets the perf counter used for shader compilation time
  101541. */
  101542. readonly shaderCompilationTimeCounter: PerfCounter;
  101543. /**
  101544. * Gets the shader compilation time capture status
  101545. */
  101546. /**
  101547. * Enable or disable the shader compilation time capture
  101548. */
  101549. captureShaderCompilationTime: boolean;
  101550. /**
  101551. * Instantiates a new engine instrumentation.
  101552. * This class can be used to get instrumentation data from a Babylon engine
  101553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101554. * @param engine Defines the engine to instrument
  101555. */
  101556. constructor(
  101557. /**
  101558. * Define the instrumented engine.
  101559. */
  101560. engine: Engine);
  101561. /**
  101562. * Dispose and release associated resources.
  101563. */
  101564. dispose(): void;
  101565. }
  101566. }
  101567. declare module BABYLON {
  101568. /**
  101569. * This class can be used to get instrumentation data from a Babylon engine
  101570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101571. */
  101572. export class SceneInstrumentation implements IDisposable {
  101573. /**
  101574. * Defines the scene to instrument
  101575. */
  101576. scene: Scene;
  101577. private _captureActiveMeshesEvaluationTime;
  101578. private _activeMeshesEvaluationTime;
  101579. private _captureRenderTargetsRenderTime;
  101580. private _renderTargetsRenderTime;
  101581. private _captureFrameTime;
  101582. private _frameTime;
  101583. private _captureRenderTime;
  101584. private _renderTime;
  101585. private _captureInterFrameTime;
  101586. private _interFrameTime;
  101587. private _captureParticlesRenderTime;
  101588. private _particlesRenderTime;
  101589. private _captureSpritesRenderTime;
  101590. private _spritesRenderTime;
  101591. private _capturePhysicsTime;
  101592. private _physicsTime;
  101593. private _captureAnimationsTime;
  101594. private _animationsTime;
  101595. private _captureCameraRenderTime;
  101596. private _cameraRenderTime;
  101597. private _onBeforeActiveMeshesEvaluationObserver;
  101598. private _onAfterActiveMeshesEvaluationObserver;
  101599. private _onBeforeRenderTargetsRenderObserver;
  101600. private _onAfterRenderTargetsRenderObserver;
  101601. private _onAfterRenderObserver;
  101602. private _onBeforeDrawPhaseObserver;
  101603. private _onAfterDrawPhaseObserver;
  101604. private _onBeforeAnimationsObserver;
  101605. private _onBeforeParticlesRenderingObserver;
  101606. private _onAfterParticlesRenderingObserver;
  101607. private _onBeforeSpritesRenderingObserver;
  101608. private _onAfterSpritesRenderingObserver;
  101609. private _onBeforePhysicsObserver;
  101610. private _onAfterPhysicsObserver;
  101611. private _onAfterAnimationsObserver;
  101612. private _onBeforeCameraRenderObserver;
  101613. private _onAfterCameraRenderObserver;
  101614. /**
  101615. * Gets the perf counter used for active meshes evaluation time
  101616. */
  101617. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  101618. /**
  101619. * Gets the active meshes evaluation time capture status
  101620. */
  101621. /**
  101622. * Enable or disable the active meshes evaluation time capture
  101623. */
  101624. captureActiveMeshesEvaluationTime: boolean;
  101625. /**
  101626. * Gets the perf counter used for render targets render time
  101627. */
  101628. readonly renderTargetsRenderTimeCounter: PerfCounter;
  101629. /**
  101630. * Gets the render targets render time capture status
  101631. */
  101632. /**
  101633. * Enable or disable the render targets render time capture
  101634. */
  101635. captureRenderTargetsRenderTime: boolean;
  101636. /**
  101637. * Gets the perf counter used for particles render time
  101638. */
  101639. readonly particlesRenderTimeCounter: PerfCounter;
  101640. /**
  101641. * Gets the particles render time capture status
  101642. */
  101643. /**
  101644. * Enable or disable the particles render time capture
  101645. */
  101646. captureParticlesRenderTime: boolean;
  101647. /**
  101648. * Gets the perf counter used for sprites render time
  101649. */
  101650. readonly spritesRenderTimeCounter: PerfCounter;
  101651. /**
  101652. * Gets the sprites render time capture status
  101653. */
  101654. /**
  101655. * Enable or disable the sprites render time capture
  101656. */
  101657. captureSpritesRenderTime: boolean;
  101658. /**
  101659. * Gets the perf counter used for physics time
  101660. */
  101661. readonly physicsTimeCounter: PerfCounter;
  101662. /**
  101663. * Gets the physics time capture status
  101664. */
  101665. /**
  101666. * Enable or disable the physics time capture
  101667. */
  101668. capturePhysicsTime: boolean;
  101669. /**
  101670. * Gets the perf counter used for animations time
  101671. */
  101672. readonly animationsTimeCounter: PerfCounter;
  101673. /**
  101674. * Gets the animations time capture status
  101675. */
  101676. /**
  101677. * Enable or disable the animations time capture
  101678. */
  101679. captureAnimationsTime: boolean;
  101680. /**
  101681. * Gets the perf counter used for frame time capture
  101682. */
  101683. readonly frameTimeCounter: PerfCounter;
  101684. /**
  101685. * Gets the frame time capture status
  101686. */
  101687. /**
  101688. * Enable or disable the frame time capture
  101689. */
  101690. captureFrameTime: boolean;
  101691. /**
  101692. * Gets the perf counter used for inter-frames time capture
  101693. */
  101694. readonly interFrameTimeCounter: PerfCounter;
  101695. /**
  101696. * Gets the inter-frames time capture status
  101697. */
  101698. /**
  101699. * Enable or disable the inter-frames time capture
  101700. */
  101701. captureInterFrameTime: boolean;
  101702. /**
  101703. * Gets the perf counter used for render time capture
  101704. */
  101705. readonly renderTimeCounter: PerfCounter;
  101706. /**
  101707. * Gets the render time capture status
  101708. */
  101709. /**
  101710. * Enable or disable the render time capture
  101711. */
  101712. captureRenderTime: boolean;
  101713. /**
  101714. * Gets the perf counter used for camera render time capture
  101715. */
  101716. readonly cameraRenderTimeCounter: PerfCounter;
  101717. /**
  101718. * Gets the camera render time capture status
  101719. */
  101720. /**
  101721. * Enable or disable the camera render time capture
  101722. */
  101723. captureCameraRenderTime: boolean;
  101724. /**
  101725. * Gets the perf counter used for draw calls
  101726. */
  101727. readonly drawCallsCounter: PerfCounter;
  101728. /**
  101729. * Gets the perf counter used for texture collisions
  101730. */
  101731. readonly textureCollisionsCounter: PerfCounter;
  101732. /**
  101733. * Instantiates a new scene instrumentation.
  101734. * This class can be used to get instrumentation data from a Babylon engine
  101735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101736. * @param scene Defines the scene to instrument
  101737. */
  101738. constructor(
  101739. /**
  101740. * Defines the scene to instrument
  101741. */
  101742. scene: Scene);
  101743. /**
  101744. * Dispose and release associated resources.
  101745. */
  101746. dispose(): void;
  101747. }
  101748. }
  101749. declare module BABYLON {
  101750. /** @hidden */
  101751. export var glowMapGenerationPixelShader: {
  101752. name: string;
  101753. shader: string;
  101754. };
  101755. }
  101756. declare module BABYLON {
  101757. /** @hidden */
  101758. export var glowMapGenerationVertexShader: {
  101759. name: string;
  101760. shader: string;
  101761. };
  101762. }
  101763. declare module BABYLON {
  101764. /**
  101765. * Effect layer options. This helps customizing the behaviour
  101766. * of the effect layer.
  101767. */
  101768. export interface IEffectLayerOptions {
  101769. /**
  101770. * Multiplication factor apply to the canvas size to compute the render target size
  101771. * used to generated the objects (the smaller the faster).
  101772. */
  101773. mainTextureRatio: number;
  101774. /**
  101775. * Enforces a fixed size texture to ensure effect stability across devices.
  101776. */
  101777. mainTextureFixedSize?: number;
  101778. /**
  101779. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  101780. */
  101781. alphaBlendingMode: number;
  101782. /**
  101783. * The camera attached to the layer.
  101784. */
  101785. camera: Nullable<Camera>;
  101786. /**
  101787. * The rendering group to draw the layer in.
  101788. */
  101789. renderingGroupId: number;
  101790. }
  101791. /**
  101792. * The effect layer Helps adding post process effect blended with the main pass.
  101793. *
  101794. * This can be for instance use to generate glow or higlight effects on the scene.
  101795. *
  101796. * The effect layer class can not be used directly and is intented to inherited from to be
  101797. * customized per effects.
  101798. */
  101799. export abstract class EffectLayer {
  101800. private _vertexBuffers;
  101801. private _indexBuffer;
  101802. private _cachedDefines;
  101803. private _effectLayerMapGenerationEffect;
  101804. private _effectLayerOptions;
  101805. private _mergeEffect;
  101806. protected _scene: Scene;
  101807. protected _engine: Engine;
  101808. protected _maxSize: number;
  101809. protected _mainTextureDesiredSize: ISize;
  101810. protected _mainTexture: RenderTargetTexture;
  101811. protected _shouldRender: boolean;
  101812. protected _postProcesses: PostProcess[];
  101813. protected _textures: BaseTexture[];
  101814. protected _emissiveTextureAndColor: {
  101815. texture: Nullable<BaseTexture>;
  101816. color: Color4;
  101817. };
  101818. /**
  101819. * The name of the layer
  101820. */
  101821. name: string;
  101822. /**
  101823. * The clear color of the texture used to generate the glow map.
  101824. */
  101825. neutralColor: Color4;
  101826. /**
  101827. * Specifies wether the highlight layer is enabled or not.
  101828. */
  101829. isEnabled: boolean;
  101830. /**
  101831. * Gets the camera attached to the layer.
  101832. */
  101833. readonly camera: Nullable<Camera>;
  101834. /**
  101835. * Gets the rendering group id the layer should render in.
  101836. */
  101837. readonly renderingGroupId: number;
  101838. /**
  101839. * An event triggered when the effect layer has been disposed.
  101840. */
  101841. onDisposeObservable: Observable<EffectLayer>;
  101842. /**
  101843. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  101844. */
  101845. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  101846. /**
  101847. * An event triggered when the generated texture is being merged in the scene.
  101848. */
  101849. onBeforeComposeObservable: Observable<EffectLayer>;
  101850. /**
  101851. * An event triggered when the generated texture has been merged in the scene.
  101852. */
  101853. onAfterComposeObservable: Observable<EffectLayer>;
  101854. /**
  101855. * An event triggered when the efffect layer changes its size.
  101856. */
  101857. onSizeChangedObservable: Observable<EffectLayer>;
  101858. /** @hidden */
  101859. static _SceneComponentInitialization: (scene: Scene) => void;
  101860. /**
  101861. * Instantiates a new effect Layer and references it in the scene.
  101862. * @param name The name of the layer
  101863. * @param scene The scene to use the layer in
  101864. */
  101865. constructor(
  101866. /** The Friendly of the effect in the scene */
  101867. name: string, scene: Scene);
  101868. /**
  101869. * Get the effect name of the layer.
  101870. * @return The effect name
  101871. */
  101872. abstract getEffectName(): string;
  101873. /**
  101874. * Checks for the readiness of the element composing the layer.
  101875. * @param subMesh the mesh to check for
  101876. * @param useInstances specify wether or not to use instances to render the mesh
  101877. * @return true if ready otherwise, false
  101878. */
  101879. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101880. /**
  101881. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101882. * @returns true if the effect requires stencil during the main canvas render pass.
  101883. */
  101884. abstract needStencil(): boolean;
  101885. /**
  101886. * Create the merge effect. This is the shader use to blit the information back
  101887. * to the main canvas at the end of the scene rendering.
  101888. * @returns The effect containing the shader used to merge the effect on the main canvas
  101889. */
  101890. protected abstract _createMergeEffect(): Effect;
  101891. /**
  101892. * Creates the render target textures and post processes used in the effect layer.
  101893. */
  101894. protected abstract _createTextureAndPostProcesses(): void;
  101895. /**
  101896. * Implementation specific of rendering the generating effect on the main canvas.
  101897. * @param effect The effect used to render through
  101898. */
  101899. protected abstract _internalRender(effect: Effect): void;
  101900. /**
  101901. * Sets the required values for both the emissive texture and and the main color.
  101902. */
  101903. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101904. /**
  101905. * Free any resources and references associated to a mesh.
  101906. * Internal use
  101907. * @param mesh The mesh to free.
  101908. */
  101909. abstract _disposeMesh(mesh: Mesh): void;
  101910. /**
  101911. * Serializes this layer (Glow or Highlight for example)
  101912. * @returns a serialized layer object
  101913. */
  101914. abstract serialize?(): any;
  101915. /**
  101916. * Initializes the effect layer with the required options.
  101917. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  101918. */
  101919. protected _init(options: Partial<IEffectLayerOptions>): void;
  101920. /**
  101921. * Generates the index buffer of the full screen quad blending to the main canvas.
  101922. */
  101923. private _generateIndexBuffer;
  101924. /**
  101925. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  101926. */
  101927. private _genrateVertexBuffer;
  101928. /**
  101929. * Sets the main texture desired size which is the closest power of two
  101930. * of the engine canvas size.
  101931. */
  101932. private _setMainTextureSize;
  101933. /**
  101934. * Creates the main texture for the effect layer.
  101935. */
  101936. protected _createMainTexture(): void;
  101937. /**
  101938. * Adds specific effects defines.
  101939. * @param defines The defines to add specifics to.
  101940. */
  101941. protected _addCustomEffectDefines(defines: string[]): void;
  101942. /**
  101943. * Checks for the readiness of the element composing the layer.
  101944. * @param subMesh the mesh to check for
  101945. * @param useInstances specify wether or not to use instances to render the mesh
  101946. * @param emissiveTexture the associated emissive texture used to generate the glow
  101947. * @return true if ready otherwise, false
  101948. */
  101949. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101950. /**
  101951. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101952. */
  101953. render(): void;
  101954. /**
  101955. * Determine if a given mesh will be used in the current effect.
  101956. * @param mesh mesh to test
  101957. * @returns true if the mesh will be used
  101958. */
  101959. hasMesh(mesh: AbstractMesh): boolean;
  101960. /**
  101961. * Returns true if the layer contains information to display, otherwise false.
  101962. * @returns true if the glow layer should be rendered
  101963. */
  101964. shouldRender(): boolean;
  101965. /**
  101966. * Returns true if the mesh should render, otherwise false.
  101967. * @param mesh The mesh to render
  101968. * @returns true if it should render otherwise false
  101969. */
  101970. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101971. /**
  101972. * Returns true if the mesh can be rendered, otherwise false.
  101973. * @param mesh The mesh to render
  101974. * @param material The material used on the mesh
  101975. * @returns true if it can be rendered otherwise false
  101976. */
  101977. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101978. /**
  101979. * Returns true if the mesh should render, otherwise false.
  101980. * @param mesh The mesh to render
  101981. * @returns true if it should render otherwise false
  101982. */
  101983. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101984. /**
  101985. * Renders the submesh passed in parameter to the generation map.
  101986. */
  101987. protected _renderSubMesh(subMesh: SubMesh): void;
  101988. /**
  101989. * Rebuild the required buffers.
  101990. * @hidden Internal use only.
  101991. */
  101992. _rebuild(): void;
  101993. /**
  101994. * Dispose only the render target textures and post process.
  101995. */
  101996. private _disposeTextureAndPostProcesses;
  101997. /**
  101998. * Dispose the highlight layer and free resources.
  101999. */
  102000. dispose(): void;
  102001. /**
  102002. * Gets the class name of the effect layer
  102003. * @returns the string with the class name of the effect layer
  102004. */
  102005. getClassName(): string;
  102006. /**
  102007. * Creates an effect layer from parsed effect layer data
  102008. * @param parsedEffectLayer defines effect layer data
  102009. * @param scene defines the current scene
  102010. * @param rootUrl defines the root URL containing the effect layer information
  102011. * @returns a parsed effect Layer
  102012. */
  102013. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102014. }
  102015. }
  102016. declare module BABYLON {
  102017. interface AbstractScene {
  102018. /**
  102019. * The list of effect layers (highlights/glow) added to the scene
  102020. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102021. * @see http://doc.babylonjs.com/how_to/glow_layer
  102022. */
  102023. effectLayers: Array<EffectLayer>;
  102024. /**
  102025. * Removes the given effect layer from this scene.
  102026. * @param toRemove defines the effect layer to remove
  102027. * @returns the index of the removed effect layer
  102028. */
  102029. removeEffectLayer(toRemove: EffectLayer): number;
  102030. /**
  102031. * Adds the given effect layer to this scene
  102032. * @param newEffectLayer defines the effect layer to add
  102033. */
  102034. addEffectLayer(newEffectLayer: EffectLayer): void;
  102035. }
  102036. /**
  102037. * Defines the layer scene component responsible to manage any effect layers
  102038. * in a given scene.
  102039. */
  102040. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102041. /**
  102042. * The component name helpfull to identify the component in the list of scene components.
  102043. */
  102044. readonly name: string;
  102045. /**
  102046. * The scene the component belongs to.
  102047. */
  102048. scene: Scene;
  102049. private _engine;
  102050. private _renderEffects;
  102051. private _needStencil;
  102052. private _previousStencilState;
  102053. /**
  102054. * Creates a new instance of the component for the given scene
  102055. * @param scene Defines the scene to register the component in
  102056. */
  102057. constructor(scene: Scene);
  102058. /**
  102059. * Registers the component in a given scene
  102060. */
  102061. register(): void;
  102062. /**
  102063. * Rebuilds the elements related to this component in case of
  102064. * context lost for instance.
  102065. */
  102066. rebuild(): void;
  102067. /**
  102068. * Serializes the component data to the specified json object
  102069. * @param serializationObject The object to serialize to
  102070. */
  102071. serialize(serializationObject: any): void;
  102072. /**
  102073. * Adds all the element from the container to the scene
  102074. * @param container the container holding the elements
  102075. */
  102076. addFromContainer(container: AbstractScene): void;
  102077. /**
  102078. * Removes all the elements in the container from the scene
  102079. * @param container contains the elements to remove
  102080. */
  102081. removeFromContainer(container: AbstractScene): void;
  102082. /**
  102083. * Disposes the component and the associated ressources.
  102084. */
  102085. dispose(): void;
  102086. private _isReadyForMesh;
  102087. private _renderMainTexture;
  102088. private _setStencil;
  102089. private _setStencilBack;
  102090. private _draw;
  102091. private _drawCamera;
  102092. private _drawRenderingGroup;
  102093. }
  102094. }
  102095. declare module BABYLON {
  102096. /** @hidden */
  102097. export var glowMapMergePixelShader: {
  102098. name: string;
  102099. shader: string;
  102100. };
  102101. }
  102102. declare module BABYLON {
  102103. /** @hidden */
  102104. export var glowMapMergeVertexShader: {
  102105. name: string;
  102106. shader: string;
  102107. };
  102108. }
  102109. declare module BABYLON {
  102110. interface AbstractScene {
  102111. /**
  102112. * Return a the first highlight layer of the scene with a given name.
  102113. * @param name The name of the highlight layer to look for.
  102114. * @return The highlight layer if found otherwise null.
  102115. */
  102116. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102117. }
  102118. /**
  102119. * Glow layer options. This helps customizing the behaviour
  102120. * of the glow layer.
  102121. */
  102122. export interface IGlowLayerOptions {
  102123. /**
  102124. * Multiplication factor apply to the canvas size to compute the render target size
  102125. * used to generated the glowing objects (the smaller the faster).
  102126. */
  102127. mainTextureRatio: number;
  102128. /**
  102129. * Enforces a fixed size texture to ensure resize independant blur.
  102130. */
  102131. mainTextureFixedSize?: number;
  102132. /**
  102133. * How big is the kernel of the blur texture.
  102134. */
  102135. blurKernelSize: number;
  102136. /**
  102137. * The camera attached to the layer.
  102138. */
  102139. camera: Nullable<Camera>;
  102140. /**
  102141. * Enable MSAA by chosing the number of samples.
  102142. */
  102143. mainTextureSamples?: number;
  102144. /**
  102145. * The rendering group to draw the layer in.
  102146. */
  102147. renderingGroupId: number;
  102148. }
  102149. /**
  102150. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  102151. *
  102152. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102153. * glowy meshes to your scene.
  102154. *
  102155. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  102156. */
  102157. export class GlowLayer extends EffectLayer {
  102158. /**
  102159. * Effect Name of the layer.
  102160. */
  102161. static readonly EffectName: string;
  102162. /**
  102163. * The default blur kernel size used for the glow.
  102164. */
  102165. static DefaultBlurKernelSize: number;
  102166. /**
  102167. * The default texture size ratio used for the glow.
  102168. */
  102169. static DefaultTextureRatio: number;
  102170. /**
  102171. * Sets the kernel size of the blur.
  102172. */
  102173. /**
  102174. * Gets the kernel size of the blur.
  102175. */
  102176. blurKernelSize: number;
  102177. /**
  102178. * Sets the glow intensity.
  102179. */
  102180. /**
  102181. * Gets the glow intensity.
  102182. */
  102183. intensity: number;
  102184. private _options;
  102185. private _intensity;
  102186. private _horizontalBlurPostprocess1;
  102187. private _verticalBlurPostprocess1;
  102188. private _horizontalBlurPostprocess2;
  102189. private _verticalBlurPostprocess2;
  102190. private _blurTexture1;
  102191. private _blurTexture2;
  102192. private _postProcesses1;
  102193. private _postProcesses2;
  102194. private _includedOnlyMeshes;
  102195. private _excludedMeshes;
  102196. /**
  102197. * Callback used to let the user override the color selection on a per mesh basis
  102198. */
  102199. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  102200. /**
  102201. * Callback used to let the user override the texture selection on a per mesh basis
  102202. */
  102203. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  102204. /**
  102205. * Instantiates a new glow Layer and references it to the scene.
  102206. * @param name The name of the layer
  102207. * @param scene The scene to use the layer in
  102208. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  102209. */
  102210. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  102211. /**
  102212. * Get the effect name of the layer.
  102213. * @return The effect name
  102214. */
  102215. getEffectName(): string;
  102216. /**
  102217. * Create the merge effect. This is the shader use to blit the information back
  102218. * to the main canvas at the end of the scene rendering.
  102219. */
  102220. protected _createMergeEffect(): Effect;
  102221. /**
  102222. * Creates the render target textures and post processes used in the glow layer.
  102223. */
  102224. protected _createTextureAndPostProcesses(): void;
  102225. /**
  102226. * Checks for the readiness of the element composing the layer.
  102227. * @param subMesh the mesh to check for
  102228. * @param useInstances specify wether or not to use instances to render the mesh
  102229. * @param emissiveTexture the associated emissive texture used to generate the glow
  102230. * @return true if ready otherwise, false
  102231. */
  102232. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102233. /**
  102234. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102235. */
  102236. needStencil(): boolean;
  102237. /**
  102238. * Returns true if the mesh can be rendered, otherwise false.
  102239. * @param mesh The mesh to render
  102240. * @param material The material used on the mesh
  102241. * @returns true if it can be rendered otherwise false
  102242. */
  102243. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102244. /**
  102245. * Implementation specific of rendering the generating effect on the main canvas.
  102246. * @param effect The effect used to render through
  102247. */
  102248. protected _internalRender(effect: Effect): void;
  102249. /**
  102250. * Sets the required values for both the emissive texture and and the main color.
  102251. */
  102252. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102253. /**
  102254. * Returns true if the mesh should render, otherwise false.
  102255. * @param mesh The mesh to render
  102256. * @returns true if it should render otherwise false
  102257. */
  102258. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102259. /**
  102260. * Adds specific effects defines.
  102261. * @param defines The defines to add specifics to.
  102262. */
  102263. protected _addCustomEffectDefines(defines: string[]): void;
  102264. /**
  102265. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  102266. * @param mesh The mesh to exclude from the glow layer
  102267. */
  102268. addExcludedMesh(mesh: Mesh): void;
  102269. /**
  102270. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  102271. * @param mesh The mesh to remove
  102272. */
  102273. removeExcludedMesh(mesh: Mesh): void;
  102274. /**
  102275. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  102276. * @param mesh The mesh to include in the glow layer
  102277. */
  102278. addIncludedOnlyMesh(mesh: Mesh): void;
  102279. /**
  102280. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  102281. * @param mesh The mesh to remove
  102282. */
  102283. removeIncludedOnlyMesh(mesh: Mesh): void;
  102284. /**
  102285. * Determine if a given mesh will be used in the glow layer
  102286. * @param mesh The mesh to test
  102287. * @returns true if the mesh will be highlighted by the current glow layer
  102288. */
  102289. hasMesh(mesh: AbstractMesh): boolean;
  102290. /**
  102291. * Free any resources and references associated to a mesh.
  102292. * Internal use
  102293. * @param mesh The mesh to free.
  102294. * @hidden
  102295. */
  102296. _disposeMesh(mesh: Mesh): void;
  102297. /**
  102298. * Gets the class name of the effect layer
  102299. * @returns the string with the class name of the effect layer
  102300. */
  102301. getClassName(): string;
  102302. /**
  102303. * Serializes this glow layer
  102304. * @returns a serialized glow layer object
  102305. */
  102306. serialize(): any;
  102307. /**
  102308. * Creates a Glow Layer from parsed glow layer data
  102309. * @param parsedGlowLayer defines glow layer data
  102310. * @param scene defines the current scene
  102311. * @param rootUrl defines the root URL containing the glow layer information
  102312. * @returns a parsed Glow Layer
  102313. */
  102314. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  102315. }
  102316. }
  102317. declare module BABYLON {
  102318. /** @hidden */
  102319. export var glowBlurPostProcessPixelShader: {
  102320. name: string;
  102321. shader: string;
  102322. };
  102323. }
  102324. declare module BABYLON {
  102325. interface AbstractScene {
  102326. /**
  102327. * Return a the first highlight layer of the scene with a given name.
  102328. * @param name The name of the highlight layer to look for.
  102329. * @return The highlight layer if found otherwise null.
  102330. */
  102331. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  102332. }
  102333. /**
  102334. * Highlight layer options. This helps customizing the behaviour
  102335. * of the highlight layer.
  102336. */
  102337. export interface IHighlightLayerOptions {
  102338. /**
  102339. * Multiplication factor apply to the canvas size to compute the render target size
  102340. * used to generated the glowing objects (the smaller the faster).
  102341. */
  102342. mainTextureRatio: number;
  102343. /**
  102344. * Enforces a fixed size texture to ensure resize independant blur.
  102345. */
  102346. mainTextureFixedSize?: number;
  102347. /**
  102348. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  102349. * of the picture to blur (the smaller the faster).
  102350. */
  102351. blurTextureSizeRatio: number;
  102352. /**
  102353. * How big in texel of the blur texture is the vertical blur.
  102354. */
  102355. blurVerticalSize: number;
  102356. /**
  102357. * How big in texel of the blur texture is the horizontal blur.
  102358. */
  102359. blurHorizontalSize: number;
  102360. /**
  102361. * Alpha blending mode used to apply the blur. Default is combine.
  102362. */
  102363. alphaBlendingMode: number;
  102364. /**
  102365. * The camera attached to the layer.
  102366. */
  102367. camera: Nullable<Camera>;
  102368. /**
  102369. * Should we display highlight as a solid stroke?
  102370. */
  102371. isStroke?: boolean;
  102372. /**
  102373. * The rendering group to draw the layer in.
  102374. */
  102375. renderingGroupId: number;
  102376. }
  102377. /**
  102378. * The highlight layer Helps adding a glow effect around a mesh.
  102379. *
  102380. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102381. * glowy meshes to your scene.
  102382. *
  102383. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  102384. */
  102385. export class HighlightLayer extends EffectLayer {
  102386. name: string;
  102387. /**
  102388. * Effect Name of the highlight layer.
  102389. */
  102390. static readonly EffectName: string;
  102391. /**
  102392. * The neutral color used during the preparation of the glow effect.
  102393. * This is black by default as the blend operation is a blend operation.
  102394. */
  102395. static NeutralColor: Color4;
  102396. /**
  102397. * Stencil value used for glowing meshes.
  102398. */
  102399. static GlowingMeshStencilReference: number;
  102400. /**
  102401. * Stencil value used for the other meshes in the scene.
  102402. */
  102403. static NormalMeshStencilReference: number;
  102404. /**
  102405. * Specifies whether or not the inner glow is ACTIVE in the layer.
  102406. */
  102407. innerGlow: boolean;
  102408. /**
  102409. * Specifies whether or not the outer glow is ACTIVE in the layer.
  102410. */
  102411. outerGlow: boolean;
  102412. /**
  102413. * Specifies the horizontal size of the blur.
  102414. */
  102415. /**
  102416. * Gets the horizontal size of the blur.
  102417. */
  102418. blurHorizontalSize: number;
  102419. /**
  102420. * Specifies the vertical size of the blur.
  102421. */
  102422. /**
  102423. * Gets the vertical size of the blur.
  102424. */
  102425. blurVerticalSize: number;
  102426. /**
  102427. * An event triggered when the highlight layer is being blurred.
  102428. */
  102429. onBeforeBlurObservable: Observable<HighlightLayer>;
  102430. /**
  102431. * An event triggered when the highlight layer has been blurred.
  102432. */
  102433. onAfterBlurObservable: Observable<HighlightLayer>;
  102434. private _instanceGlowingMeshStencilReference;
  102435. private _options;
  102436. private _downSamplePostprocess;
  102437. private _horizontalBlurPostprocess;
  102438. private _verticalBlurPostprocess;
  102439. private _blurTexture;
  102440. private _meshes;
  102441. private _excludedMeshes;
  102442. /**
  102443. * Instantiates a new highlight Layer and references it to the scene..
  102444. * @param name The name of the layer
  102445. * @param scene The scene to use the layer in
  102446. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  102447. */
  102448. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  102449. /**
  102450. * Get the effect name of the layer.
  102451. * @return The effect name
  102452. */
  102453. getEffectName(): string;
  102454. /**
  102455. * Create the merge effect. This is the shader use to blit the information back
  102456. * to the main canvas at the end of the scene rendering.
  102457. */
  102458. protected _createMergeEffect(): Effect;
  102459. /**
  102460. * Creates the render target textures and post processes used in the highlight layer.
  102461. */
  102462. protected _createTextureAndPostProcesses(): void;
  102463. /**
  102464. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102465. */
  102466. needStencil(): boolean;
  102467. /**
  102468. * Checks for the readiness of the element composing the layer.
  102469. * @param subMesh the mesh to check for
  102470. * @param useInstances specify wether or not to use instances to render the mesh
  102471. * @param emissiveTexture the associated emissive texture used to generate the glow
  102472. * @return true if ready otherwise, false
  102473. */
  102474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102475. /**
  102476. * Implementation specific of rendering the generating effect on the main canvas.
  102477. * @param effect The effect used to render through
  102478. */
  102479. protected _internalRender(effect: Effect): void;
  102480. /**
  102481. * Returns true if the layer contains information to display, otherwise false.
  102482. */
  102483. shouldRender(): boolean;
  102484. /**
  102485. * Returns true if the mesh should render, otherwise false.
  102486. * @param mesh The mesh to render
  102487. * @returns true if it should render otherwise false
  102488. */
  102489. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102490. /**
  102491. * Sets the required values for both the emissive texture and and the main color.
  102492. */
  102493. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102494. /**
  102495. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  102496. * @param mesh The mesh to exclude from the highlight layer
  102497. */
  102498. addExcludedMesh(mesh: Mesh): void;
  102499. /**
  102500. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  102501. * @param mesh The mesh to highlight
  102502. */
  102503. removeExcludedMesh(mesh: Mesh): void;
  102504. /**
  102505. * Determine if a given mesh will be highlighted by the current HighlightLayer
  102506. * @param mesh mesh to test
  102507. * @returns true if the mesh will be highlighted by the current HighlightLayer
  102508. */
  102509. hasMesh(mesh: AbstractMesh): boolean;
  102510. /**
  102511. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  102512. * @param mesh The mesh to highlight
  102513. * @param color The color of the highlight
  102514. * @param glowEmissiveOnly Extract the glow from the emissive texture
  102515. */
  102516. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  102517. /**
  102518. * Remove a mesh from the highlight layer in order to make it stop glowing.
  102519. * @param mesh The mesh to highlight
  102520. */
  102521. removeMesh(mesh: Mesh): void;
  102522. /**
  102523. * Force the stencil to the normal expected value for none glowing parts
  102524. */
  102525. private _defaultStencilReference;
  102526. /**
  102527. * Free any resources and references associated to a mesh.
  102528. * Internal use
  102529. * @param mesh The mesh to free.
  102530. * @hidden
  102531. */
  102532. _disposeMesh(mesh: Mesh): void;
  102533. /**
  102534. * Dispose the highlight layer and free resources.
  102535. */
  102536. dispose(): void;
  102537. /**
  102538. * Gets the class name of the effect layer
  102539. * @returns the string with the class name of the effect layer
  102540. */
  102541. getClassName(): string;
  102542. /**
  102543. * Serializes this Highlight layer
  102544. * @returns a serialized Highlight layer object
  102545. */
  102546. serialize(): any;
  102547. /**
  102548. * Creates a Highlight layer from parsed Highlight layer data
  102549. * @param parsedHightlightLayer defines the Highlight layer data
  102550. * @param scene defines the current scene
  102551. * @param rootUrl defines the root URL containing the Highlight layer information
  102552. * @returns a parsed Highlight layer
  102553. */
  102554. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  102555. }
  102556. }
  102557. declare module BABYLON {
  102558. /** @hidden */
  102559. export var lensFlarePixelShader: {
  102560. name: string;
  102561. shader: string;
  102562. };
  102563. }
  102564. declare module BABYLON {
  102565. /** @hidden */
  102566. export var lensFlareVertexShader: {
  102567. name: string;
  102568. shader: string;
  102569. };
  102570. }
  102571. declare module BABYLON {
  102572. /**
  102573. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102574. * It is usually composed of several `lensFlare`.
  102575. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102576. */
  102577. export class LensFlareSystem {
  102578. /**
  102579. * Define the name of the lens flare system
  102580. */
  102581. name: string;
  102582. /**
  102583. * List of lens flares used in this system.
  102584. */
  102585. lensFlares: LensFlare[];
  102586. /**
  102587. * Define a limit from the border the lens flare can be visible.
  102588. */
  102589. borderLimit: number;
  102590. /**
  102591. * Define a viewport border we do not want to see the lens flare in.
  102592. */
  102593. viewportBorder: number;
  102594. /**
  102595. * Define a predicate which could limit the list of meshes able to occlude the effect.
  102596. */
  102597. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102598. /**
  102599. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  102600. */
  102601. layerMask: number;
  102602. /**
  102603. * Define the id of the lens flare system in the scene.
  102604. * (equal to name by default)
  102605. */
  102606. id: string;
  102607. private _scene;
  102608. private _emitter;
  102609. private _vertexBuffers;
  102610. private _indexBuffer;
  102611. private _effect;
  102612. private _positionX;
  102613. private _positionY;
  102614. private _isEnabled;
  102615. /** @hidden */
  102616. static _SceneComponentInitialization: (scene: Scene) => void;
  102617. /**
  102618. * Instantiates a lens flare system.
  102619. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102620. * It is usually composed of several `lensFlare`.
  102621. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102622. * @param name Define the name of the lens flare system in the scene
  102623. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  102624. * @param scene Define the scene the lens flare system belongs to
  102625. */
  102626. constructor(
  102627. /**
  102628. * Define the name of the lens flare system
  102629. */
  102630. name: string, emitter: any, scene: Scene);
  102631. /**
  102632. * Define if the lens flare system is enabled.
  102633. */
  102634. isEnabled: boolean;
  102635. /**
  102636. * Get the scene the effects belongs to.
  102637. * @returns the scene holding the lens flare system
  102638. */
  102639. getScene(): Scene;
  102640. /**
  102641. * Get the emitter of the lens flare system.
  102642. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102643. * @returns the emitter of the lens flare system
  102644. */
  102645. getEmitter(): any;
  102646. /**
  102647. * Set the emitter of the lens flare system.
  102648. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102649. * @param newEmitter Define the new emitter of the system
  102650. */
  102651. setEmitter(newEmitter: any): void;
  102652. /**
  102653. * Get the lens flare system emitter position.
  102654. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  102655. * @returns the position
  102656. */
  102657. getEmitterPosition(): Vector3;
  102658. /**
  102659. * @hidden
  102660. */
  102661. computeEffectivePosition(globalViewport: Viewport): boolean;
  102662. /** @hidden */
  102663. _isVisible(): boolean;
  102664. /**
  102665. * @hidden
  102666. */
  102667. render(): boolean;
  102668. /**
  102669. * Dispose and release the lens flare with its associated resources.
  102670. */
  102671. dispose(): void;
  102672. /**
  102673. * Parse a lens flare system from a JSON repressentation
  102674. * @param parsedLensFlareSystem Define the JSON to parse
  102675. * @param scene Define the scene the parsed system should be instantiated in
  102676. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  102677. * @returns the parsed system
  102678. */
  102679. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  102680. /**
  102681. * Serialize the current Lens Flare System into a JSON representation.
  102682. * @returns the serialized JSON
  102683. */
  102684. serialize(): any;
  102685. }
  102686. }
  102687. declare module BABYLON {
  102688. /**
  102689. * This represents one of the lens effect in a `lensFlareSystem`.
  102690. * It controls one of the indiviual texture used in the effect.
  102691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102692. */
  102693. export class LensFlare {
  102694. /**
  102695. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102696. */
  102697. size: number;
  102698. /**
  102699. * 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.
  102700. */
  102701. position: number;
  102702. /**
  102703. * Define the lens color.
  102704. */
  102705. color: Color3;
  102706. /**
  102707. * Define the lens texture.
  102708. */
  102709. texture: Nullable<Texture>;
  102710. /**
  102711. * Define the alpha mode to render this particular lens.
  102712. */
  102713. alphaMode: number;
  102714. private _system;
  102715. /**
  102716. * Creates a new Lens Flare.
  102717. * This represents one of the lens effect in a `lensFlareSystem`.
  102718. * It controls one of the indiviual texture used in the effect.
  102719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102720. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  102721. * @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.
  102722. * @param color Define the lens color
  102723. * @param imgUrl Define the lens texture url
  102724. * @param system Define the `lensFlareSystem` this flare is part of
  102725. * @returns The newly created Lens Flare
  102726. */
  102727. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  102728. /**
  102729. * Instantiates a new Lens Flare.
  102730. * This represents one of the lens effect in a `lensFlareSystem`.
  102731. * It controls one of the indiviual texture used in the effect.
  102732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102733. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  102734. * @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.
  102735. * @param color Define the lens color
  102736. * @param imgUrl Define the lens texture url
  102737. * @param system Define the `lensFlareSystem` this flare is part of
  102738. */
  102739. constructor(
  102740. /**
  102741. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102742. */
  102743. size: number,
  102744. /**
  102745. * 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.
  102746. */
  102747. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  102748. /**
  102749. * Dispose and release the lens flare with its associated resources.
  102750. */
  102751. dispose(): void;
  102752. }
  102753. }
  102754. declare module BABYLON {
  102755. interface AbstractScene {
  102756. /**
  102757. * The list of lens flare system added to the scene
  102758. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102759. */
  102760. lensFlareSystems: Array<LensFlareSystem>;
  102761. /**
  102762. * Removes the given lens flare system from this scene.
  102763. * @param toRemove The lens flare system to remove
  102764. * @returns The index of the removed lens flare system
  102765. */
  102766. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  102767. /**
  102768. * Adds the given lens flare system to this scene
  102769. * @param newLensFlareSystem The lens flare system to add
  102770. */
  102771. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  102772. /**
  102773. * Gets a lens flare system using its name
  102774. * @param name defines the name to look for
  102775. * @returns the lens flare system or null if not found
  102776. */
  102777. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  102778. /**
  102779. * Gets a lens flare system using its id
  102780. * @param id defines the id to look for
  102781. * @returns the lens flare system or null if not found
  102782. */
  102783. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  102784. }
  102785. /**
  102786. * Defines the lens flare scene component responsible to manage any lens flares
  102787. * in a given scene.
  102788. */
  102789. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  102790. /**
  102791. * The component name helpfull to identify the component in the list of scene components.
  102792. */
  102793. readonly name: string;
  102794. /**
  102795. * The scene the component belongs to.
  102796. */
  102797. scene: Scene;
  102798. /**
  102799. * Creates a new instance of the component for the given scene
  102800. * @param scene Defines the scene to register the component in
  102801. */
  102802. constructor(scene: Scene);
  102803. /**
  102804. * Registers the component in a given scene
  102805. */
  102806. register(): void;
  102807. /**
  102808. * Rebuilds the elements related to this component in case of
  102809. * context lost for instance.
  102810. */
  102811. rebuild(): void;
  102812. /**
  102813. * Adds all the element from the container to the scene
  102814. * @param container the container holding the elements
  102815. */
  102816. addFromContainer(container: AbstractScene): void;
  102817. /**
  102818. * Removes all the elements in the container from the scene
  102819. * @param container contains the elements to remove
  102820. */
  102821. removeFromContainer(container: AbstractScene): void;
  102822. /**
  102823. * Serializes the component data to the specified json object
  102824. * @param serializationObject The object to serialize to
  102825. */
  102826. serialize(serializationObject: any): void;
  102827. /**
  102828. * Disposes the component and the associated ressources.
  102829. */
  102830. dispose(): void;
  102831. private _draw;
  102832. }
  102833. }
  102834. declare module BABYLON {
  102835. /**
  102836. * Defines the shadow generator component responsible to manage any shadow generators
  102837. * in a given scene.
  102838. */
  102839. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  102840. /**
  102841. * The component name helpfull to identify the component in the list of scene components.
  102842. */
  102843. readonly name: string;
  102844. /**
  102845. * The scene the component belongs to.
  102846. */
  102847. scene: Scene;
  102848. /**
  102849. * Creates a new instance of the component for the given scene
  102850. * @param scene Defines the scene to register the component in
  102851. */
  102852. constructor(scene: Scene);
  102853. /**
  102854. * Registers the component in a given scene
  102855. */
  102856. register(): void;
  102857. /**
  102858. * Rebuilds the elements related to this component in case of
  102859. * context lost for instance.
  102860. */
  102861. rebuild(): void;
  102862. /**
  102863. * Serializes the component data to the specified json object
  102864. * @param serializationObject The object to serialize to
  102865. */
  102866. serialize(serializationObject: any): void;
  102867. /**
  102868. * Adds all the element from the container to the scene
  102869. * @param container the container holding the elements
  102870. */
  102871. addFromContainer(container: AbstractScene): void;
  102872. /**
  102873. * Removes all the elements in the container from the scene
  102874. * @param container contains the elements to remove
  102875. */
  102876. removeFromContainer(container: AbstractScene): void;
  102877. /**
  102878. * Rebuilds the elements related to this component in case of
  102879. * context lost for instance.
  102880. */
  102881. dispose(): void;
  102882. private _gatherRenderTargets;
  102883. }
  102884. }
  102885. declare module BABYLON {
  102886. /**
  102887. * A directional light is defined by a direction (what a surprise!).
  102888. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102889. * 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.
  102890. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102891. */
  102892. export class DirectionalLight extends ShadowLight {
  102893. private _shadowFrustumSize;
  102894. /**
  102895. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102896. */
  102897. /**
  102898. * Specifies a fix frustum size for the shadow generation.
  102899. */
  102900. shadowFrustumSize: number;
  102901. private _shadowOrthoScale;
  102902. /**
  102903. * Gets the shadow projection scale against the optimal computed one.
  102904. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102905. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102906. */
  102907. /**
  102908. * Sets the shadow projection scale against the optimal computed one.
  102909. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102910. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102911. */
  102912. shadowOrthoScale: number;
  102913. /**
  102914. * Automatically compute the projection matrix to best fit (including all the casters)
  102915. * on each frame.
  102916. */
  102917. autoUpdateExtends: boolean;
  102918. private _orthoLeft;
  102919. private _orthoRight;
  102920. private _orthoTop;
  102921. private _orthoBottom;
  102922. /**
  102923. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102924. * The directional light is emitted from everywhere in the given direction.
  102925. * It can cast shadows.
  102926. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102927. * @param name The friendly name of the light
  102928. * @param direction The direction of the light
  102929. * @param scene The scene the light belongs to
  102930. */
  102931. constructor(name: string, direction: Vector3, scene: Scene);
  102932. /**
  102933. * Returns the string "DirectionalLight".
  102934. * @return The class name
  102935. */
  102936. getClassName(): string;
  102937. /**
  102938. * Returns the integer 1.
  102939. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102940. */
  102941. getTypeID(): number;
  102942. /**
  102943. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102944. * Returns the DirectionalLight Shadow projection matrix.
  102945. */
  102946. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102947. /**
  102948. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102949. * Returns the DirectionalLight Shadow projection matrix.
  102950. */
  102951. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102952. /**
  102953. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102954. * Returns the DirectionalLight Shadow projection matrix.
  102955. */
  102956. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102957. protected _buildUniformLayout(): void;
  102958. /**
  102959. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102960. * @param effect The effect to update
  102961. * @param lightIndex The index of the light in the effect to update
  102962. * @returns The directional light
  102963. */
  102964. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102965. /**
  102966. * Gets the minZ used for shadow according to both the scene and the light.
  102967. *
  102968. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102969. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102970. * @param activeCamera The camera we are returning the min for
  102971. * @returns the depth min z
  102972. */
  102973. getDepthMinZ(activeCamera: Camera): number;
  102974. /**
  102975. * Gets the maxZ used for shadow according to both the scene and the light.
  102976. *
  102977. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102978. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102979. * @param activeCamera The camera we are returning the max for
  102980. * @returns the depth max z
  102981. */
  102982. getDepthMaxZ(activeCamera: Camera): number;
  102983. /**
  102984. * Prepares the list of defines specific to the light type.
  102985. * @param defines the list of defines
  102986. * @param lightIndex defines the index of the light for the effect
  102987. */
  102988. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102989. }
  102990. }
  102991. declare module BABYLON {
  102992. /**
  102993. * A point light is a light defined by an unique point in world space.
  102994. * The light is emitted in every direction from this point.
  102995. * A good example of a point light is a standard light bulb.
  102996. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102997. */
  102998. export class PointLight extends ShadowLight {
  102999. private _shadowAngle;
  103000. /**
  103001. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103002. * This specifies what angle the shadow will use to be created.
  103003. *
  103004. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103005. */
  103006. /**
  103007. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103008. * This specifies what angle the shadow will use to be created.
  103009. *
  103010. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103011. */
  103012. shadowAngle: number;
  103013. /**
  103014. * Gets the direction if it has been set.
  103015. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103016. */
  103017. /**
  103018. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103019. */
  103020. direction: Vector3;
  103021. /**
  103022. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103023. * A PointLight emits the light in every direction.
  103024. * It can cast shadows.
  103025. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103026. * ```javascript
  103027. * var pointLight = new PointLight("pl", camera.position, scene);
  103028. * ```
  103029. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103030. * @param name The light friendly name
  103031. * @param position The position of the point light in the scene
  103032. * @param scene The scene the lights belongs to
  103033. */
  103034. constructor(name: string, position: Vector3, scene: Scene);
  103035. /**
  103036. * Returns the string "PointLight"
  103037. * @returns the class name
  103038. */
  103039. getClassName(): string;
  103040. /**
  103041. * Returns the integer 0.
  103042. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103043. */
  103044. getTypeID(): number;
  103045. /**
  103046. * Specifies wether or not the shadowmap should be a cube texture.
  103047. * @returns true if the shadowmap needs to be a cube texture.
  103048. */
  103049. needCube(): boolean;
  103050. /**
  103051. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103052. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103053. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103054. */
  103055. getShadowDirection(faceIndex?: number): Vector3;
  103056. /**
  103057. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103058. * - fov = PI / 2
  103059. * - aspect ratio : 1.0
  103060. * - z-near and far equal to the active camera minZ and maxZ.
  103061. * Returns the PointLight.
  103062. */
  103063. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103064. protected _buildUniformLayout(): void;
  103065. /**
  103066. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103067. * @param effect The effect to update
  103068. * @param lightIndex The index of the light in the effect to update
  103069. * @returns The point light
  103070. */
  103071. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103072. /**
  103073. * Prepares the list of defines specific to the light type.
  103074. * @param defines the list of defines
  103075. * @param lightIndex defines the index of the light for the effect
  103076. */
  103077. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103078. }
  103079. }
  103080. declare module BABYLON {
  103081. /**
  103082. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103083. * These values define a cone of light starting from the position, emitting toward the direction.
  103084. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103085. * and the exponent defines the speed of the decay of the light with distance (reach).
  103086. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103087. */
  103088. export class SpotLight extends ShadowLight {
  103089. private _angle;
  103090. private _innerAngle;
  103091. private _cosHalfAngle;
  103092. private _lightAngleScale;
  103093. private _lightAngleOffset;
  103094. /**
  103095. * Gets the cone angle of the spot light in Radians.
  103096. */
  103097. /**
  103098. * Sets the cone angle of the spot light in Radians.
  103099. */
  103100. angle: number;
  103101. /**
  103102. * Only used in gltf falloff mode, this defines the angle where
  103103. * the directional falloff will start before cutting at angle which could be seen
  103104. * as outer angle.
  103105. */
  103106. /**
  103107. * Only used in gltf falloff mode, this defines the angle where
  103108. * the directional falloff will start before cutting at angle which could be seen
  103109. * as outer angle.
  103110. */
  103111. innerAngle: number;
  103112. private _shadowAngleScale;
  103113. /**
  103114. * Allows scaling the angle of the light for shadow generation only.
  103115. */
  103116. /**
  103117. * Allows scaling the angle of the light for shadow generation only.
  103118. */
  103119. shadowAngleScale: number;
  103120. /**
  103121. * The light decay speed with the distance from the emission spot.
  103122. */
  103123. exponent: number;
  103124. private _projectionTextureMatrix;
  103125. /**
  103126. * Allows reading the projecton texture
  103127. */
  103128. readonly projectionTextureMatrix: Matrix;
  103129. protected _projectionTextureLightNear: number;
  103130. /**
  103131. * Gets the near clip of the Spotlight for texture projection.
  103132. */
  103133. /**
  103134. * Sets the near clip of the Spotlight for texture projection.
  103135. */
  103136. projectionTextureLightNear: number;
  103137. protected _projectionTextureLightFar: number;
  103138. /**
  103139. * Gets the far clip of the Spotlight for texture projection.
  103140. */
  103141. /**
  103142. * Sets the far clip of the Spotlight for texture projection.
  103143. */
  103144. projectionTextureLightFar: number;
  103145. protected _projectionTextureUpDirection: Vector3;
  103146. /**
  103147. * Gets the Up vector of the Spotlight for texture projection.
  103148. */
  103149. /**
  103150. * Sets the Up vector of the Spotlight for texture projection.
  103151. */
  103152. projectionTextureUpDirection: Vector3;
  103153. private _projectionTexture;
  103154. /**
  103155. * Gets the projection texture of the light.
  103156. */
  103157. /**
  103158. * Sets the projection texture of the light.
  103159. */
  103160. projectionTexture: Nullable<BaseTexture>;
  103161. private _projectionTextureViewLightDirty;
  103162. private _projectionTextureProjectionLightDirty;
  103163. private _projectionTextureDirty;
  103164. private _projectionTextureViewTargetVector;
  103165. private _projectionTextureViewLightMatrix;
  103166. private _projectionTextureProjectionLightMatrix;
  103167. private _projectionTextureScalingMatrix;
  103168. /**
  103169. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103170. * It can cast shadows.
  103171. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103172. * @param name The light friendly name
  103173. * @param position The position of the spot light in the scene
  103174. * @param direction The direction of the light in the scene
  103175. * @param angle The cone angle of the light in Radians
  103176. * @param exponent The light decay speed with the distance from the emission spot
  103177. * @param scene The scene the lights belongs to
  103178. */
  103179. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103180. /**
  103181. * Returns the string "SpotLight".
  103182. * @returns the class name
  103183. */
  103184. getClassName(): string;
  103185. /**
  103186. * Returns the integer 2.
  103187. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103188. */
  103189. getTypeID(): number;
  103190. /**
  103191. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103192. */
  103193. protected _setDirection(value: Vector3): void;
  103194. /**
  103195. * Overrides the position setter to recompute the projection texture view light Matrix.
  103196. */
  103197. protected _setPosition(value: Vector3): void;
  103198. /**
  103199. * 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.
  103200. * Returns the SpotLight.
  103201. */
  103202. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103203. protected _computeProjectionTextureViewLightMatrix(): void;
  103204. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103205. /**
  103206. * Main function for light texture projection matrix computing.
  103207. */
  103208. protected _computeProjectionTextureMatrix(): void;
  103209. protected _buildUniformLayout(): void;
  103210. private _computeAngleValues;
  103211. /**
  103212. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103213. * @param effect The effect to update
  103214. * @param lightIndex The index of the light in the effect to update
  103215. * @returns The spot light
  103216. */
  103217. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103218. /**
  103219. * Disposes the light and the associated resources.
  103220. */
  103221. dispose(): void;
  103222. /**
  103223. * Prepares the list of defines specific to the light type.
  103224. * @param defines the list of defines
  103225. * @param lightIndex defines the index of the light for the effect
  103226. */
  103227. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103228. }
  103229. }
  103230. declare module BABYLON {
  103231. /**
  103232. * Header information of HDR texture files.
  103233. */
  103234. export interface HDRInfo {
  103235. /**
  103236. * The height of the texture in pixels.
  103237. */
  103238. height: number;
  103239. /**
  103240. * The width of the texture in pixels.
  103241. */
  103242. width: number;
  103243. /**
  103244. * The index of the beginning of the data in the binary file.
  103245. */
  103246. dataPosition: number;
  103247. }
  103248. /**
  103249. * This groups tools to convert HDR texture to native colors array.
  103250. */
  103251. export class HDRTools {
  103252. private static Ldexp;
  103253. private static Rgbe2float;
  103254. private static readStringLine;
  103255. /**
  103256. * Reads header information from an RGBE texture stored in a native array.
  103257. * More information on this format are available here:
  103258. * https://en.wikipedia.org/wiki/RGBE_image_format
  103259. *
  103260. * @param uint8array The binary file stored in native array.
  103261. * @return The header information.
  103262. */
  103263. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  103264. /**
  103265. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  103266. * This RGBE texture needs to store the information as a panorama.
  103267. *
  103268. * More information on this format are available here:
  103269. * https://en.wikipedia.org/wiki/RGBE_image_format
  103270. *
  103271. * @param buffer The binary file stored in an array buffer.
  103272. * @param size The expected size of the extracted cubemap.
  103273. * @return The Cube Map information.
  103274. */
  103275. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  103276. /**
  103277. * Returns the pixels data extracted from an RGBE texture.
  103278. * This pixels will be stored left to right up to down in the R G B order in one array.
  103279. *
  103280. * More information on this format are available here:
  103281. * https://en.wikipedia.org/wiki/RGBE_image_format
  103282. *
  103283. * @param uint8array The binary file stored in an array buffer.
  103284. * @param hdrInfo The header information of the file.
  103285. * @return The pixels data in RGB right to left up to down order.
  103286. */
  103287. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  103288. private static RGBE_ReadPixels_RLE;
  103289. }
  103290. }
  103291. declare module BABYLON {
  103292. /**
  103293. * This represents a texture coming from an HDR input.
  103294. *
  103295. * The only supported format is currently panorama picture stored in RGBE format.
  103296. * Example of such files can be found on HDRLib: http://hdrlib.com/
  103297. */
  103298. export class HDRCubeTexture extends BaseTexture {
  103299. private static _facesMapping;
  103300. private _generateHarmonics;
  103301. private _noMipmap;
  103302. private _textureMatrix;
  103303. private _size;
  103304. private _onLoad;
  103305. private _onError;
  103306. /**
  103307. * The texture URL.
  103308. */
  103309. url: string;
  103310. /**
  103311. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  103312. */
  103313. coordinatesMode: number;
  103314. protected _isBlocking: boolean;
  103315. /**
  103316. * Sets wether or not the texture is blocking during loading.
  103317. */
  103318. /**
  103319. * Gets wether or not the texture is blocking during loading.
  103320. */
  103321. isBlocking: boolean;
  103322. protected _rotationY: number;
  103323. /**
  103324. * Sets texture matrix rotation angle around Y axis in radians.
  103325. */
  103326. /**
  103327. * Gets texture matrix rotation angle around Y axis radians.
  103328. */
  103329. rotationY: number;
  103330. /**
  103331. * Gets or sets the center of the bounding box associated with the cube texture
  103332. * It must define where the camera used to render the texture was set
  103333. */
  103334. boundingBoxPosition: Vector3;
  103335. private _boundingBoxSize;
  103336. /**
  103337. * Gets or sets the size of the bounding box associated with the cube texture
  103338. * When defined, the cubemap will switch to local mode
  103339. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103340. * @example https://www.babylonjs-playground.com/#RNASML
  103341. */
  103342. boundingBoxSize: Vector3;
  103343. /**
  103344. * Instantiates an HDRTexture from the following parameters.
  103345. *
  103346. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  103347. * @param scene The scene the texture will be used in
  103348. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  103349. * @param noMipmap Forces to not generate the mipmap if true
  103350. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  103351. * @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)
  103352. * @param reserved Reserved flag for internal use.
  103353. */
  103354. 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>);
  103355. /**
  103356. * Get the current class name of the texture useful for serialization or dynamic coding.
  103357. * @returns "HDRCubeTexture"
  103358. */
  103359. getClassName(): string;
  103360. /**
  103361. * Occurs when the file is raw .hdr file.
  103362. */
  103363. private loadTexture;
  103364. clone(): HDRCubeTexture;
  103365. delayLoad(): void;
  103366. /**
  103367. * Get the texture reflection matrix used to rotate/transform the reflection.
  103368. * @returns the reflection matrix
  103369. */
  103370. getReflectionTextureMatrix(): Matrix;
  103371. /**
  103372. * Set the texture reflection matrix used to rotate/transform the reflection.
  103373. * @param value Define the reflection matrix to set
  103374. */
  103375. setReflectionTextureMatrix(value: Matrix): void;
  103376. /**
  103377. * Parses a JSON representation of an HDR Texture in order to create the texture
  103378. * @param parsedTexture Define the JSON representation
  103379. * @param scene Define the scene the texture should be created in
  103380. * @param rootUrl Define the root url in case we need to load relative dependencies
  103381. * @returns the newly created texture after parsing
  103382. */
  103383. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  103384. serialize(): any;
  103385. }
  103386. }
  103387. declare module BABYLON {
  103388. /**
  103389. * Class used to control physics engine
  103390. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103391. */
  103392. export class PhysicsEngine implements IPhysicsEngine {
  103393. private _physicsPlugin;
  103394. /**
  103395. * Global value used to control the smallest number supported by the simulation
  103396. */
  103397. static Epsilon: number;
  103398. private _impostors;
  103399. private _joints;
  103400. /**
  103401. * Gets the gravity vector used by the simulation
  103402. */
  103403. gravity: Vector3;
  103404. /**
  103405. * Factory used to create the default physics plugin.
  103406. * @returns The default physics plugin
  103407. */
  103408. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  103409. /**
  103410. * Creates a new Physics Engine
  103411. * @param gravity defines the gravity vector used by the simulation
  103412. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  103413. */
  103414. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  103415. /**
  103416. * Sets the gravity vector used by the simulation
  103417. * @param gravity defines the gravity vector to use
  103418. */
  103419. setGravity(gravity: Vector3): void;
  103420. /**
  103421. * Set the time step of the physics engine.
  103422. * Default is 1/60.
  103423. * To slow it down, enter 1/600 for example.
  103424. * To speed it up, 1/30
  103425. * @param newTimeStep defines the new timestep to apply to this world.
  103426. */
  103427. setTimeStep(newTimeStep?: number): void;
  103428. /**
  103429. * Get the time step of the physics engine.
  103430. * @returns the current time step
  103431. */
  103432. getTimeStep(): number;
  103433. /**
  103434. * Release all resources
  103435. */
  103436. dispose(): void;
  103437. /**
  103438. * Gets the name of the current physics plugin
  103439. * @returns the name of the plugin
  103440. */
  103441. getPhysicsPluginName(): string;
  103442. /**
  103443. * Adding a new impostor for the impostor tracking.
  103444. * This will be done by the impostor itself.
  103445. * @param impostor the impostor to add
  103446. */
  103447. addImpostor(impostor: PhysicsImpostor): void;
  103448. /**
  103449. * Remove an impostor from the engine.
  103450. * This impostor and its mesh will not longer be updated by the physics engine.
  103451. * @param impostor the impostor to remove
  103452. */
  103453. removeImpostor(impostor: PhysicsImpostor): void;
  103454. /**
  103455. * Add a joint to the physics engine
  103456. * @param mainImpostor defines the main impostor to which the joint is added.
  103457. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103458. * @param joint defines the joint that will connect both impostors.
  103459. */
  103460. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103461. /**
  103462. * Removes a joint from the simulation
  103463. * @param mainImpostor defines the impostor used with the joint
  103464. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103465. * @param joint defines the joint to remove
  103466. */
  103467. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103468. /**
  103469. * Called by the scene. No need to call it.
  103470. * @param delta defines the timespam between frames
  103471. */
  103472. _step(delta: number): void;
  103473. /**
  103474. * Gets the current plugin used to run the simulation
  103475. * @returns current plugin
  103476. */
  103477. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103478. /**
  103479. * Gets the list of physic impostors
  103480. * @returns an array of PhysicsImpostor
  103481. */
  103482. getImpostors(): Array<PhysicsImpostor>;
  103483. /**
  103484. * Gets the impostor for a physics enabled object
  103485. * @param object defines the object impersonated by the impostor
  103486. * @returns the PhysicsImpostor or null if not found
  103487. */
  103488. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103489. /**
  103490. * Gets the impostor for a physics body object
  103491. * @param body defines physics body used by the impostor
  103492. * @returns the PhysicsImpostor or null if not found
  103493. */
  103494. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103495. }
  103496. }
  103497. declare module BABYLON {
  103498. /** @hidden */
  103499. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  103500. private _useDeltaForWorldStep;
  103501. world: any;
  103502. name: string;
  103503. private _physicsMaterials;
  103504. private _fixedTimeStep;
  103505. BJSCANNON: any;
  103506. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  103507. setGravity(gravity: Vector3): void;
  103508. setTimeStep(timeStep: number): void;
  103509. getTimeStep(): number;
  103510. executeStep(delta: number): void;
  103511. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103512. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103513. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103514. private _processChildMeshes;
  103515. removePhysicsBody(impostor: PhysicsImpostor): void;
  103516. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103517. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103518. private _addMaterial;
  103519. private _checkWithEpsilon;
  103520. private _createShape;
  103521. private _createHeightmap;
  103522. private _minus90X;
  103523. private _plus90X;
  103524. private _tmpPosition;
  103525. private _tmpDeltaPosition;
  103526. private _tmpUnityRotation;
  103527. private _updatePhysicsBodyTransformation;
  103528. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103529. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103530. isSupported(): boolean;
  103531. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103532. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103533. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103534. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103535. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103536. getBodyMass(impostor: PhysicsImpostor): number;
  103537. getBodyFriction(impostor: PhysicsImpostor): number;
  103538. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103539. getBodyRestitution(impostor: PhysicsImpostor): number;
  103540. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103541. sleepBody(impostor: PhysicsImpostor): void;
  103542. wakeUpBody(impostor: PhysicsImpostor): void;
  103543. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  103544. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  103545. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  103546. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103547. getRadius(impostor: PhysicsImpostor): number;
  103548. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103549. dispose(): void;
  103550. private _extendNamespace;
  103551. }
  103552. }
  103553. declare module BABYLON {
  103554. /** @hidden */
  103555. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  103556. world: any;
  103557. name: string;
  103558. BJSOIMO: any;
  103559. constructor(iterations?: number, oimoInjection?: any);
  103560. setGravity(gravity: Vector3): void;
  103561. setTimeStep(timeStep: number): void;
  103562. getTimeStep(): number;
  103563. private _tmpImpostorsArray;
  103564. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103565. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103566. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103567. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103568. private _tmpPositionVector;
  103569. removePhysicsBody(impostor: PhysicsImpostor): void;
  103570. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103571. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103572. isSupported(): boolean;
  103573. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103574. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103575. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103576. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103577. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103578. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103579. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103580. getBodyMass(impostor: PhysicsImpostor): number;
  103581. getBodyFriction(impostor: PhysicsImpostor): number;
  103582. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103583. getBodyRestitution(impostor: PhysicsImpostor): number;
  103584. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103585. sleepBody(impostor: PhysicsImpostor): void;
  103586. wakeUpBody(impostor: PhysicsImpostor): void;
  103587. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103588. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  103589. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103590. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103591. getRadius(impostor: PhysicsImpostor): number;
  103592. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103593. dispose(): void;
  103594. }
  103595. }
  103596. declare module BABYLON {
  103597. interface AbstractScene {
  103598. /**
  103599. * The list of reflection probes added to the scene
  103600. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103601. */
  103602. reflectionProbes: Array<ReflectionProbe>;
  103603. /**
  103604. * Removes the given reflection probe from this scene.
  103605. * @param toRemove The reflection probe to remove
  103606. * @returns The index of the removed reflection probe
  103607. */
  103608. removeReflectionProbe(toRemove: ReflectionProbe): number;
  103609. /**
  103610. * Adds the given reflection probe to this scene.
  103611. * @param newReflectionProbe The reflection probe to add
  103612. */
  103613. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  103614. }
  103615. /**
  103616. * Class used to generate realtime reflection / refraction cube textures
  103617. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103618. */
  103619. export class ReflectionProbe {
  103620. /** defines the name of the probe */
  103621. name: string;
  103622. private _scene;
  103623. private _renderTargetTexture;
  103624. private _projectionMatrix;
  103625. private _viewMatrix;
  103626. private _target;
  103627. private _add;
  103628. private _attachedMesh;
  103629. private _invertYAxis;
  103630. /** Gets or sets probe position (center of the cube map) */
  103631. position: Vector3;
  103632. /**
  103633. * Creates a new reflection probe
  103634. * @param name defines the name of the probe
  103635. * @param size defines the texture resolution (for each face)
  103636. * @param scene defines the hosting scene
  103637. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  103638. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  103639. */
  103640. constructor(
  103641. /** defines the name of the probe */
  103642. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  103643. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  103644. samples: number;
  103645. /** Gets or sets the refresh rate to use (on every frame by default) */
  103646. refreshRate: number;
  103647. /**
  103648. * Gets the hosting scene
  103649. * @returns a Scene
  103650. */
  103651. getScene(): Scene;
  103652. /** Gets the internal CubeTexture used to render to */
  103653. readonly cubeTexture: RenderTargetTexture;
  103654. /** Gets the list of meshes to render */
  103655. readonly renderList: Nullable<AbstractMesh[]>;
  103656. /**
  103657. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  103658. * @param mesh defines the mesh to attach to
  103659. */
  103660. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103661. /**
  103662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  103663. * @param renderingGroupId The rendering group id corresponding to its index
  103664. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103665. */
  103666. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103667. /**
  103668. * Clean all associated resources
  103669. */
  103670. dispose(): void;
  103671. /**
  103672. * Converts the reflection probe information to a readable string for debug purpose.
  103673. * @param fullDetails Supports for multiple levels of logging within scene loading
  103674. * @returns the human readable reflection probe info
  103675. */
  103676. toString(fullDetails?: boolean): string;
  103677. /**
  103678. * Get the class name of the relfection probe.
  103679. * @returns "ReflectionProbe"
  103680. */
  103681. getClassName(): string;
  103682. /**
  103683. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  103684. * @returns The JSON representation of the texture
  103685. */
  103686. serialize(): any;
  103687. /**
  103688. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  103689. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  103690. * @param scene Define the scene the parsed reflection probe should be instantiated in
  103691. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103692. * @returns The parsed reflection probe if successful
  103693. */
  103694. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  103695. }
  103696. }
  103697. declare module BABYLON {
  103698. /** @hidden */
  103699. export var _BabylonLoaderRegistered: boolean;
  103700. }
  103701. declare module BABYLON {
  103702. /**
  103703. * The Physically based simple base material of BJS.
  103704. *
  103705. * This enables better naming and convention enforcements on top of the pbrMaterial.
  103706. * It is used as the base class for both the specGloss and metalRough conventions.
  103707. */
  103708. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  103709. /**
  103710. * Number of Simultaneous lights allowed on the material.
  103711. */
  103712. maxSimultaneousLights: number;
  103713. /**
  103714. * If sets to true, disables all the lights affecting the material.
  103715. */
  103716. disableLighting: boolean;
  103717. /**
  103718. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  103719. */
  103720. environmentTexture: BaseTexture;
  103721. /**
  103722. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103723. */
  103724. invertNormalMapX: boolean;
  103725. /**
  103726. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103727. */
  103728. invertNormalMapY: boolean;
  103729. /**
  103730. * Normal map used in the model.
  103731. */
  103732. normalTexture: BaseTexture;
  103733. /**
  103734. * Emissivie color used to self-illuminate the model.
  103735. */
  103736. emissiveColor: Color3;
  103737. /**
  103738. * Emissivie texture used to self-illuminate the model.
  103739. */
  103740. emissiveTexture: BaseTexture;
  103741. /**
  103742. * Occlusion Channel Strenght.
  103743. */
  103744. occlusionStrength: number;
  103745. /**
  103746. * Occlusion Texture of the material (adding extra occlusion effects).
  103747. */
  103748. occlusionTexture: BaseTexture;
  103749. /**
  103750. * Defines the alpha limits in alpha test mode.
  103751. */
  103752. alphaCutOff: number;
  103753. /**
  103754. * Gets the current double sided mode.
  103755. */
  103756. /**
  103757. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103758. */
  103759. doubleSided: boolean;
  103760. /**
  103761. * Stores the pre-calculated light information of a mesh in a texture.
  103762. */
  103763. lightmapTexture: BaseTexture;
  103764. /**
  103765. * If true, the light map contains occlusion information instead of lighting info.
  103766. */
  103767. useLightmapAsShadowmap: boolean;
  103768. /**
  103769. * Instantiates a new PBRMaterial instance.
  103770. *
  103771. * @param name The material name
  103772. * @param scene The scene the material will be use in.
  103773. */
  103774. constructor(name: string, scene: Scene);
  103775. getClassName(): string;
  103776. }
  103777. }
  103778. declare module BABYLON {
  103779. /**
  103780. * The PBR material of BJS following the metal roughness convention.
  103781. *
  103782. * This fits to the PBR convention in the GLTF definition:
  103783. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  103784. */
  103785. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  103786. /**
  103787. * The base color has two different interpretations depending on the value of metalness.
  103788. * When the material is a metal, the base color is the specific measured reflectance value
  103789. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  103790. * of the material.
  103791. */
  103792. baseColor: Color3;
  103793. /**
  103794. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  103795. * well as opacity information in the alpha channel.
  103796. */
  103797. baseTexture: BaseTexture;
  103798. /**
  103799. * Specifies the metallic scalar value of the material.
  103800. * Can also be used to scale the metalness values of the metallic texture.
  103801. */
  103802. metallic: number;
  103803. /**
  103804. * Specifies the roughness scalar value of the material.
  103805. * Can also be used to scale the roughness values of the metallic texture.
  103806. */
  103807. roughness: number;
  103808. /**
  103809. * Texture containing both the metallic value in the B channel and the
  103810. * roughness value in the G channel to keep better precision.
  103811. */
  103812. metallicRoughnessTexture: BaseTexture;
  103813. /**
  103814. * Instantiates a new PBRMetalRoughnessMaterial instance.
  103815. *
  103816. * @param name The material name
  103817. * @param scene The scene the material will be use in.
  103818. */
  103819. constructor(name: string, scene: Scene);
  103820. /**
  103821. * Return the currrent class name of the material.
  103822. */
  103823. getClassName(): string;
  103824. /**
  103825. * Makes a duplicate of the current material.
  103826. * @param name - name to use for the new material.
  103827. */
  103828. clone(name: string): PBRMetallicRoughnessMaterial;
  103829. /**
  103830. * Serialize the material to a parsable JSON object.
  103831. */
  103832. serialize(): any;
  103833. /**
  103834. * Parses a JSON object correponding to the serialize function.
  103835. */
  103836. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  103837. }
  103838. }
  103839. declare module BABYLON {
  103840. /**
  103841. * The PBR material of BJS following the specular glossiness convention.
  103842. *
  103843. * This fits to the PBR convention in the GLTF definition:
  103844. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  103845. */
  103846. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  103847. /**
  103848. * Specifies the diffuse color of the material.
  103849. */
  103850. diffuseColor: Color3;
  103851. /**
  103852. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  103853. * channel.
  103854. */
  103855. diffuseTexture: BaseTexture;
  103856. /**
  103857. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  103858. */
  103859. specularColor: Color3;
  103860. /**
  103861. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  103862. */
  103863. glossiness: number;
  103864. /**
  103865. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  103866. */
  103867. specularGlossinessTexture: BaseTexture;
  103868. /**
  103869. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  103870. *
  103871. * @param name The material name
  103872. * @param scene The scene the material will be use in.
  103873. */
  103874. constructor(name: string, scene: Scene);
  103875. /**
  103876. * Return the currrent class name of the material.
  103877. */
  103878. getClassName(): string;
  103879. /**
  103880. * Makes a duplicate of the current material.
  103881. * @param name - name to use for the new material.
  103882. */
  103883. clone(name: string): PBRSpecularGlossinessMaterial;
  103884. /**
  103885. * Serialize the material to a parsable JSON object.
  103886. */
  103887. serialize(): any;
  103888. /**
  103889. * Parses a JSON object correponding to the serialize function.
  103890. */
  103891. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  103892. }
  103893. }
  103894. declare module BABYLON {
  103895. /**
  103896. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  103897. * It can help converting any input color in a desired output one. This can then be used to create effects
  103898. * from sepia, black and white to sixties or futuristic rendering...
  103899. *
  103900. * The only supported format is currently 3dl.
  103901. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  103902. */
  103903. export class ColorGradingTexture extends BaseTexture {
  103904. /**
  103905. * The current texture matrix. (will always be identity in color grading texture)
  103906. */
  103907. private _textureMatrix;
  103908. /**
  103909. * The texture URL.
  103910. */
  103911. url: string;
  103912. /**
  103913. * Empty line regex stored for GC.
  103914. */
  103915. private static _noneEmptyLineRegex;
  103916. private _engine;
  103917. /**
  103918. * Instantiates a ColorGradingTexture from the following parameters.
  103919. *
  103920. * @param url The location of the color gradind data (currently only supporting 3dl)
  103921. * @param scene The scene the texture will be used in
  103922. */
  103923. constructor(url: string, scene: Scene);
  103924. /**
  103925. * Returns the texture matrix used in most of the material.
  103926. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  103927. */
  103928. getTextureMatrix(): Matrix;
  103929. /**
  103930. * Occurs when the file being loaded is a .3dl LUT file.
  103931. */
  103932. private load3dlTexture;
  103933. /**
  103934. * Starts the loading process of the texture.
  103935. */
  103936. private loadTexture;
  103937. /**
  103938. * Clones the color gradind texture.
  103939. */
  103940. clone(): ColorGradingTexture;
  103941. /**
  103942. * Called during delayed load for textures.
  103943. */
  103944. delayLoad(): void;
  103945. /**
  103946. * Parses a color grading texture serialized by Babylon.
  103947. * @param parsedTexture The texture information being parsedTexture
  103948. * @param scene The scene to load the texture in
  103949. * @param rootUrl The root url of the data assets to load
  103950. * @return A color gradind texture
  103951. */
  103952. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103953. /**
  103954. * Serializes the LUT texture to json format.
  103955. */
  103956. serialize(): any;
  103957. }
  103958. }
  103959. declare module BABYLON {
  103960. /**
  103961. * Direct draw surface info
  103962. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103963. */
  103964. export interface DDSInfo {
  103965. /**
  103966. * Width of the texture
  103967. */
  103968. width: number;
  103969. /**
  103970. * Width of the texture
  103971. */
  103972. height: number;
  103973. /**
  103974. * Number of Mipmaps for the texture
  103975. * @see https://en.wikipedia.org/wiki/Mipmap
  103976. */
  103977. mipmapCount: number;
  103978. /**
  103979. * If the textures format is a known fourCC format
  103980. * @see https://www.fourcc.org/
  103981. */
  103982. isFourCC: boolean;
  103983. /**
  103984. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103985. */
  103986. isRGB: boolean;
  103987. /**
  103988. * If the texture is a lumincance format
  103989. */
  103990. isLuminance: boolean;
  103991. /**
  103992. * If this is a cube texture
  103993. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103994. */
  103995. isCube: boolean;
  103996. /**
  103997. * If the texture is a compressed format eg. FOURCC_DXT1
  103998. */
  103999. isCompressed: boolean;
  104000. /**
  104001. * The dxgiFormat of the texture
  104002. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104003. */
  104004. dxgiFormat: number;
  104005. /**
  104006. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104007. */
  104008. textureType: number;
  104009. /**
  104010. * Sphericle polynomial created for the dds texture
  104011. */
  104012. sphericalPolynomial?: SphericalPolynomial;
  104013. }
  104014. /**
  104015. * Class used to provide DDS decompression tools
  104016. */
  104017. export class DDSTools {
  104018. /**
  104019. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104020. */
  104021. static StoreLODInAlphaChannel: boolean;
  104022. /**
  104023. * Gets DDS information from an array buffer
  104024. * @param arrayBuffer defines the array buffer to read data from
  104025. * @returns the DDS information
  104026. */
  104027. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104028. private static _FloatView;
  104029. private static _Int32View;
  104030. private static _ToHalfFloat;
  104031. private static _FromHalfFloat;
  104032. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104033. private static _GetHalfFloatRGBAArrayBuffer;
  104034. private static _GetFloatRGBAArrayBuffer;
  104035. private static _GetFloatAsUIntRGBAArrayBuffer;
  104036. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104037. private static _GetRGBAArrayBuffer;
  104038. private static _ExtractLongWordOrder;
  104039. private static _GetRGBArrayBuffer;
  104040. private static _GetLuminanceArrayBuffer;
  104041. /**
  104042. * Uploads DDS Levels to a Babylon Texture
  104043. * @hidden
  104044. */
  104045. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104046. }
  104047. interface Engine {
  104048. /**
  104049. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104050. * @param rootUrl defines the url where the file to load is located
  104051. * @param scene defines the current scene
  104052. * @param lodScale defines scale to apply to the mip map selection
  104053. * @param lodOffset defines offset to apply to the mip map selection
  104054. * @param onLoad defines an optional callback raised when the texture is loaded
  104055. * @param onError defines an optional callback raised if there is an issue to load the texture
  104056. * @param format defines the format of the data
  104057. * @param forcedExtension defines the extension to use to pick the right loader
  104058. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104059. * @returns the cube texture as an InternalTexture
  104060. */
  104061. 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;
  104062. }
  104063. }
  104064. declare module BABYLON {
  104065. /**
  104066. * Implementation of the DDS Texture Loader.
  104067. * @hidden
  104068. */
  104069. export class _DDSTextureLoader implements IInternalTextureLoader {
  104070. /**
  104071. * Defines wether the loader supports cascade loading the different faces.
  104072. */
  104073. readonly supportCascades: boolean;
  104074. /**
  104075. * This returns if the loader support the current file information.
  104076. * @param extension defines the file extension of the file being loaded
  104077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104078. * @param fallback defines the fallback internal texture if any
  104079. * @param isBase64 defines whether the texture is encoded as a base64
  104080. * @param isBuffer defines whether the texture data are stored as a buffer
  104081. * @returns true if the loader can load the specified file
  104082. */
  104083. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104084. /**
  104085. * Transform the url before loading if required.
  104086. * @param rootUrl the url of the texture
  104087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104088. * @returns the transformed texture
  104089. */
  104090. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104091. /**
  104092. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104093. * @param rootUrl the url of the texture
  104094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104095. * @returns the fallback texture
  104096. */
  104097. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104098. /**
  104099. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104100. * @param data contains the texture data
  104101. * @param texture defines the BabylonJS internal texture
  104102. * @param createPolynomials will be true if polynomials have been requested
  104103. * @param onLoad defines the callback to trigger once the texture is ready
  104104. * @param onError defines the callback to trigger in case of error
  104105. */
  104106. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104107. /**
  104108. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104109. * @param data contains the texture data
  104110. * @param texture defines the BabylonJS internal texture
  104111. * @param callback defines the method to call once ready to upload
  104112. */
  104113. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104114. }
  104115. }
  104116. declare module BABYLON {
  104117. /** @hidden */
  104118. export var rgbdEncodePixelShader: {
  104119. name: string;
  104120. shader: string;
  104121. };
  104122. }
  104123. declare module BABYLON {
  104124. /** @hidden */
  104125. export var rgbdDecodePixelShader: {
  104126. name: string;
  104127. shader: string;
  104128. };
  104129. }
  104130. declare module BABYLON {
  104131. /**
  104132. * Raw texture data and descriptor sufficient for WebGL texture upload
  104133. */
  104134. export interface EnvironmentTextureInfo {
  104135. /**
  104136. * Version of the environment map
  104137. */
  104138. version: number;
  104139. /**
  104140. * Width of image
  104141. */
  104142. width: number;
  104143. /**
  104144. * Irradiance information stored in the file.
  104145. */
  104146. irradiance: any;
  104147. /**
  104148. * Specular information stored in the file.
  104149. */
  104150. specular: any;
  104151. }
  104152. /**
  104153. * Sets of helpers addressing the serialization and deserialization of environment texture
  104154. * stored in a BabylonJS env file.
  104155. * Those files are usually stored as .env files.
  104156. */
  104157. export class EnvironmentTextureTools {
  104158. /**
  104159. * Magic number identifying the env file.
  104160. */
  104161. private static _MagicBytes;
  104162. /**
  104163. * Gets the environment info from an env file.
  104164. * @param data The array buffer containing the .env bytes.
  104165. * @returns the environment file info (the json header) if successfully parsed.
  104166. */
  104167. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104168. /**
  104169. * Creates an environment texture from a loaded cube texture.
  104170. * @param texture defines the cube texture to convert in env file
  104171. * @return a promise containing the environment data if succesfull.
  104172. */
  104173. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104174. /**
  104175. * Creates a JSON representation of the spherical data.
  104176. * @param texture defines the texture containing the polynomials
  104177. * @return the JSON representation of the spherical info
  104178. */
  104179. private static _CreateEnvTextureIrradiance;
  104180. /**
  104181. * Uploads the texture info contained in the env file to the GPU.
  104182. * @param texture defines the internal texture to upload to
  104183. * @param arrayBuffer defines the buffer cotaining the data to load
  104184. * @param info defines the texture info retrieved through the GetEnvInfo method
  104185. * @returns a promise
  104186. */
  104187. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104188. /**
  104189. * Uploads the levels of image data to the GPU.
  104190. * @param texture defines the internal texture to upload to
  104191. * @param imageData defines the array buffer views of image data [mipmap][face]
  104192. * @returns a promise
  104193. */
  104194. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104195. /**
  104196. * Uploads spherical polynomials information to the texture.
  104197. * @param texture defines the texture we are trying to upload the information to
  104198. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104199. */
  104200. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104201. /** @hidden */
  104202. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104203. }
  104204. }
  104205. declare module BABYLON {
  104206. /**
  104207. * Implementation of the ENV Texture Loader.
  104208. * @hidden
  104209. */
  104210. export class _ENVTextureLoader implements IInternalTextureLoader {
  104211. /**
  104212. * Defines wether the loader supports cascade loading the different faces.
  104213. */
  104214. readonly supportCascades: boolean;
  104215. /**
  104216. * This returns if the loader support the current file information.
  104217. * @param extension defines the file extension of the file being loaded
  104218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104219. * @param fallback defines the fallback internal texture if any
  104220. * @param isBase64 defines whether the texture is encoded as a base64
  104221. * @param isBuffer defines whether the texture data are stored as a buffer
  104222. * @returns true if the loader can load the specified file
  104223. */
  104224. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104225. /**
  104226. * Transform the url before loading if required.
  104227. * @param rootUrl the url of the texture
  104228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104229. * @returns the transformed texture
  104230. */
  104231. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104232. /**
  104233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104234. * @param rootUrl the url of the texture
  104235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104236. * @returns the fallback texture
  104237. */
  104238. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104239. /**
  104240. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104241. * @param data contains the texture data
  104242. * @param texture defines the BabylonJS internal texture
  104243. * @param createPolynomials will be true if polynomials have been requested
  104244. * @param onLoad defines the callback to trigger once the texture is ready
  104245. * @param onError defines the callback to trigger in case of error
  104246. */
  104247. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104248. /**
  104249. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104250. * @param data contains the texture data
  104251. * @param texture defines the BabylonJS internal texture
  104252. * @param callback defines the method to call once ready to upload
  104253. */
  104254. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104255. }
  104256. }
  104257. declare module BABYLON {
  104258. /**
  104259. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104260. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104261. */
  104262. export class KhronosTextureContainer {
  104263. /** contents of the KTX container file */
  104264. arrayBuffer: any;
  104265. private static HEADER_LEN;
  104266. private static COMPRESSED_2D;
  104267. private static COMPRESSED_3D;
  104268. private static TEX_2D;
  104269. private static TEX_3D;
  104270. /**
  104271. * Gets the openGL type
  104272. */
  104273. glType: number;
  104274. /**
  104275. * Gets the openGL type size
  104276. */
  104277. glTypeSize: number;
  104278. /**
  104279. * Gets the openGL format
  104280. */
  104281. glFormat: number;
  104282. /**
  104283. * Gets the openGL internal format
  104284. */
  104285. glInternalFormat: number;
  104286. /**
  104287. * Gets the base internal format
  104288. */
  104289. glBaseInternalFormat: number;
  104290. /**
  104291. * Gets image width in pixel
  104292. */
  104293. pixelWidth: number;
  104294. /**
  104295. * Gets image height in pixel
  104296. */
  104297. pixelHeight: number;
  104298. /**
  104299. * Gets image depth in pixels
  104300. */
  104301. pixelDepth: number;
  104302. /**
  104303. * Gets the number of array elements
  104304. */
  104305. numberOfArrayElements: number;
  104306. /**
  104307. * Gets the number of faces
  104308. */
  104309. numberOfFaces: number;
  104310. /**
  104311. * Gets the number of mipmap levels
  104312. */
  104313. numberOfMipmapLevels: number;
  104314. /**
  104315. * Gets the bytes of key value data
  104316. */
  104317. bytesOfKeyValueData: number;
  104318. /**
  104319. * Gets the load type
  104320. */
  104321. loadType: number;
  104322. /**
  104323. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104324. */
  104325. isInvalid: boolean;
  104326. /**
  104327. * Creates a new KhronosTextureContainer
  104328. * @param arrayBuffer contents of the KTX container file
  104329. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104330. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104331. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104332. */
  104333. constructor(
  104334. /** contents of the KTX container file */
  104335. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104336. /**
  104337. * Uploads KTX content to a Babylon Texture.
  104338. * It is assumed that the texture has already been created & is currently bound
  104339. * @hidden
  104340. */
  104341. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104342. private _upload2DCompressedLevels;
  104343. }
  104344. }
  104345. declare module BABYLON {
  104346. /**
  104347. * Implementation of the KTX Texture Loader.
  104348. * @hidden
  104349. */
  104350. export class _KTXTextureLoader implements IInternalTextureLoader {
  104351. /**
  104352. * Defines wether the loader supports cascade loading the different faces.
  104353. */
  104354. readonly supportCascades: boolean;
  104355. /**
  104356. * This returns if the loader support the current file information.
  104357. * @param extension defines the file extension of the file being loaded
  104358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104359. * @param fallback defines the fallback internal texture if any
  104360. * @param isBase64 defines whether the texture is encoded as a base64
  104361. * @param isBuffer defines whether the texture data are stored as a buffer
  104362. * @returns true if the loader can load the specified file
  104363. */
  104364. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104365. /**
  104366. * Transform the url before loading if required.
  104367. * @param rootUrl the url of the texture
  104368. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104369. * @returns the transformed texture
  104370. */
  104371. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104372. /**
  104373. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104374. * @param rootUrl the url of the texture
  104375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104376. * @returns the fallback texture
  104377. */
  104378. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104379. /**
  104380. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104381. * @param data contains the texture data
  104382. * @param texture defines the BabylonJS internal texture
  104383. * @param createPolynomials will be true if polynomials have been requested
  104384. * @param onLoad defines the callback to trigger once the texture is ready
  104385. * @param onError defines the callback to trigger in case of error
  104386. */
  104387. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104388. /**
  104389. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104390. * @param data contains the texture data
  104391. * @param texture defines the BabylonJS internal texture
  104392. * @param callback defines the method to call once ready to upload
  104393. */
  104394. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104395. }
  104396. }
  104397. declare module BABYLON {
  104398. /**
  104399. * Based on jsTGALoader - Javascript loader for TGA file
  104400. * By Vincent Thibault
  104401. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104402. */
  104403. export class TGATools {
  104404. private static _TYPE_INDEXED;
  104405. private static _TYPE_RGB;
  104406. private static _TYPE_GREY;
  104407. private static _TYPE_RLE_INDEXED;
  104408. private static _TYPE_RLE_RGB;
  104409. private static _TYPE_RLE_GREY;
  104410. private static _ORIGIN_MASK;
  104411. private static _ORIGIN_SHIFT;
  104412. private static _ORIGIN_BL;
  104413. private static _ORIGIN_BR;
  104414. private static _ORIGIN_UL;
  104415. private static _ORIGIN_UR;
  104416. /**
  104417. * Gets the header of a TGA file
  104418. * @param data defines the TGA data
  104419. * @returns the header
  104420. */
  104421. static GetTGAHeader(data: Uint8Array): any;
  104422. /**
  104423. * Uploads TGA content to a Babylon Texture
  104424. * @hidden
  104425. */
  104426. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104427. /** @hidden */
  104428. 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;
  104429. /** @hidden */
  104430. 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;
  104431. /** @hidden */
  104432. 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;
  104433. /** @hidden */
  104434. 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;
  104435. /** @hidden */
  104436. 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;
  104437. /** @hidden */
  104438. 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;
  104439. }
  104440. }
  104441. declare module BABYLON {
  104442. /**
  104443. * Implementation of the TGA Texture Loader.
  104444. * @hidden
  104445. */
  104446. export class _TGATextureLoader implements IInternalTextureLoader {
  104447. /**
  104448. * Defines wether the loader supports cascade loading the different faces.
  104449. */
  104450. readonly supportCascades: boolean;
  104451. /**
  104452. * This returns if the loader support the current file information.
  104453. * @param extension defines the file extension of the file being loaded
  104454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104455. * @param fallback defines the fallback internal texture if any
  104456. * @param isBase64 defines whether the texture is encoded as a base64
  104457. * @param isBuffer defines whether the texture data are stored as a buffer
  104458. * @returns true if the loader can load the specified file
  104459. */
  104460. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104461. /**
  104462. * Transform the url before loading if required.
  104463. * @param rootUrl the url of the texture
  104464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104465. * @returns the transformed texture
  104466. */
  104467. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104468. /**
  104469. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104470. * @param rootUrl the url of the texture
  104471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104472. * @returns the fallback texture
  104473. */
  104474. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104475. /**
  104476. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104477. * @param data contains the texture data
  104478. * @param texture defines the BabylonJS internal texture
  104479. * @param createPolynomials will be true if polynomials have been requested
  104480. * @param onLoad defines the callback to trigger once the texture is ready
  104481. * @param onError defines the callback to trigger in case of error
  104482. */
  104483. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104484. /**
  104485. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104486. * @param data contains the texture data
  104487. * @param texture defines the BabylonJS internal texture
  104488. * @param callback defines the method to call once ready to upload
  104489. */
  104490. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104491. }
  104492. }
  104493. declare module BABYLON {
  104494. /**
  104495. * 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.
  104496. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104497. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104498. */
  104499. export class CustomProceduralTexture extends ProceduralTexture {
  104500. private _animate;
  104501. private _time;
  104502. private _config;
  104503. private _texturePath;
  104504. /**
  104505. * Instantiates a new Custom Procedural Texture.
  104506. * 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.
  104507. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104509. * @param name Define the name of the texture
  104510. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104511. * @param size Define the size of the texture to create
  104512. * @param scene Define the scene the texture belongs to
  104513. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104514. * @param generateMipMaps Define if the texture should creates mip maps or not
  104515. */
  104516. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104517. private _loadJson;
  104518. /**
  104519. * Is the texture ready to be used ? (rendered at least once)
  104520. * @returns true if ready, otherwise, false.
  104521. */
  104522. isReady(): boolean;
  104523. /**
  104524. * Render the texture to its associated render target.
  104525. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104526. */
  104527. render(useCameraPostProcess?: boolean): void;
  104528. /**
  104529. * Update the list of dependant textures samplers in the shader.
  104530. */
  104531. updateTextures(): void;
  104532. /**
  104533. * Update the uniform values of the procedural texture in the shader.
  104534. */
  104535. updateShaderUniforms(): void;
  104536. /**
  104537. * Define if the texture animates or not.
  104538. */
  104539. animate: boolean;
  104540. }
  104541. }
  104542. declare module BABYLON {
  104543. /** @hidden */
  104544. export var noisePixelShader: {
  104545. name: string;
  104546. shader: string;
  104547. };
  104548. }
  104549. declare module BABYLON {
  104550. /**
  104551. * Class used to generate noise procedural textures
  104552. */
  104553. export class NoiseProceduralTexture extends ProceduralTexture {
  104554. private _time;
  104555. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104556. brightness: number;
  104557. /** Defines the number of octaves to process */
  104558. octaves: number;
  104559. /** Defines the level of persistence (0.8 by default) */
  104560. persistence: number;
  104561. /** Gets or sets animation speed factor (default is 1) */
  104562. animationSpeedFactor: number;
  104563. /**
  104564. * Creates a new NoiseProceduralTexture
  104565. * @param name defines the name fo the texture
  104566. * @param size defines the size of the texture (default is 256)
  104567. * @param scene defines the hosting scene
  104568. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104569. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104570. */
  104571. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104572. private _updateShaderUniforms;
  104573. protected _getDefines(): string;
  104574. /** Generate the current state of the procedural texture */
  104575. render(useCameraPostProcess?: boolean): void;
  104576. /**
  104577. * Serializes this noise procedural texture
  104578. * @returns a serialized noise procedural texture object
  104579. */
  104580. serialize(): any;
  104581. /**
  104582. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  104583. * @param parsedTexture defines parsed texture data
  104584. * @param scene defines the current scene
  104585. * @param rootUrl defines the root URL containing noise procedural texture information
  104586. * @returns a parsed NoiseProceduralTexture
  104587. */
  104588. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  104589. }
  104590. }
  104591. declare module BABYLON {
  104592. /**
  104593. * Raw cube texture where the raw buffers are passed in
  104594. */
  104595. export class RawCubeTexture extends CubeTexture {
  104596. /**
  104597. * Creates a cube texture where the raw buffers are passed in.
  104598. * @param scene defines the scene the texture is attached to
  104599. * @param data defines the array of data to use to create each face
  104600. * @param size defines the size of the textures
  104601. * @param format defines the format of the data
  104602. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104603. * @param generateMipMaps defines if the engine should generate the mip levels
  104604. * @param invertY defines if data must be stored with Y axis inverted
  104605. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104606. * @param compression defines the compression used (null by default)
  104607. */
  104608. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  104609. /**
  104610. * Updates the raw cube texture.
  104611. * @param data defines the data to store
  104612. * @param format defines the data format
  104613. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104614. * @param invertY defines if data must be stored with Y axis inverted
  104615. * @param compression defines the compression used (null by default)
  104616. * @param level defines which level of the texture to update
  104617. */
  104618. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  104619. /**
  104620. * Updates a raw cube texture with RGBD encoded data.
  104621. * @param data defines the array of data [mipmap][face] to use to create each face
  104622. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  104623. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104624. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  104625. * @returns a promsie that resolves when the operation is complete
  104626. */
  104627. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  104628. /**
  104629. * Clones the raw cube texture.
  104630. * @return a new cube texture
  104631. */
  104632. clone(): CubeTexture;
  104633. /** @hidden */
  104634. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104635. }
  104636. }
  104637. declare module BABYLON {
  104638. /**
  104639. * Class used to store 3D textures containing user data
  104640. */
  104641. export class RawTexture3D extends Texture {
  104642. /** Gets or sets the texture format to use */
  104643. format: number;
  104644. private _engine;
  104645. /**
  104646. * Create a new RawTexture3D
  104647. * @param data defines the data of the texture
  104648. * @param width defines the width of the texture
  104649. * @param height defines the height of the texture
  104650. * @param depth defines the depth of the texture
  104651. * @param format defines the texture format to use
  104652. * @param scene defines the hosting scene
  104653. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  104654. * @param invertY defines if texture must be stored with Y axis inverted
  104655. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  104656. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  104657. */
  104658. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  104659. /** Gets or sets the texture format to use */
  104660. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  104661. /**
  104662. * Update the texture with new data
  104663. * @param data defines the data to store in the texture
  104664. */
  104665. update(data: ArrayBufferView): void;
  104666. }
  104667. }
  104668. declare module BABYLON {
  104669. /**
  104670. * Creates a refraction texture used by refraction channel of the standard material.
  104671. * It is like a mirror but to see through a material.
  104672. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104673. */
  104674. export class RefractionTexture extends RenderTargetTexture {
  104675. /**
  104676. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  104677. * 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.
  104678. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104679. */
  104680. refractionPlane: Plane;
  104681. /**
  104682. * Define how deep under the surface we should see.
  104683. */
  104684. depth: number;
  104685. /**
  104686. * Creates a refraction texture used by refraction channel of the standard material.
  104687. * It is like a mirror but to see through a material.
  104688. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104689. * @param name Define the texture name
  104690. * @param size Define the size of the underlying texture
  104691. * @param scene Define the scene the refraction belongs to
  104692. * @param generateMipMaps Define if we need to generate mips level for the refraction
  104693. */
  104694. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  104695. /**
  104696. * Clone the refraction texture.
  104697. * @returns the cloned texture
  104698. */
  104699. clone(): RefractionTexture;
  104700. /**
  104701. * Serialize the texture to a JSON representation you could use in Parse later on
  104702. * @returns the serialized JSON representation
  104703. */
  104704. serialize(): any;
  104705. }
  104706. }
  104707. declare module BABYLON {
  104708. /**
  104709. * Configuration for Draco compression
  104710. */
  104711. export interface IDracoCompressionConfiguration {
  104712. /**
  104713. * Configuration for the decoder.
  104714. */
  104715. decoder?: {
  104716. /**
  104717. * The url to the WebAssembly module.
  104718. */
  104719. wasmUrl?: string;
  104720. /**
  104721. * The url to the WebAssembly binary.
  104722. */
  104723. wasmBinaryUrl?: string;
  104724. /**
  104725. * The url to the fallback JavaScript module.
  104726. */
  104727. fallbackUrl?: string;
  104728. };
  104729. }
  104730. /**
  104731. * Draco compression (https://google.github.io/draco/)
  104732. *
  104733. * This class wraps the Draco module.
  104734. *
  104735. * **Encoder**
  104736. *
  104737. * The encoder is not currently implemented.
  104738. *
  104739. * **Decoder**
  104740. *
  104741. * 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.
  104742. *
  104743. * To update the configuration, use the following code:
  104744. * ```javascript
  104745. * DracoCompression.Configuration = {
  104746. * decoder: {
  104747. * wasmUrl: "<url to the WebAssembly library>",
  104748. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  104749. * fallbackUrl: "<url to the fallback JavaScript library>",
  104750. * }
  104751. * };
  104752. * ```
  104753. *
  104754. * 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.
  104755. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  104756. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  104757. *
  104758. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  104759. * ```javascript
  104760. * var dracoCompression = new DracoCompression();
  104761. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  104762. * [VertexBuffer.PositionKind]: 0
  104763. * });
  104764. * ```
  104765. *
  104766. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  104767. */
  104768. export class DracoCompression implements IDisposable {
  104769. private static _DecoderModulePromise;
  104770. /**
  104771. * The configuration. Defaults to the following urls:
  104772. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  104773. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  104774. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  104775. */
  104776. static Configuration: IDracoCompressionConfiguration;
  104777. /**
  104778. * Returns true if the decoder is available.
  104779. */
  104780. static readonly DecoderAvailable: boolean;
  104781. /**
  104782. * Constructor
  104783. */
  104784. constructor();
  104785. /**
  104786. * Stop all async operations and release resources.
  104787. */
  104788. dispose(): void;
  104789. /**
  104790. * Decode Draco compressed mesh data to vertex data.
  104791. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  104792. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  104793. * @returns A promise that resolves with the decoded vertex data
  104794. */
  104795. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  104796. [kind: string]: number;
  104797. }): Promise<VertexData>;
  104798. private static _GetDecoderModule;
  104799. private static _LoadScriptAsync;
  104800. private static _LoadFileAsync;
  104801. }
  104802. }
  104803. declare module BABYLON {
  104804. /**
  104805. * Class for building Constructive Solid Geometry
  104806. */
  104807. export class CSG {
  104808. private polygons;
  104809. /**
  104810. * The world matrix
  104811. */
  104812. matrix: Matrix;
  104813. /**
  104814. * Stores the position
  104815. */
  104816. position: Vector3;
  104817. /**
  104818. * Stores the rotation
  104819. */
  104820. rotation: Vector3;
  104821. /**
  104822. * Stores the rotation quaternion
  104823. */
  104824. rotationQuaternion: Nullable<Quaternion>;
  104825. /**
  104826. * Stores the scaling vector
  104827. */
  104828. scaling: Vector3;
  104829. /**
  104830. * Convert the Mesh to CSG
  104831. * @param mesh The Mesh to convert to CSG
  104832. * @returns A new CSG from the Mesh
  104833. */
  104834. static FromMesh(mesh: Mesh): CSG;
  104835. /**
  104836. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  104837. * @param polygons Polygons used to construct a CSG solid
  104838. */
  104839. private static FromPolygons;
  104840. /**
  104841. * Clones, or makes a deep copy, of the CSG
  104842. * @returns A new CSG
  104843. */
  104844. clone(): CSG;
  104845. /**
  104846. * Unions this CSG with another CSG
  104847. * @param csg The CSG to union against this CSG
  104848. * @returns The unioned CSG
  104849. */
  104850. union(csg: CSG): CSG;
  104851. /**
  104852. * Unions this CSG with another CSG in place
  104853. * @param csg The CSG to union against this CSG
  104854. */
  104855. unionInPlace(csg: CSG): void;
  104856. /**
  104857. * Subtracts this CSG with another CSG
  104858. * @param csg The CSG to subtract against this CSG
  104859. * @returns A new CSG
  104860. */
  104861. subtract(csg: CSG): CSG;
  104862. /**
  104863. * Subtracts this CSG with another CSG in place
  104864. * @param csg The CSG to subtact against this CSG
  104865. */
  104866. subtractInPlace(csg: CSG): void;
  104867. /**
  104868. * Intersect this CSG with another CSG
  104869. * @param csg The CSG to intersect against this CSG
  104870. * @returns A new CSG
  104871. */
  104872. intersect(csg: CSG): CSG;
  104873. /**
  104874. * Intersects this CSG with another CSG in place
  104875. * @param csg The CSG to intersect against this CSG
  104876. */
  104877. intersectInPlace(csg: CSG): void;
  104878. /**
  104879. * Return a new CSG solid with solid and empty space switched. This solid is
  104880. * not modified.
  104881. * @returns A new CSG solid with solid and empty space switched
  104882. */
  104883. inverse(): CSG;
  104884. /**
  104885. * Inverses the CSG in place
  104886. */
  104887. inverseInPlace(): void;
  104888. /**
  104889. * This is used to keep meshes transformations so they can be restored
  104890. * when we build back a Babylon Mesh
  104891. * NB : All CSG operations are performed in world coordinates
  104892. * @param csg The CSG to copy the transform attributes from
  104893. * @returns This CSG
  104894. */
  104895. copyTransformAttributes(csg: CSG): CSG;
  104896. /**
  104897. * Build Raw mesh from CSG
  104898. * Coordinates here are in world space
  104899. * @param name The name of the mesh geometry
  104900. * @param scene The Scene
  104901. * @param keepSubMeshes Specifies if the submeshes should be kept
  104902. * @returns A new Mesh
  104903. */
  104904. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104905. /**
  104906. * Build Mesh from CSG taking material and transforms into account
  104907. * @param name The name of the Mesh
  104908. * @param material The material of the Mesh
  104909. * @param scene The Scene
  104910. * @param keepSubMeshes Specifies if submeshes should be kept
  104911. * @returns The new Mesh
  104912. */
  104913. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104914. }
  104915. }
  104916. declare module BABYLON {
  104917. /**
  104918. * Class used to create a trail following a mesh
  104919. */
  104920. export class TrailMesh extends Mesh {
  104921. private _generator;
  104922. private _autoStart;
  104923. private _running;
  104924. private _diameter;
  104925. private _length;
  104926. private _sectionPolygonPointsCount;
  104927. private _sectionVectors;
  104928. private _sectionNormalVectors;
  104929. private _beforeRenderObserver;
  104930. /**
  104931. * @constructor
  104932. * @param name The value used by scene.getMeshByName() to do a lookup.
  104933. * @param generator The mesh to generate a trail.
  104934. * @param scene The scene to add this mesh to.
  104935. * @param diameter Diameter of trailing mesh. Default is 1.
  104936. * @param length Length of trailing mesh. Default is 60.
  104937. * @param autoStart Automatically start trailing mesh. Default true.
  104938. */
  104939. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104940. /**
  104941. * "TrailMesh"
  104942. * @returns "TrailMesh"
  104943. */
  104944. getClassName(): string;
  104945. private _createMesh;
  104946. /**
  104947. * Start trailing mesh.
  104948. */
  104949. start(): void;
  104950. /**
  104951. * Stop trailing mesh.
  104952. */
  104953. stop(): void;
  104954. /**
  104955. * Update trailing mesh geometry.
  104956. */
  104957. update(): void;
  104958. /**
  104959. * Returns a new TrailMesh object.
  104960. * @param name is a string, the name given to the new mesh
  104961. * @param newGenerator use new generator object for cloned trail mesh
  104962. * @returns a new mesh
  104963. */
  104964. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104965. /**
  104966. * Serializes this trail mesh
  104967. * @param serializationObject object to write serialization to
  104968. */
  104969. serialize(serializationObject: any): void;
  104970. /**
  104971. * Parses a serialized trail mesh
  104972. * @param parsedMesh the serialized mesh
  104973. * @param scene the scene to create the trail mesh in
  104974. * @returns the created trail mesh
  104975. */
  104976. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104977. }
  104978. }
  104979. declare module BABYLON {
  104980. /**
  104981. * Class containing static functions to help procedurally build meshes
  104982. */
  104983. export class RibbonBuilder {
  104984. /**
  104985. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104986. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104987. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104988. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104989. * * 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
  104990. * * 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
  104991. * * 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
  104992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104995. * * 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
  104996. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104997. * * 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
  104998. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105000. * @param name defines the name of the mesh
  105001. * @param options defines the options used to create the mesh
  105002. * @param scene defines the hosting scene
  105003. * @returns the ribbon mesh
  105004. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105006. */
  105007. static CreateRibbon(name: string, options: {
  105008. pathArray: Vector3[][];
  105009. closeArray?: boolean;
  105010. closePath?: boolean;
  105011. offset?: number;
  105012. updatable?: boolean;
  105013. sideOrientation?: number;
  105014. frontUVs?: Vector4;
  105015. backUVs?: Vector4;
  105016. instance?: Mesh;
  105017. invertUV?: boolean;
  105018. uvs?: Vector2[];
  105019. colors?: Color4[];
  105020. }, scene?: Nullable<Scene>): Mesh;
  105021. }
  105022. }
  105023. declare module BABYLON {
  105024. /**
  105025. * Class containing static functions to help procedurally build meshes
  105026. */
  105027. export class TorusKnotBuilder {
  105028. /**
  105029. * Creates a torus knot mesh
  105030. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105031. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105032. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105033. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105037. * @param name defines the name of the mesh
  105038. * @param options defines the options used to create the mesh
  105039. * @param scene defines the hosting scene
  105040. * @returns the torus knot mesh
  105041. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105042. */
  105043. static CreateTorusKnot(name: string, options: {
  105044. radius?: number;
  105045. tube?: number;
  105046. radialSegments?: number;
  105047. tubularSegments?: number;
  105048. p?: number;
  105049. q?: number;
  105050. updatable?: boolean;
  105051. sideOrientation?: number;
  105052. frontUVs?: Vector4;
  105053. backUVs?: Vector4;
  105054. }, scene: any): Mesh;
  105055. }
  105056. }
  105057. declare module BABYLON {
  105058. /**
  105059. * Polygon
  105060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105061. */
  105062. export class Polygon {
  105063. /**
  105064. * Creates a rectangle
  105065. * @param xmin bottom X coord
  105066. * @param ymin bottom Y coord
  105067. * @param xmax top X coord
  105068. * @param ymax top Y coord
  105069. * @returns points that make the resulting rectation
  105070. */
  105071. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105072. /**
  105073. * Creates a circle
  105074. * @param radius radius of circle
  105075. * @param cx scale in x
  105076. * @param cy scale in y
  105077. * @param numberOfSides number of sides that make up the circle
  105078. * @returns points that make the resulting circle
  105079. */
  105080. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105081. /**
  105082. * Creates a polygon from input string
  105083. * @param input Input polygon data
  105084. * @returns the parsed points
  105085. */
  105086. static Parse(input: string): Vector2[];
  105087. /**
  105088. * Starts building a polygon from x and y coordinates
  105089. * @param x x coordinate
  105090. * @param y y coordinate
  105091. * @returns the started path2
  105092. */
  105093. static StartingAt(x: number, y: number): Path2;
  105094. }
  105095. /**
  105096. * Builds a polygon
  105097. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105098. */
  105099. export class PolygonMeshBuilder {
  105100. private _points;
  105101. private _outlinepoints;
  105102. private _holes;
  105103. private _name;
  105104. private _scene;
  105105. private _epoints;
  105106. private _eholes;
  105107. private _addToepoint;
  105108. /**
  105109. * Babylon reference to the earcut plugin.
  105110. */
  105111. bjsEarcut: any;
  105112. /**
  105113. * Creates a PolygonMeshBuilder
  105114. * @param name name of the builder
  105115. * @param contours Path of the polygon
  105116. * @param scene scene to add to
  105117. * @param earcutInjection can be used to inject your own earcut reference
  105118. */
  105119. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105120. /**
  105121. * Adds a whole within the polygon
  105122. * @param hole Array of points defining the hole
  105123. * @returns this
  105124. */
  105125. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105126. /**
  105127. * Creates the polygon
  105128. * @param updatable If the mesh should be updatable
  105129. * @param depth The depth of the mesh created
  105130. * @returns the created mesh
  105131. */
  105132. build(updatable?: boolean, depth?: number): Mesh;
  105133. /**
  105134. * Adds a side to the polygon
  105135. * @param positions points that make the polygon
  105136. * @param normals normals of the polygon
  105137. * @param uvs uvs of the polygon
  105138. * @param indices indices of the polygon
  105139. * @param bounds bounds of the polygon
  105140. * @param points points of the polygon
  105141. * @param depth depth of the polygon
  105142. * @param flip flip of the polygon
  105143. */
  105144. private addSide;
  105145. }
  105146. }
  105147. declare module BABYLON {
  105148. /**
  105149. * Class containing static functions to help procedurally build meshes
  105150. */
  105151. export class PolygonBuilder {
  105152. /**
  105153. * Creates a polygon mesh
  105154. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105155. * * 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
  105156. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105159. * * Remember you can only change the shape positions, not their number when updating a polygon
  105160. * @param name defines the name of the mesh
  105161. * @param options defines the options used to create the mesh
  105162. * @param scene defines the hosting scene
  105163. * @param earcutInjection can be used to inject your own earcut reference
  105164. * @returns the polygon mesh
  105165. */
  105166. static CreatePolygon(name: string, options: {
  105167. shape: Vector3[];
  105168. holes?: Vector3[][];
  105169. depth?: number;
  105170. faceUV?: Vector4[];
  105171. faceColors?: Color4[];
  105172. updatable?: boolean;
  105173. sideOrientation?: number;
  105174. frontUVs?: Vector4;
  105175. backUVs?: Vector4;
  105176. }, scene: Scene, earcutInjection?: any): Mesh;
  105177. /**
  105178. * Creates an extruded polygon mesh, with depth in the Y direction.
  105179. * * 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)
  105180. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105181. * @param name defines the name of the mesh
  105182. * @param options defines the options used to create the mesh
  105183. * @param scene defines the hosting scene
  105184. * @param earcutInjection can be used to inject your own earcut reference
  105185. * @returns the polygon mesh
  105186. */
  105187. static ExtrudePolygon(name: string, options: {
  105188. shape: Vector3[];
  105189. holes?: Vector3[][];
  105190. depth?: number;
  105191. faceUV?: Vector4[];
  105192. faceColors?: Color4[];
  105193. updatable?: boolean;
  105194. sideOrientation?: number;
  105195. frontUVs?: Vector4;
  105196. backUVs?: Vector4;
  105197. }, scene: Scene, earcutInjection?: any): Mesh;
  105198. }
  105199. }
  105200. declare module BABYLON {
  105201. /**
  105202. * Class containing static functions to help procedurally build meshes
  105203. */
  105204. export class ShapeBuilder {
  105205. /**
  105206. * 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.
  105207. * * 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.
  105208. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105209. * * 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.
  105210. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105211. * * 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
  105212. * * 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
  105213. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105218. * @param name defines the name of the mesh
  105219. * @param options defines the options used to create the mesh
  105220. * @param scene defines the hosting scene
  105221. * @returns the extruded shape mesh
  105222. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105224. */
  105225. static ExtrudeShape(name: string, options: {
  105226. shape: Vector3[];
  105227. path: Vector3[];
  105228. scale?: number;
  105229. rotation?: number;
  105230. cap?: number;
  105231. updatable?: boolean;
  105232. sideOrientation?: number;
  105233. frontUVs?: Vector4;
  105234. backUVs?: Vector4;
  105235. instance?: Mesh;
  105236. invertUV?: boolean;
  105237. }, scene?: Nullable<Scene>): Mesh;
  105238. /**
  105239. * Creates an custom extruded shape mesh.
  105240. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105241. * * 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.
  105242. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105243. * * 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
  105244. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105245. * * 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
  105246. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105247. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105248. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105249. * * 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
  105250. * * 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
  105251. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105256. * @param name defines the name of the mesh
  105257. * @param options defines the options used to create the mesh
  105258. * @param scene defines the hosting scene
  105259. * @returns the custom extruded shape mesh
  105260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105263. */
  105264. static ExtrudeShapeCustom(name: string, options: {
  105265. shape: Vector3[];
  105266. path: Vector3[];
  105267. scaleFunction?: any;
  105268. rotationFunction?: any;
  105269. ribbonCloseArray?: boolean;
  105270. ribbonClosePath?: boolean;
  105271. cap?: number;
  105272. updatable?: boolean;
  105273. sideOrientation?: number;
  105274. frontUVs?: Vector4;
  105275. backUVs?: Vector4;
  105276. instance?: Mesh;
  105277. invertUV?: boolean;
  105278. }, scene: Scene): Mesh;
  105279. private static _ExtrudeShapeGeneric;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * Class containing static functions to help procedurally build meshes
  105285. */
  105286. export class LatheBuilder {
  105287. /**
  105288. * Creates lathe mesh.
  105289. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105290. * * 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
  105291. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105292. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105293. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105294. * * 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
  105295. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105296. * * 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
  105297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105301. * @param name defines the name of the mesh
  105302. * @param options defines the options used to create the mesh
  105303. * @param scene defines the hosting scene
  105304. * @returns the lathe mesh
  105305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105306. */
  105307. static CreateLathe(name: string, options: {
  105308. shape: Vector3[];
  105309. radius?: number;
  105310. tessellation?: number;
  105311. clip?: number;
  105312. arc?: number;
  105313. closed?: boolean;
  105314. updatable?: boolean;
  105315. sideOrientation?: number;
  105316. frontUVs?: Vector4;
  105317. backUVs?: Vector4;
  105318. cap?: number;
  105319. invertUV?: boolean;
  105320. }, scene: Scene): Mesh;
  105321. }
  105322. }
  105323. declare module BABYLON {
  105324. /**
  105325. * Class containing static functions to help procedurally build meshes
  105326. */
  105327. export class TubeBuilder {
  105328. /**
  105329. * Creates a tube mesh.
  105330. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105331. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105332. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105333. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105334. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105335. * * 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)
  105336. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105337. * * 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
  105338. * * 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
  105339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105343. * @param name defines the name of the mesh
  105344. * @param options defines the options used to create the mesh
  105345. * @param scene defines the hosting scene
  105346. * @returns the tube mesh
  105347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105348. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105349. */
  105350. static CreateTube(name: string, options: {
  105351. path: Vector3[];
  105352. radius?: number;
  105353. tessellation?: number;
  105354. radiusFunction?: {
  105355. (i: number, distance: number): number;
  105356. };
  105357. cap?: number;
  105358. arc?: number;
  105359. updatable?: boolean;
  105360. sideOrientation?: number;
  105361. frontUVs?: Vector4;
  105362. backUVs?: Vector4;
  105363. instance?: Mesh;
  105364. invertUV?: boolean;
  105365. }, scene: Scene): Mesh;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * Class containing static functions to help procedurally build meshes
  105371. */
  105372. export class IcoSphereBuilder {
  105373. /**
  105374. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105375. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105376. * * 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`)
  105377. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105378. * * 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
  105379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105382. * @param name defines the name of the mesh
  105383. * @param options defines the options used to create the mesh
  105384. * @param scene defines the hosting scene
  105385. * @returns the icosahedron mesh
  105386. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105387. */
  105388. static CreateIcoSphere(name: string, options: {
  105389. radius?: number;
  105390. radiusX?: number;
  105391. radiusY?: number;
  105392. radiusZ?: number;
  105393. flat?: boolean;
  105394. subdivisions?: number;
  105395. sideOrientation?: number;
  105396. frontUVs?: Vector4;
  105397. backUVs?: Vector4;
  105398. updatable?: boolean;
  105399. }, scene: Scene): Mesh;
  105400. }
  105401. }
  105402. declare module BABYLON {
  105403. /**
  105404. * Class containing static functions to help procedurally build meshes
  105405. */
  105406. export class DecalBuilder {
  105407. /**
  105408. * Creates a decal mesh.
  105409. * 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
  105410. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105411. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105412. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105413. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105414. * @param name defines the name of the mesh
  105415. * @param sourceMesh defines the mesh where the decal must be applied
  105416. * @param options defines the options used to create the mesh
  105417. * @param scene defines the hosting scene
  105418. * @returns the decal mesh
  105419. * @see https://doc.babylonjs.com/how_to/decals
  105420. */
  105421. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105422. position?: Vector3;
  105423. normal?: Vector3;
  105424. size?: Vector3;
  105425. angle?: number;
  105426. }): Mesh;
  105427. }
  105428. }
  105429. declare module BABYLON {
  105430. /**
  105431. * Class containing static functions to help procedurally build meshes
  105432. */
  105433. export class MeshBuilder {
  105434. /**
  105435. * Creates a box mesh
  105436. * * The parameter `size` sets the size (float) of each box side (default 1)
  105437. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105438. * * 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)
  105439. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105443. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105444. * @param name defines the name of the mesh
  105445. * @param options defines the options used to create the mesh
  105446. * @param scene defines the hosting scene
  105447. * @returns the box mesh
  105448. */
  105449. static CreateBox(name: string, options: {
  105450. size?: number;
  105451. width?: number;
  105452. height?: number;
  105453. depth?: number;
  105454. faceUV?: Vector4[];
  105455. faceColors?: Color4[];
  105456. sideOrientation?: number;
  105457. frontUVs?: Vector4;
  105458. backUVs?: Vector4;
  105459. updatable?: boolean;
  105460. }, scene?: Nullable<Scene>): Mesh;
  105461. /**
  105462. * Creates a sphere mesh
  105463. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105464. * * 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`)
  105465. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105466. * * 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
  105467. * * 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)
  105468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105471. * @param name defines the name of the mesh
  105472. * @param options defines the options used to create the mesh
  105473. * @param scene defines the hosting scene
  105474. * @returns the sphere mesh
  105475. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105476. */
  105477. static CreateSphere(name: string, options: {
  105478. segments?: number;
  105479. diameter?: number;
  105480. diameterX?: number;
  105481. diameterY?: number;
  105482. diameterZ?: number;
  105483. arc?: number;
  105484. slice?: number;
  105485. sideOrientation?: number;
  105486. frontUVs?: Vector4;
  105487. backUVs?: Vector4;
  105488. updatable?: boolean;
  105489. }, scene: any): Mesh;
  105490. /**
  105491. * Creates a plane polygonal mesh. By default, this is a disc
  105492. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105493. * * 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
  105494. * * 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
  105495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105498. * @param name defines the name of the mesh
  105499. * @param options defines the options used to create the mesh
  105500. * @param scene defines the hosting scene
  105501. * @returns the plane polygonal mesh
  105502. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105503. */
  105504. static CreateDisc(name: string, options: {
  105505. radius?: number;
  105506. tessellation?: number;
  105507. arc?: number;
  105508. updatable?: boolean;
  105509. sideOrientation?: number;
  105510. frontUVs?: Vector4;
  105511. backUVs?: Vector4;
  105512. }, scene?: Nullable<Scene>): Mesh;
  105513. /**
  105514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105516. * * 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`)
  105517. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105518. * * 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
  105519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105522. * @param name defines the name of the mesh
  105523. * @param options defines the options used to create the mesh
  105524. * @param scene defines the hosting scene
  105525. * @returns the icosahedron mesh
  105526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105527. */
  105528. static CreateIcoSphere(name: string, options: {
  105529. radius?: number;
  105530. radiusX?: number;
  105531. radiusY?: number;
  105532. radiusZ?: number;
  105533. flat?: boolean;
  105534. subdivisions?: number;
  105535. sideOrientation?: number;
  105536. frontUVs?: Vector4;
  105537. backUVs?: Vector4;
  105538. updatable?: boolean;
  105539. }, scene: Scene): Mesh;
  105540. /**
  105541. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105542. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105543. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105544. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105545. * * 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
  105546. * * 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
  105547. * * 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
  105548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105551. * * 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
  105552. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105553. * * 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
  105554. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105556. * @param name defines the name of the mesh
  105557. * @param options defines the options used to create the mesh
  105558. * @param scene defines the hosting scene
  105559. * @returns the ribbon mesh
  105560. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105562. */
  105563. static CreateRibbon(name: string, options: {
  105564. pathArray: Vector3[][];
  105565. closeArray?: boolean;
  105566. closePath?: boolean;
  105567. offset?: number;
  105568. updatable?: boolean;
  105569. sideOrientation?: number;
  105570. frontUVs?: Vector4;
  105571. backUVs?: Vector4;
  105572. instance?: Mesh;
  105573. invertUV?: boolean;
  105574. uvs?: Vector2[];
  105575. colors?: Color4[];
  105576. }, scene?: Nullable<Scene>): Mesh;
  105577. /**
  105578. * Creates a cylinder or a cone mesh
  105579. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105580. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105581. * * 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.
  105582. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105583. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105584. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105585. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105586. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105587. * * 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).
  105588. * * 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
  105589. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105590. * * 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
  105591. * * 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.
  105592. * * If `enclose` is false, a ring surface is one element.
  105593. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105594. * * 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
  105595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105598. * @param name defines the name of the mesh
  105599. * @param options defines the options used to create the mesh
  105600. * @param scene defines the hosting scene
  105601. * @returns the cylinder mesh
  105602. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105603. */
  105604. static CreateCylinder(name: string, options: {
  105605. height?: number;
  105606. diameterTop?: number;
  105607. diameterBottom?: number;
  105608. diameter?: number;
  105609. tessellation?: number;
  105610. subdivisions?: number;
  105611. arc?: number;
  105612. faceColors?: Color4[];
  105613. faceUV?: Vector4[];
  105614. updatable?: boolean;
  105615. hasRings?: boolean;
  105616. enclose?: boolean;
  105617. sideOrientation?: number;
  105618. frontUVs?: Vector4;
  105619. backUVs?: Vector4;
  105620. }, scene: any): Mesh;
  105621. /**
  105622. * Creates a torus mesh
  105623. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105624. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105625. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105629. * @param name defines the name of the mesh
  105630. * @param options defines the options used to create the mesh
  105631. * @param scene defines the hosting scene
  105632. * @returns the torus mesh
  105633. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105634. */
  105635. static CreateTorus(name: string, options: {
  105636. diameter?: number;
  105637. thickness?: number;
  105638. tessellation?: number;
  105639. updatable?: boolean;
  105640. sideOrientation?: number;
  105641. frontUVs?: Vector4;
  105642. backUVs?: Vector4;
  105643. }, scene: any): Mesh;
  105644. /**
  105645. * Creates a torus knot mesh
  105646. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105647. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105648. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105649. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105653. * @param name defines the name of the mesh
  105654. * @param options defines the options used to create the mesh
  105655. * @param scene defines the hosting scene
  105656. * @returns the torus knot mesh
  105657. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105658. */
  105659. static CreateTorusKnot(name: string, options: {
  105660. radius?: number;
  105661. tube?: number;
  105662. radialSegments?: number;
  105663. tubularSegments?: number;
  105664. p?: number;
  105665. q?: number;
  105666. updatable?: boolean;
  105667. sideOrientation?: number;
  105668. frontUVs?: Vector4;
  105669. backUVs?: Vector4;
  105670. }, scene: any): Mesh;
  105671. /**
  105672. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105673. * * 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
  105674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105675. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105676. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105677. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105678. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105679. * * 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
  105680. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105683. * @param name defines the name of the new line system
  105684. * @param options defines the options used to create the line system
  105685. * @param scene defines the hosting scene
  105686. * @returns a new line system mesh
  105687. */
  105688. static CreateLineSystem(name: string, options: {
  105689. lines: Vector3[][];
  105690. updatable?: boolean;
  105691. instance?: Nullable<LinesMesh>;
  105692. colors?: Nullable<Color4[][]>;
  105693. useVertexAlpha?: boolean;
  105694. }, scene: Nullable<Scene>): LinesMesh;
  105695. /**
  105696. * Creates a line mesh
  105697. * 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
  105698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105699. * * The parameter `points` is an array successive Vector3
  105700. * * 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
  105701. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105703. * * When updating an instance, remember that only point positions can change, not the number of points
  105704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105706. * @param name defines the name of the new line system
  105707. * @param options defines the options used to create the line system
  105708. * @param scene defines the hosting scene
  105709. * @returns a new line mesh
  105710. */
  105711. static CreateLines(name: string, options: {
  105712. points: Vector3[];
  105713. updatable?: boolean;
  105714. instance?: Nullable<LinesMesh>;
  105715. colors?: Color4[];
  105716. useVertexAlpha?: boolean;
  105717. }, scene?: Nullable<Scene>): LinesMesh;
  105718. /**
  105719. * Creates a dashed line mesh
  105720. * * 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
  105721. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105722. * * The parameter `points` is an array successive Vector3
  105723. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105724. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105725. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105726. * * 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
  105727. * * When updating an instance, remember that only point positions can change, not the number of points
  105728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105729. * @param name defines the name of the mesh
  105730. * @param options defines the options used to create the mesh
  105731. * @param scene defines the hosting scene
  105732. * @returns the dashed line mesh
  105733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105734. */
  105735. static CreateDashedLines(name: string, options: {
  105736. points: Vector3[];
  105737. dashSize?: number;
  105738. gapSize?: number;
  105739. dashNb?: number;
  105740. updatable?: boolean;
  105741. instance?: LinesMesh;
  105742. }, scene?: Nullable<Scene>): LinesMesh;
  105743. /**
  105744. * 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.
  105745. * * 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.
  105746. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105747. * * 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.
  105748. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105749. * * 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
  105750. * * 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
  105751. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105756. * @param name defines the name of the mesh
  105757. * @param options defines the options used to create the mesh
  105758. * @param scene defines the hosting scene
  105759. * @returns the extruded shape mesh
  105760. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105762. */
  105763. static ExtrudeShape(name: string, options: {
  105764. shape: Vector3[];
  105765. path: Vector3[];
  105766. scale?: number;
  105767. rotation?: number;
  105768. cap?: number;
  105769. updatable?: boolean;
  105770. sideOrientation?: number;
  105771. frontUVs?: Vector4;
  105772. backUVs?: Vector4;
  105773. instance?: Mesh;
  105774. invertUV?: boolean;
  105775. }, scene?: Nullable<Scene>): Mesh;
  105776. /**
  105777. * Creates an custom extruded shape mesh.
  105778. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105779. * * 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.
  105780. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105781. * * 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
  105782. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105783. * * 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
  105784. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105785. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105786. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105787. * * 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
  105788. * * 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
  105789. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105794. * @param name defines the name of the mesh
  105795. * @param options defines the options used to create the mesh
  105796. * @param scene defines the hosting scene
  105797. * @returns the custom extruded shape mesh
  105798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105801. */
  105802. static ExtrudeShapeCustom(name: string, options: {
  105803. shape: Vector3[];
  105804. path: Vector3[];
  105805. scaleFunction?: any;
  105806. rotationFunction?: any;
  105807. ribbonCloseArray?: boolean;
  105808. ribbonClosePath?: boolean;
  105809. cap?: number;
  105810. updatable?: boolean;
  105811. sideOrientation?: number;
  105812. frontUVs?: Vector4;
  105813. backUVs?: Vector4;
  105814. instance?: Mesh;
  105815. invertUV?: boolean;
  105816. }, scene: Scene): Mesh;
  105817. /**
  105818. * Creates lathe mesh.
  105819. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105820. * * 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
  105821. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105822. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105823. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105824. * * 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
  105825. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105826. * * 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
  105827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105831. * @param name defines the name of the mesh
  105832. * @param options defines the options used to create the mesh
  105833. * @param scene defines the hosting scene
  105834. * @returns the lathe mesh
  105835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105836. */
  105837. static CreateLathe(name: string, options: {
  105838. shape: Vector3[];
  105839. radius?: number;
  105840. tessellation?: number;
  105841. clip?: number;
  105842. arc?: number;
  105843. closed?: boolean;
  105844. updatable?: boolean;
  105845. sideOrientation?: number;
  105846. frontUVs?: Vector4;
  105847. backUVs?: Vector4;
  105848. cap?: number;
  105849. invertUV?: boolean;
  105850. }, scene: Scene): Mesh;
  105851. /**
  105852. * Creates a plane mesh
  105853. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105854. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105855. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105859. * @param name defines the name of the mesh
  105860. * @param options defines the options used to create the mesh
  105861. * @param scene defines the hosting scene
  105862. * @returns the plane mesh
  105863. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105864. */
  105865. static CreatePlane(name: string, options: {
  105866. size?: number;
  105867. width?: number;
  105868. height?: number;
  105869. sideOrientation?: number;
  105870. frontUVs?: Vector4;
  105871. backUVs?: Vector4;
  105872. updatable?: boolean;
  105873. sourcePlane?: Plane;
  105874. }, scene: Scene): Mesh;
  105875. /**
  105876. * Creates a ground mesh
  105877. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105878. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105880. * @param name defines the name of the mesh
  105881. * @param options defines the options used to create the mesh
  105882. * @param scene defines the hosting scene
  105883. * @returns the ground mesh
  105884. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105885. */
  105886. static CreateGround(name: string, options: {
  105887. width?: number;
  105888. height?: number;
  105889. subdivisions?: number;
  105890. subdivisionsX?: number;
  105891. subdivisionsY?: number;
  105892. updatable?: boolean;
  105893. }, scene: any): Mesh;
  105894. /**
  105895. * Creates a tiled ground mesh
  105896. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105897. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105898. * * 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
  105899. * * 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
  105900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105901. * @param name defines the name of the mesh
  105902. * @param options defines the options used to create the mesh
  105903. * @param scene defines the hosting scene
  105904. * @returns the tiled ground mesh
  105905. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105906. */
  105907. static CreateTiledGround(name: string, options: {
  105908. xmin: number;
  105909. zmin: number;
  105910. xmax: number;
  105911. zmax: number;
  105912. subdivisions?: {
  105913. w: number;
  105914. h: number;
  105915. };
  105916. precision?: {
  105917. w: number;
  105918. h: number;
  105919. };
  105920. updatable?: boolean;
  105921. }, scene: Scene): Mesh;
  105922. /**
  105923. * Creates a ground mesh from a height map
  105924. * * The parameter `url` sets the URL of the height map image resource.
  105925. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105926. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105927. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105928. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105929. * * 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.
  105930. * * 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).
  105931. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105933. * @param name defines the name of the mesh
  105934. * @param url defines the url to the height map
  105935. * @param options defines the options used to create the mesh
  105936. * @param scene defines the hosting scene
  105937. * @returns the ground mesh
  105938. * @see https://doc.babylonjs.com/babylon101/height_map
  105939. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105940. */
  105941. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105942. width?: number;
  105943. height?: number;
  105944. subdivisions?: number;
  105945. minHeight?: number;
  105946. maxHeight?: number;
  105947. colorFilter?: Color3;
  105948. alphaFilter?: number;
  105949. updatable?: boolean;
  105950. onReady?: (mesh: GroundMesh) => void;
  105951. }, scene: Scene): GroundMesh;
  105952. /**
  105953. * Creates a polygon mesh
  105954. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105955. * * 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
  105956. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105959. * * Remember you can only change the shape positions, not their number when updating a polygon
  105960. * @param name defines the name of the mesh
  105961. * @param options defines the options used to create the mesh
  105962. * @param scene defines the hosting scene
  105963. * @param earcutInjection can be used to inject your own earcut reference
  105964. * @returns the polygon mesh
  105965. */
  105966. static CreatePolygon(name: string, options: {
  105967. shape: Vector3[];
  105968. holes?: Vector3[][];
  105969. depth?: number;
  105970. faceUV?: Vector4[];
  105971. faceColors?: Color4[];
  105972. updatable?: boolean;
  105973. sideOrientation?: number;
  105974. frontUVs?: Vector4;
  105975. backUVs?: Vector4;
  105976. }, scene: Scene, earcutInjection?: any): Mesh;
  105977. /**
  105978. * Creates an extruded polygon mesh, with depth in the Y direction.
  105979. * * 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)
  105980. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105981. * @param name defines the name of the mesh
  105982. * @param options defines the options used to create the mesh
  105983. * @param scene defines the hosting scene
  105984. * @param earcutInjection can be used to inject your own earcut reference
  105985. * @returns the polygon mesh
  105986. */
  105987. static ExtrudePolygon(name: string, options: {
  105988. shape: Vector3[];
  105989. holes?: Vector3[][];
  105990. depth?: number;
  105991. faceUV?: Vector4[];
  105992. faceColors?: Color4[];
  105993. updatable?: boolean;
  105994. sideOrientation?: number;
  105995. frontUVs?: Vector4;
  105996. backUVs?: Vector4;
  105997. }, scene: Scene, earcutInjection?: any): Mesh;
  105998. /**
  105999. * Creates a tube mesh.
  106000. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106001. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106002. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106003. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106004. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106005. * * 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)
  106006. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106007. * * 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
  106008. * * 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
  106009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106013. * @param name defines the name of the mesh
  106014. * @param options defines the options used to create the mesh
  106015. * @param scene defines the hosting scene
  106016. * @returns the tube mesh
  106017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106018. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106019. */
  106020. static CreateTube(name: string, options: {
  106021. path: Vector3[];
  106022. radius?: number;
  106023. tessellation?: number;
  106024. radiusFunction?: {
  106025. (i: number, distance: number): number;
  106026. };
  106027. cap?: number;
  106028. arc?: number;
  106029. updatable?: boolean;
  106030. sideOrientation?: number;
  106031. frontUVs?: Vector4;
  106032. backUVs?: Vector4;
  106033. instance?: Mesh;
  106034. invertUV?: boolean;
  106035. }, scene: Scene): Mesh;
  106036. /**
  106037. * Creates a polyhedron mesh
  106038. * * 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
  106039. * * The parameter `size` (positive float, default 1) sets the polygon size
  106040. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106041. * * 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`
  106042. * * 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
  106043. * * 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)`)
  106044. * * 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
  106045. * * 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
  106046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106049. * @param name defines the name of the mesh
  106050. * @param options defines the options used to create the mesh
  106051. * @param scene defines the hosting scene
  106052. * @returns the polyhedron mesh
  106053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106054. */
  106055. static CreatePolyhedron(name: string, options: {
  106056. type?: number;
  106057. size?: number;
  106058. sizeX?: number;
  106059. sizeY?: number;
  106060. sizeZ?: number;
  106061. custom?: any;
  106062. faceUV?: Vector4[];
  106063. faceColors?: Color4[];
  106064. flat?: boolean;
  106065. updatable?: boolean;
  106066. sideOrientation?: number;
  106067. frontUVs?: Vector4;
  106068. backUVs?: Vector4;
  106069. }, scene: Scene): Mesh;
  106070. /**
  106071. * Creates a decal mesh.
  106072. * 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
  106073. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106074. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106075. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106076. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106077. * @param name defines the name of the mesh
  106078. * @param sourceMesh defines the mesh where the decal must be applied
  106079. * @param options defines the options used to create the mesh
  106080. * @param scene defines the hosting scene
  106081. * @returns the decal mesh
  106082. * @see https://doc.babylonjs.com/how_to/decals
  106083. */
  106084. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106085. position?: Vector3;
  106086. normal?: Vector3;
  106087. size?: Vector3;
  106088. angle?: number;
  106089. }): Mesh;
  106090. }
  106091. }
  106092. declare module BABYLON {
  106093. /**
  106094. * A simplifier interface for future simplification implementations
  106095. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106096. */
  106097. export interface ISimplifier {
  106098. /**
  106099. * Simplification of a given mesh according to the given settings.
  106100. * Since this requires computation, it is assumed that the function runs async.
  106101. * @param settings The settings of the simplification, including quality and distance
  106102. * @param successCallback A callback that will be called after the mesh was simplified.
  106103. * @param errorCallback in case of an error, this callback will be called. optional.
  106104. */
  106105. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106106. }
  106107. /**
  106108. * Expected simplification settings.
  106109. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106110. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106111. */
  106112. export interface ISimplificationSettings {
  106113. /**
  106114. * Gets or sets the expected quality
  106115. */
  106116. quality: number;
  106117. /**
  106118. * Gets or sets the distance when this optimized version should be used
  106119. */
  106120. distance: number;
  106121. /**
  106122. * Gets an already optimized mesh
  106123. */
  106124. optimizeMesh?: boolean;
  106125. }
  106126. /**
  106127. * Class used to specify simplification options
  106128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106129. */
  106130. export class SimplificationSettings implements ISimplificationSettings {
  106131. /** expected quality */
  106132. quality: number;
  106133. /** distance when this optimized version should be used */
  106134. distance: number;
  106135. /** already optimized mesh */
  106136. optimizeMesh?: boolean | undefined;
  106137. /**
  106138. * Creates a SimplificationSettings
  106139. * @param quality expected quality
  106140. * @param distance distance when this optimized version should be used
  106141. * @param optimizeMesh already optimized mesh
  106142. */
  106143. constructor(
  106144. /** expected quality */
  106145. quality: number,
  106146. /** distance when this optimized version should be used */
  106147. distance: number,
  106148. /** already optimized mesh */
  106149. optimizeMesh?: boolean | undefined);
  106150. }
  106151. /**
  106152. * Interface used to define a simplification task
  106153. */
  106154. export interface ISimplificationTask {
  106155. /**
  106156. * Array of settings
  106157. */
  106158. settings: Array<ISimplificationSettings>;
  106159. /**
  106160. * Simplification type
  106161. */
  106162. simplificationType: SimplificationType;
  106163. /**
  106164. * Mesh to simplify
  106165. */
  106166. mesh: Mesh;
  106167. /**
  106168. * Callback called on success
  106169. */
  106170. successCallback?: () => void;
  106171. /**
  106172. * Defines if parallel processing can be used
  106173. */
  106174. parallelProcessing: boolean;
  106175. }
  106176. /**
  106177. * Queue used to order the simplification tasks
  106178. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106179. */
  106180. export class SimplificationQueue {
  106181. private _simplificationArray;
  106182. /**
  106183. * Gets a boolean indicating that the process is still running
  106184. */
  106185. running: boolean;
  106186. /**
  106187. * Creates a new queue
  106188. */
  106189. constructor();
  106190. /**
  106191. * Adds a new simplification task
  106192. * @param task defines a task to add
  106193. */
  106194. addTask(task: ISimplificationTask): void;
  106195. /**
  106196. * Execute next task
  106197. */
  106198. executeNext(): void;
  106199. /**
  106200. * Execute a simplification task
  106201. * @param task defines the task to run
  106202. */
  106203. runSimplification(task: ISimplificationTask): void;
  106204. private getSimplifier;
  106205. }
  106206. /**
  106207. * The implemented types of simplification
  106208. * At the moment only Quadratic Error Decimation is implemented
  106209. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106210. */
  106211. export enum SimplificationType {
  106212. /** Quadratic error decimation */
  106213. QUADRATIC = 0
  106214. }
  106215. }
  106216. declare module BABYLON {
  106217. interface Scene {
  106218. /** @hidden (Backing field) */
  106219. _simplificationQueue: SimplificationQueue;
  106220. /**
  106221. * Gets or sets the simplification queue attached to the scene
  106222. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106223. */
  106224. simplificationQueue: SimplificationQueue;
  106225. }
  106226. interface Mesh {
  106227. /**
  106228. * Simplify the mesh according to the given array of settings.
  106229. * Function will return immediately and will simplify async
  106230. * @param settings a collection of simplification settings
  106231. * @param parallelProcessing should all levels calculate parallel or one after the other
  106232. * @param simplificationType the type of simplification to run
  106233. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106234. * @returns the current mesh
  106235. */
  106236. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106237. }
  106238. /**
  106239. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106240. * created in a scene
  106241. */
  106242. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106243. /**
  106244. * The component name helpfull to identify the component in the list of scene components.
  106245. */
  106246. readonly name: string;
  106247. /**
  106248. * The scene the component belongs to.
  106249. */
  106250. scene: Scene;
  106251. /**
  106252. * Creates a new instance of the component for the given scene
  106253. * @param scene Defines the scene to register the component in
  106254. */
  106255. constructor(scene: Scene);
  106256. /**
  106257. * Registers the component in a given scene
  106258. */
  106259. register(): void;
  106260. /**
  106261. * Rebuilds the elements related to this component in case of
  106262. * context lost for instance.
  106263. */
  106264. rebuild(): void;
  106265. /**
  106266. * Disposes the component and the associated ressources
  106267. */
  106268. dispose(): void;
  106269. private _beforeCameraUpdate;
  106270. }
  106271. }
  106272. declare module BABYLON {
  106273. /**
  106274. * Class used to enable access to IndexedDB
  106275. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106276. */
  106277. export class Database implements IOfflineProvider {
  106278. private _callbackManifestChecked;
  106279. private _currentSceneUrl;
  106280. private _db;
  106281. private _enableSceneOffline;
  106282. private _enableTexturesOffline;
  106283. private _manifestVersionFound;
  106284. private _mustUpdateRessources;
  106285. private _hasReachedQuota;
  106286. private _isSupported;
  106287. private _idbFactory;
  106288. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106289. private static IsUASupportingBlobStorage;
  106290. /**
  106291. * Gets a boolean indicating if Database storate is enabled (off by default)
  106292. */
  106293. static IDBStorageEnabled: boolean;
  106294. /**
  106295. * Gets a boolean indicating if scene must be saved in the database
  106296. */
  106297. readonly enableSceneOffline: boolean;
  106298. /**
  106299. * Gets a boolean indicating if textures must be saved in the database
  106300. */
  106301. readonly enableTexturesOffline: boolean;
  106302. /**
  106303. * Creates a new Database
  106304. * @param urlToScene defines the url to load the scene
  106305. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106306. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106307. */
  106308. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106309. private static _ParseURL;
  106310. private static _ReturnFullUrlLocation;
  106311. private _checkManifestFile;
  106312. /**
  106313. * Open the database and make it available
  106314. * @param successCallback defines the callback to call on success
  106315. * @param errorCallback defines the callback to call on error
  106316. */
  106317. open(successCallback: () => void, errorCallback: () => void): void;
  106318. /**
  106319. * Loads an image from the database
  106320. * @param url defines the url to load from
  106321. * @param image defines the target DOM image
  106322. */
  106323. loadImage(url: string, image: HTMLImageElement): void;
  106324. private _loadImageFromDBAsync;
  106325. private _saveImageIntoDBAsync;
  106326. private _checkVersionFromDB;
  106327. private _loadVersionFromDBAsync;
  106328. private _saveVersionIntoDBAsync;
  106329. /**
  106330. * Loads a file from database
  106331. * @param url defines the URL to load from
  106332. * @param sceneLoaded defines a callback to call on success
  106333. * @param progressCallBack defines a callback to call when progress changed
  106334. * @param errorCallback defines a callback to call on error
  106335. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106336. */
  106337. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106338. private _loadFileAsync;
  106339. private _saveFileAsync;
  106340. /**
  106341. * Validates if xhr data is correct
  106342. * @param xhr defines the request to validate
  106343. * @param dataType defines the expected data type
  106344. * @returns true if data is correct
  106345. */
  106346. private static _ValidateXHRData;
  106347. }
  106348. }
  106349. declare module BABYLON {
  106350. /** @hidden */
  106351. export var gpuUpdateParticlesPixelShader: {
  106352. name: string;
  106353. shader: string;
  106354. };
  106355. }
  106356. declare module BABYLON {
  106357. /** @hidden */
  106358. export var gpuUpdateParticlesVertexShader: {
  106359. name: string;
  106360. shader: string;
  106361. };
  106362. }
  106363. declare module BABYLON {
  106364. /** @hidden */
  106365. export var clipPlaneFragmentDeclaration2: {
  106366. name: string;
  106367. shader: string;
  106368. };
  106369. }
  106370. declare module BABYLON {
  106371. /** @hidden */
  106372. export var gpuRenderParticlesPixelShader: {
  106373. name: string;
  106374. shader: string;
  106375. };
  106376. }
  106377. declare module BABYLON {
  106378. /** @hidden */
  106379. export var clipPlaneVertexDeclaration2: {
  106380. name: string;
  106381. shader: string;
  106382. };
  106383. }
  106384. declare module BABYLON {
  106385. /** @hidden */
  106386. export var gpuRenderParticlesVertexShader: {
  106387. name: string;
  106388. shader: string;
  106389. };
  106390. }
  106391. declare module BABYLON {
  106392. /**
  106393. * This represents a GPU particle system in Babylon
  106394. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106395. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106396. */
  106397. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106398. /**
  106399. * The layer mask we are rendering the particles through.
  106400. */
  106401. layerMask: number;
  106402. private _capacity;
  106403. private _activeCount;
  106404. private _currentActiveCount;
  106405. private _accumulatedCount;
  106406. private _renderEffect;
  106407. private _updateEffect;
  106408. private _buffer0;
  106409. private _buffer1;
  106410. private _spriteBuffer;
  106411. private _updateVAO;
  106412. private _renderVAO;
  106413. private _targetIndex;
  106414. private _sourceBuffer;
  106415. private _targetBuffer;
  106416. private _engine;
  106417. private _currentRenderId;
  106418. private _started;
  106419. private _stopped;
  106420. private _timeDelta;
  106421. private _randomTexture;
  106422. private _randomTexture2;
  106423. private _attributesStrideSize;
  106424. private _updateEffectOptions;
  106425. private _randomTextureSize;
  106426. private _actualFrame;
  106427. private readonly _rawTextureWidth;
  106428. /**
  106429. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106430. */
  106431. static readonly IsSupported: boolean;
  106432. /**
  106433. * An event triggered when the system is disposed.
  106434. */
  106435. onDisposeObservable: Observable<GPUParticleSystem>;
  106436. /**
  106437. * Gets the maximum number of particles active at the same time.
  106438. * @returns The max number of active particles.
  106439. */
  106440. getCapacity(): number;
  106441. /**
  106442. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106443. * to override the particles.
  106444. */
  106445. forceDepthWrite: boolean;
  106446. /**
  106447. * Gets or set the number of active particles
  106448. */
  106449. activeParticleCount: number;
  106450. private _preWarmDone;
  106451. /**
  106452. * Is this system ready to be used/rendered
  106453. * @return true if the system is ready
  106454. */
  106455. isReady(): boolean;
  106456. /**
  106457. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106458. * @returns True if it has been started, otherwise false.
  106459. */
  106460. isStarted(): boolean;
  106461. /**
  106462. * Starts the particle system and begins to emit
  106463. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106464. */
  106465. start(delay?: number): void;
  106466. /**
  106467. * Stops the particle system.
  106468. */
  106469. stop(): void;
  106470. /**
  106471. * Remove all active particles
  106472. */
  106473. reset(): void;
  106474. /**
  106475. * Returns the string "GPUParticleSystem"
  106476. * @returns a string containing the class name
  106477. */
  106478. getClassName(): string;
  106479. private _colorGradientsTexture;
  106480. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106481. /**
  106482. * Adds a new color gradient
  106483. * @param gradient defines the gradient to use (between 0 and 1)
  106484. * @param color1 defines the color to affect to the specified gradient
  106485. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106486. * @returns the current particle system
  106487. */
  106488. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106489. /**
  106490. * Remove a specific color gradient
  106491. * @param gradient defines the gradient to remove
  106492. * @returns the current particle system
  106493. */
  106494. removeColorGradient(gradient: number): GPUParticleSystem;
  106495. private _angularSpeedGradientsTexture;
  106496. private _sizeGradientsTexture;
  106497. private _velocityGradientsTexture;
  106498. private _limitVelocityGradientsTexture;
  106499. private _dragGradientsTexture;
  106500. private _addFactorGradient;
  106501. /**
  106502. * Adds a new size gradient
  106503. * @param gradient defines the gradient to use (between 0 and 1)
  106504. * @param factor defines the size factor to affect to the specified gradient
  106505. * @returns the current particle system
  106506. */
  106507. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106508. /**
  106509. * Remove a specific size gradient
  106510. * @param gradient defines the gradient to remove
  106511. * @returns the current particle system
  106512. */
  106513. removeSizeGradient(gradient: number): GPUParticleSystem;
  106514. /**
  106515. * Adds a new angular speed gradient
  106516. * @param gradient defines the gradient to use (between 0 and 1)
  106517. * @param factor defines the angular speed to affect to the specified gradient
  106518. * @returns the current particle system
  106519. */
  106520. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106521. /**
  106522. * Remove a specific angular speed gradient
  106523. * @param gradient defines the gradient to remove
  106524. * @returns the current particle system
  106525. */
  106526. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106527. /**
  106528. * Adds a new velocity gradient
  106529. * @param gradient defines the gradient to use (between 0 and 1)
  106530. * @param factor defines the velocity to affect to the specified gradient
  106531. * @returns the current particle system
  106532. */
  106533. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106534. /**
  106535. * Remove a specific velocity gradient
  106536. * @param gradient defines the gradient to remove
  106537. * @returns the current particle system
  106538. */
  106539. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106540. /**
  106541. * Adds a new limit velocity gradient
  106542. * @param gradient defines the gradient to use (between 0 and 1)
  106543. * @param factor defines the limit velocity value to affect to the specified gradient
  106544. * @returns the current particle system
  106545. */
  106546. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106547. /**
  106548. * Remove a specific limit velocity gradient
  106549. * @param gradient defines the gradient to remove
  106550. * @returns the current particle system
  106551. */
  106552. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106553. /**
  106554. * Adds a new drag gradient
  106555. * @param gradient defines the gradient to use (between 0 and 1)
  106556. * @param factor defines the drag value to affect to the specified gradient
  106557. * @returns the current particle system
  106558. */
  106559. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106560. /**
  106561. * Remove a specific drag gradient
  106562. * @param gradient defines the gradient to remove
  106563. * @returns the current particle system
  106564. */
  106565. removeDragGradient(gradient: number): GPUParticleSystem;
  106566. /**
  106567. * Not supported by GPUParticleSystem
  106568. * @param gradient defines the gradient to use (between 0 and 1)
  106569. * @param factor defines the emit rate value to affect to the specified gradient
  106570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106571. * @returns the current particle system
  106572. */
  106573. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106574. /**
  106575. * Not supported by GPUParticleSystem
  106576. * @param gradient defines the gradient to remove
  106577. * @returns the current particle system
  106578. */
  106579. removeEmitRateGradient(gradient: number): IParticleSystem;
  106580. /**
  106581. * Not supported by GPUParticleSystem
  106582. * @param gradient defines the gradient to use (between 0 and 1)
  106583. * @param factor defines the start size value to affect to the specified gradient
  106584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106585. * @returns the current particle system
  106586. */
  106587. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106588. /**
  106589. * Not supported by GPUParticleSystem
  106590. * @param gradient defines the gradient to remove
  106591. * @returns the current particle system
  106592. */
  106593. removeStartSizeGradient(gradient: number): IParticleSystem;
  106594. /**
  106595. * Not supported by GPUParticleSystem
  106596. * @param gradient defines the gradient to use (between 0 and 1)
  106597. * @param min defines the color remap minimal range
  106598. * @param max defines the color remap maximal range
  106599. * @returns the current particle system
  106600. */
  106601. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106602. /**
  106603. * Not supported by GPUParticleSystem
  106604. * @param gradient defines the gradient to remove
  106605. * @returns the current particle system
  106606. */
  106607. removeColorRemapGradient(): IParticleSystem;
  106608. /**
  106609. * Not supported by GPUParticleSystem
  106610. * @param gradient defines the gradient to use (between 0 and 1)
  106611. * @param min defines the alpha remap minimal range
  106612. * @param max defines the alpha remap maximal range
  106613. * @returns the current particle system
  106614. */
  106615. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106616. /**
  106617. * Not supported by GPUParticleSystem
  106618. * @param gradient defines the gradient to remove
  106619. * @returns the current particle system
  106620. */
  106621. removeAlphaRemapGradient(): IParticleSystem;
  106622. /**
  106623. * Not supported by GPUParticleSystem
  106624. * @param gradient defines the gradient to use (between 0 and 1)
  106625. * @param color defines the color to affect to the specified gradient
  106626. * @returns the current particle system
  106627. */
  106628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  106629. /**
  106630. * Not supported by GPUParticleSystem
  106631. * @param gradient defines the gradient to remove
  106632. * @returns the current particle system
  106633. */
  106634. removeRampGradient(): IParticleSystem;
  106635. /**
  106636. * Not supported by GPUParticleSystem
  106637. * @returns the list of ramp gradients
  106638. */
  106639. getRampGradients(): Nullable<Array<Color3Gradient>>;
  106640. /**
  106641. * Not supported by GPUParticleSystem
  106642. * Gets or sets a boolean indicating that ramp gradients must be used
  106643. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106644. */
  106645. useRampGradients: boolean;
  106646. /**
  106647. * Not supported by GPUParticleSystem
  106648. * @param gradient defines the gradient to use (between 0 and 1)
  106649. * @param factor defines the life time factor to affect to the specified gradient
  106650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106651. * @returns the current particle system
  106652. */
  106653. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106654. /**
  106655. * Not supported by GPUParticleSystem
  106656. * @param gradient defines the gradient to remove
  106657. * @returns the current particle system
  106658. */
  106659. removeLifeTimeGradient(gradient: number): IParticleSystem;
  106660. /**
  106661. * Instantiates a GPU particle system.
  106662. * 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.
  106663. * @param name The name of the particle system
  106664. * @param options The options used to create the system
  106665. * @param scene The scene the particle system belongs to
  106666. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106667. */
  106668. constructor(name: string, options: Partial<{
  106669. capacity: number;
  106670. randomTextureSize: number;
  106671. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  106672. protected _reset(): void;
  106673. private _createUpdateVAO;
  106674. private _createRenderVAO;
  106675. private _initialize;
  106676. /** @hidden */
  106677. _recreateUpdateEffect(): void;
  106678. /** @hidden */
  106679. _recreateRenderEffect(): void;
  106680. /**
  106681. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106682. * @param preWarm defines if we are in the pre-warmimg phase
  106683. */
  106684. animate(preWarm?: boolean): void;
  106685. private _createFactorGradientTexture;
  106686. private _createSizeGradientTexture;
  106687. private _createAngularSpeedGradientTexture;
  106688. private _createVelocityGradientTexture;
  106689. private _createLimitVelocityGradientTexture;
  106690. private _createDragGradientTexture;
  106691. private _createColorGradientTexture;
  106692. /**
  106693. * Renders the particle system in its current state
  106694. * @param preWarm defines if the system should only update the particles but not render them
  106695. * @returns the current number of particles
  106696. */
  106697. render(preWarm?: boolean): number;
  106698. /**
  106699. * Rebuilds the particle system
  106700. */
  106701. rebuild(): void;
  106702. private _releaseBuffers;
  106703. private _releaseVAOs;
  106704. /**
  106705. * Disposes the particle system and free the associated resources
  106706. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106707. */
  106708. dispose(disposeTexture?: boolean): void;
  106709. /**
  106710. * Clones the particle system.
  106711. * @param name The name of the cloned object
  106712. * @param newEmitter The new emitter to use
  106713. * @returns the cloned particle system
  106714. */
  106715. clone(name: string, newEmitter: any): GPUParticleSystem;
  106716. /**
  106717. * Serializes the particle system to a JSON object.
  106718. * @returns the JSON object
  106719. */
  106720. serialize(): any;
  106721. /**
  106722. * Parses a JSON object to create a GPU particle system.
  106723. * @param parsedParticleSystem The JSON object to parse
  106724. * @param scene The scene to create the particle system in
  106725. * @param rootUrl The root url to use to load external dependencies like texture
  106726. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106727. * @returns the parsed GPU particle system
  106728. */
  106729. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  106730. }
  106731. }
  106732. declare module BABYLON {
  106733. /**
  106734. * Represents a set of particle systems working together to create a specific effect
  106735. */
  106736. export class ParticleSystemSet implements IDisposable {
  106737. private _emitterCreationOptions;
  106738. private _emitterNode;
  106739. /**
  106740. * Gets the particle system list
  106741. */
  106742. systems: IParticleSystem[];
  106743. /**
  106744. * Gets the emitter node used with this set
  106745. */
  106746. readonly emitterNode: Nullable<TransformNode>;
  106747. /**
  106748. * Creates a new emitter mesh as a sphere
  106749. * @param options defines the options used to create the sphere
  106750. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106751. * @param scene defines the hosting scene
  106752. */
  106753. setEmitterAsSphere(options: {
  106754. diameter: number;
  106755. segments: number;
  106756. color: Color3;
  106757. }, renderingGroupId: number, scene: Scene): void;
  106758. /**
  106759. * Starts all particle systems of the set
  106760. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106761. */
  106762. start(emitter?: AbstractMesh): void;
  106763. /**
  106764. * Release all associated resources
  106765. */
  106766. dispose(): void;
  106767. /**
  106768. * Serialize the set into a JSON compatible object
  106769. * @returns a JSON compatible representation of the set
  106770. */
  106771. serialize(): any;
  106772. /**
  106773. * Parse a new ParticleSystemSet from a serialized source
  106774. * @param data defines a JSON compatible representation of the set
  106775. * @param scene defines the hosting scene
  106776. * @param gpu defines if we want GPU particles or CPU particles
  106777. * @returns a new ParticleSystemSet
  106778. */
  106779. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  106780. }
  106781. }
  106782. declare module BABYLON {
  106783. /**
  106784. * This class is made for on one-liner static method to help creating particle system set.
  106785. */
  106786. export class ParticleHelper {
  106787. /**
  106788. * Gets or sets base Assets URL
  106789. */
  106790. static BaseAssetsUrl: string;
  106791. /**
  106792. * Create a default particle system that you can tweak
  106793. * @param emitter defines the emitter to use
  106794. * @param capacity defines the system capacity (default is 500 particles)
  106795. * @param scene defines the hosting scene
  106796. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106797. * @returns the new Particle system
  106798. */
  106799. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  106800. /**
  106801. * This is the main static method (one-liner) of this helper to create different particle systems
  106802. * @param type This string represents the type to the particle system to create
  106803. * @param scene The scene where the particle system should live
  106804. * @param gpu If the system will use gpu
  106805. * @returns the ParticleSystemSet created
  106806. */
  106807. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  106808. /**
  106809. * Static function used to export a particle system to a ParticleSystemSet variable.
  106810. * Please note that the emitter shape is not exported
  106811. * @param systems defines the particle systems to export
  106812. * @returns the created particle system set
  106813. */
  106814. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  106815. }
  106816. }
  106817. declare module BABYLON {
  106818. interface Engine {
  106819. /**
  106820. * Create an effect to use with particle systems.
  106821. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  106822. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  106823. * @param uniformsNames defines a list of attribute names
  106824. * @param samplers defines an array of string used to represent textures
  106825. * @param defines defines the string containing the defines to use to compile the shaders
  106826. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106827. * @param onCompiled defines a function to call when the effect creation is successful
  106828. * @param onError defines a function to call when the effect creation has failed
  106829. * @returns the new Effect
  106830. */
  106831. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  106832. }
  106833. interface Mesh {
  106834. /**
  106835. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  106836. * @returns an array of IParticleSystem
  106837. */
  106838. getEmittedParticleSystems(): IParticleSystem[];
  106839. /**
  106840. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  106841. * @returns an array of IParticleSystem
  106842. */
  106843. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  106844. }
  106845. /**
  106846. * @hidden
  106847. */
  106848. export var _IDoNeedToBeInTheBuild: number;
  106849. }
  106850. declare module BABYLON {
  106851. interface Scene {
  106852. /** @hidden (Backing field) */
  106853. _physicsEngine: Nullable<IPhysicsEngine>;
  106854. /**
  106855. * Gets the current physics engine
  106856. * @returns a IPhysicsEngine or null if none attached
  106857. */
  106858. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  106859. /**
  106860. * Enables physics to the current scene
  106861. * @param gravity defines the scene's gravity for the physics engine
  106862. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  106863. * @return a boolean indicating if the physics engine was initialized
  106864. */
  106865. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  106866. /**
  106867. * Disables and disposes the physics engine associated with the scene
  106868. */
  106869. disablePhysicsEngine(): void;
  106870. /**
  106871. * Gets a boolean indicating if there is an active physics engine
  106872. * @returns a boolean indicating if there is an active physics engine
  106873. */
  106874. isPhysicsEnabled(): boolean;
  106875. /**
  106876. * Deletes a physics compound impostor
  106877. * @param compound defines the compound to delete
  106878. */
  106879. deleteCompoundImpostor(compound: any): void;
  106880. /**
  106881. * An event triggered when physic simulation is about to be run
  106882. */
  106883. onBeforePhysicsObservable: Observable<Scene>;
  106884. /**
  106885. * An event triggered when physic simulation has been done
  106886. */
  106887. onAfterPhysicsObservable: Observable<Scene>;
  106888. }
  106889. interface AbstractMesh {
  106890. /** @hidden */
  106891. _physicsImpostor: Nullable<PhysicsImpostor>;
  106892. /**
  106893. * Gets or sets impostor used for physic simulation
  106894. * @see http://doc.babylonjs.com/features/physics_engine
  106895. */
  106896. physicsImpostor: Nullable<PhysicsImpostor>;
  106897. /**
  106898. * Gets the current physics impostor
  106899. * @see http://doc.babylonjs.com/features/physics_engine
  106900. * @returns a physics impostor or null
  106901. */
  106902. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106903. /** Apply a physic impulse to the mesh
  106904. * @param force defines the force to apply
  106905. * @param contactPoint defines where to apply the force
  106906. * @returns the current mesh
  106907. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106908. */
  106909. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106910. /**
  106911. * Creates a physic joint between two meshes
  106912. * @param otherMesh defines the other mesh to use
  106913. * @param pivot1 defines the pivot to use on this mesh
  106914. * @param pivot2 defines the pivot to use on the other mesh
  106915. * @param options defines additional options (can be plugin dependent)
  106916. * @returns the current mesh
  106917. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106918. */
  106919. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106920. /** @hidden */
  106921. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106922. }
  106923. /**
  106924. * Defines the physics engine scene component responsible to manage a physics engine
  106925. */
  106926. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106927. /**
  106928. * The component name helpful to identify the component in the list of scene components.
  106929. */
  106930. readonly name: string;
  106931. /**
  106932. * The scene the component belongs to.
  106933. */
  106934. scene: Scene;
  106935. /**
  106936. * Creates a new instance of the component for the given scene
  106937. * @param scene Defines the scene to register the component in
  106938. */
  106939. constructor(scene: Scene);
  106940. /**
  106941. * Registers the component in a given scene
  106942. */
  106943. register(): void;
  106944. /**
  106945. * Rebuilds the elements related to this component in case of
  106946. * context lost for instance.
  106947. */
  106948. rebuild(): void;
  106949. /**
  106950. * Disposes the component and the associated ressources
  106951. */
  106952. dispose(): void;
  106953. }
  106954. }
  106955. declare module BABYLON {
  106956. /**
  106957. * A helper for physics simulations
  106958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106959. */
  106960. export class PhysicsHelper {
  106961. private _scene;
  106962. private _physicsEngine;
  106963. /**
  106964. * Initializes the Physics helper
  106965. * @param scene Babylon.js scene
  106966. */
  106967. constructor(scene: Scene);
  106968. /**
  106969. * Applies a radial explosion impulse
  106970. * @param origin the origin of the explosion
  106971. * @param radius the explosion radius
  106972. * @param strength the explosion strength
  106973. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106974. * @returns A physics radial explosion event, or null
  106975. */
  106976. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106977. /**
  106978. * Applies a radial explosion force
  106979. * @param origin the origin of the explosion
  106980. * @param radius the explosion radius
  106981. * @param strength the explosion strength
  106982. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106983. * @returns A physics radial explosion event, or null
  106984. */
  106985. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106986. /**
  106987. * Creates a gravitational field
  106988. * @param origin the origin of the explosion
  106989. * @param radius the explosion radius
  106990. * @param strength the explosion strength
  106991. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106992. * @returns A physics gravitational field event, or null
  106993. */
  106994. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  106995. /**
  106996. * Creates a physics updraft event
  106997. * @param origin the origin of the updraft
  106998. * @param radius the radius of the updraft
  106999. * @param strength the strength of the updraft
  107000. * @param height the height of the updraft
  107001. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107002. * @returns A physics updraft event, or null
  107003. */
  107004. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107005. /**
  107006. * Creates a physics vortex event
  107007. * @param origin the of the vortex
  107008. * @param radius the radius of the vortex
  107009. * @param strength the strength of the vortex
  107010. * @param height the height of the vortex
  107011. * @returns a Physics vortex event, or null
  107012. * A physics vortex event or null
  107013. */
  107014. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107015. }
  107016. /**
  107017. * Represents a physics radial explosion event
  107018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107019. */
  107020. export class PhysicsRadialExplosionEvent {
  107021. private _scene;
  107022. private _sphere;
  107023. private _sphereOptions;
  107024. private _rays;
  107025. private _dataFetched;
  107026. /**
  107027. * Initializes a radial explosioin event
  107028. * @param scene BabylonJS scene
  107029. */
  107030. constructor(scene: Scene);
  107031. /**
  107032. * Returns the data related to the radial explosion event (sphere & rays).
  107033. * @returns The radial explosion event data
  107034. */
  107035. getData(): PhysicsRadialExplosionEventData;
  107036. /**
  107037. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107038. * @param impostor A physics imposter
  107039. * @param origin the origin of the explosion
  107040. * @param radius the explosion radius
  107041. * @param strength the explosion strength
  107042. * @param falloff possible options: Constant & Linear
  107043. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107044. */
  107045. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107046. /**
  107047. * Disposes the sphere.
  107048. * @param force Specifies if the sphere should be disposed by force
  107049. */
  107050. dispose(force?: boolean): void;
  107051. /*** Helpers ***/
  107052. private _prepareSphere;
  107053. private _intersectsWithSphere;
  107054. }
  107055. /**
  107056. * Represents a gravitational field event
  107057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107058. */
  107059. export class PhysicsGravitationalFieldEvent {
  107060. private _physicsHelper;
  107061. private _scene;
  107062. private _origin;
  107063. private _radius;
  107064. private _strength;
  107065. private _falloff;
  107066. private _tickCallback;
  107067. private _sphere;
  107068. private _dataFetched;
  107069. /**
  107070. * Initializes the physics gravitational field event
  107071. * @param physicsHelper A physics helper
  107072. * @param scene BabylonJS scene
  107073. * @param origin The origin position of the gravitational field event
  107074. * @param radius The radius of the gravitational field event
  107075. * @param strength The strength of the gravitational field event
  107076. * @param falloff The falloff for the gravitational field event
  107077. */
  107078. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107079. /**
  107080. * Returns the data related to the gravitational field event (sphere).
  107081. * @returns A gravitational field event
  107082. */
  107083. getData(): PhysicsGravitationalFieldEventData;
  107084. /**
  107085. * Enables the gravitational field.
  107086. */
  107087. enable(): void;
  107088. /**
  107089. * Disables the gravitational field.
  107090. */
  107091. disable(): void;
  107092. /**
  107093. * Disposes the sphere.
  107094. * @param force The force to dispose from the gravitational field event
  107095. */
  107096. dispose(force?: boolean): void;
  107097. private _tick;
  107098. }
  107099. /**
  107100. * Represents a physics updraft event
  107101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107102. */
  107103. export class PhysicsUpdraftEvent {
  107104. private _scene;
  107105. private _origin;
  107106. private _radius;
  107107. private _strength;
  107108. private _height;
  107109. private _updraftMode;
  107110. private _physicsEngine;
  107111. private _originTop;
  107112. private _originDirection;
  107113. private _tickCallback;
  107114. private _cylinder;
  107115. private _cylinderPosition;
  107116. private _dataFetched;
  107117. /**
  107118. * Initializes the physics updraft event
  107119. * @param _scene BabylonJS scene
  107120. * @param _origin The origin position of the updraft
  107121. * @param _radius The radius of the updraft
  107122. * @param _strength The strength of the updraft
  107123. * @param _height The height of the updraft
  107124. * @param _updraftMode The mode of the updraft
  107125. */
  107126. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107127. /**
  107128. * Returns the data related to the updraft event (cylinder).
  107129. * @returns A physics updraft event
  107130. */
  107131. getData(): PhysicsUpdraftEventData;
  107132. /**
  107133. * Enables the updraft.
  107134. */
  107135. enable(): void;
  107136. /**
  107137. * Disables the cortex.
  107138. */
  107139. disable(): void;
  107140. /**
  107141. * Disposes the sphere.
  107142. * @param force Specifies if the updraft should be disposed by force
  107143. */
  107144. dispose(force?: boolean): void;
  107145. private getImpostorForceAndContactPoint;
  107146. private _tick;
  107147. /*** Helpers ***/
  107148. private _prepareCylinder;
  107149. private _intersectsWithCylinder;
  107150. }
  107151. /**
  107152. * Represents a physics vortex event
  107153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107154. */
  107155. export class PhysicsVortexEvent {
  107156. private _scene;
  107157. private _origin;
  107158. private _radius;
  107159. private _strength;
  107160. private _height;
  107161. private _physicsEngine;
  107162. private _originTop;
  107163. private _centripetalForceThreshold;
  107164. private _updraftMultiplier;
  107165. private _tickCallback;
  107166. private _cylinder;
  107167. private _cylinderPosition;
  107168. private _dataFetched;
  107169. /**
  107170. * Initializes the physics vortex event
  107171. * @param _scene The BabylonJS scene
  107172. * @param _origin The origin position of the vortex
  107173. * @param _radius The radius of the vortex
  107174. * @param _strength The strength of the vortex
  107175. * @param _height The height of the vortex
  107176. */
  107177. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107178. /**
  107179. * Returns the data related to the vortex event (cylinder).
  107180. * @returns The physics vortex event data
  107181. */
  107182. getData(): PhysicsVortexEventData;
  107183. /**
  107184. * Enables the vortex.
  107185. */
  107186. enable(): void;
  107187. /**
  107188. * Disables the cortex.
  107189. */
  107190. disable(): void;
  107191. /**
  107192. * Disposes the sphere.
  107193. * @param force
  107194. */
  107195. dispose(force?: boolean): void;
  107196. private getImpostorForceAndContactPoint;
  107197. private _tick;
  107198. /*** Helpers ***/
  107199. private _prepareCylinder;
  107200. private _intersectsWithCylinder;
  107201. }
  107202. /**
  107203. * The strenght of the force in correspondence to the distance of the affected object
  107204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107205. */
  107206. export enum PhysicsRadialImpulseFalloff {
  107207. /** Defines that impulse is constant in strength across it's whole radius */
  107208. Constant = 0,
  107209. /** DEfines that impulse gets weaker if it's further from the origin */
  107210. Linear = 1
  107211. }
  107212. /**
  107213. * The strength of the force in correspondence to the distance of the affected object
  107214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107215. */
  107216. export enum PhysicsUpdraftMode {
  107217. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107218. Center = 0,
  107219. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107220. Perpendicular = 1
  107221. }
  107222. /**
  107223. * Interface for a physics force and contact point
  107224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107225. */
  107226. export interface PhysicsForceAndContactPoint {
  107227. /**
  107228. * The force applied at the contact point
  107229. */
  107230. force: Vector3;
  107231. /**
  107232. * The contact point
  107233. */
  107234. contactPoint: Vector3;
  107235. }
  107236. /**
  107237. * Interface for radial explosion event data
  107238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107239. */
  107240. export interface PhysicsRadialExplosionEventData {
  107241. /**
  107242. * A sphere used for the radial explosion event
  107243. */
  107244. sphere: Mesh;
  107245. /**
  107246. * An array of rays for the radial explosion event
  107247. */
  107248. rays: Array<Ray>;
  107249. }
  107250. /**
  107251. * Interface for gravitational field event data
  107252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107253. */
  107254. export interface PhysicsGravitationalFieldEventData {
  107255. /**
  107256. * A sphere mesh used for the gravitational field event
  107257. */
  107258. sphere: Mesh;
  107259. }
  107260. /**
  107261. * Interface for updraft event data
  107262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107263. */
  107264. export interface PhysicsUpdraftEventData {
  107265. /**
  107266. * A cylinder used for the updraft event
  107267. */
  107268. cylinder: Mesh;
  107269. }
  107270. /**
  107271. * Interface for vortex event data
  107272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107273. */
  107274. export interface PhysicsVortexEventData {
  107275. /**
  107276. * A cylinder used for the vortex event
  107277. */
  107278. cylinder: Mesh;
  107279. }
  107280. }
  107281. declare module BABYLON {
  107282. /**
  107283. * AmmoJS Physics plugin
  107284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107285. * @see https://github.com/kripken/ammo.js/
  107286. */
  107287. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107288. private _useDeltaForWorldStep;
  107289. /**
  107290. * Reference to the Ammo library
  107291. */
  107292. bjsAMMO: any;
  107293. /**
  107294. * Created ammoJS world which physics bodies are added to
  107295. */
  107296. world: any;
  107297. /**
  107298. * Name of the plugin
  107299. */
  107300. name: string;
  107301. private _timeStep;
  107302. private _fixedTimeStep;
  107303. private _maxSteps;
  107304. private _tmpQuaternion;
  107305. private _tmpAmmoTransform;
  107306. private _tmpAmmoQuaternion;
  107307. private _tmpAmmoConcreteContactResultCallback;
  107308. private _collisionConfiguration;
  107309. private _dispatcher;
  107310. private _overlappingPairCache;
  107311. private _solver;
  107312. private _tmpAmmoVectorA;
  107313. private _tmpAmmoVectorB;
  107314. private _tmpAmmoVectorC;
  107315. private _tmpContactCallbackResult;
  107316. private static readonly DISABLE_COLLISION_FLAG;
  107317. private static readonly KINEMATIC_FLAG;
  107318. private static readonly DISABLE_DEACTIVATION_FLAG;
  107319. /**
  107320. * Initializes the ammoJS plugin
  107321. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107322. * @param ammoInjection can be used to inject your own ammo reference
  107323. */
  107324. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107325. /**
  107326. * Sets the gravity of the physics world (m/(s^2))
  107327. * @param gravity Gravity to set
  107328. */
  107329. setGravity(gravity: Vector3): void;
  107330. /**
  107331. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107332. * @param timeStep timestep to use in seconds
  107333. */
  107334. setTimeStep(timeStep: number): void;
  107335. /**
  107336. * 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)
  107337. * @param fixedTimeStep fixedTimeStep to use in seconds
  107338. */
  107339. setFixedTimeStep(fixedTimeStep: number): void;
  107340. /**
  107341. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107342. * @param maxSteps the maximum number of steps by the physics engine per frame
  107343. */
  107344. setMaxSteps(maxSteps: number): void;
  107345. /**
  107346. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107347. * @returns the current timestep in seconds
  107348. */
  107349. getTimeStep(): number;
  107350. private _isImpostorInContact;
  107351. private _isImpostorPairInContact;
  107352. private _stepSimulation;
  107353. /**
  107354. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107355. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107356. * After the step the babylon meshes are set to the position of the physics imposters
  107357. * @param delta amount of time to step forward
  107358. * @param impostors array of imposters to update before/after the step
  107359. */
  107360. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107361. private _tmpVector;
  107362. private _tmpMatrix;
  107363. /**
  107364. * Applies an implulse on the imposter
  107365. * @param impostor imposter to apply impulse
  107366. * @param force amount of force to be applied to the imposter
  107367. * @param contactPoint the location to apply the impulse on the imposter
  107368. */
  107369. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107370. /**
  107371. * Applies a force on the imposter
  107372. * @param impostor imposter to apply force
  107373. * @param force amount of force to be applied to the imposter
  107374. * @param contactPoint the location to apply the force on the imposter
  107375. */
  107376. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107377. /**
  107378. * Creates a physics body using the plugin
  107379. * @param impostor the imposter to create the physics body on
  107380. */
  107381. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107382. /**
  107383. * Removes the physics body from the imposter and disposes of the body's memory
  107384. * @param impostor imposter to remove the physics body from
  107385. */
  107386. removePhysicsBody(impostor: PhysicsImpostor): void;
  107387. /**
  107388. * Generates a joint
  107389. * @param impostorJoint the imposter joint to create the joint with
  107390. */
  107391. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107392. /**
  107393. * Removes a joint
  107394. * @param impostorJoint the imposter joint to remove the joint from
  107395. */
  107396. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107397. private _addMeshVerts;
  107398. private _createShape;
  107399. /**
  107400. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107401. * @param impostor imposter containing the physics body and babylon object
  107402. */
  107403. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107404. /**
  107405. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107406. * @param impostor imposter containing the physics body and babylon object
  107407. * @param newPosition new position
  107408. * @param newRotation new rotation
  107409. */
  107410. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107411. /**
  107412. * If this plugin is supported
  107413. * @returns true if its supported
  107414. */
  107415. isSupported(): boolean;
  107416. /**
  107417. * Sets the linear velocity of the physics body
  107418. * @param impostor imposter to set the velocity on
  107419. * @param velocity velocity to set
  107420. */
  107421. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107422. /**
  107423. * Sets the angular velocity of the physics body
  107424. * @param impostor imposter to set the velocity on
  107425. * @param velocity velocity to set
  107426. */
  107427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107428. /**
  107429. * gets the linear velocity
  107430. * @param impostor imposter to get linear velocity from
  107431. * @returns linear velocity
  107432. */
  107433. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107434. /**
  107435. * gets the angular velocity
  107436. * @param impostor imposter to get angular velocity from
  107437. * @returns angular velocity
  107438. */
  107439. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107440. /**
  107441. * Sets the mass of physics body
  107442. * @param impostor imposter to set the mass on
  107443. * @param mass mass to set
  107444. */
  107445. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107446. /**
  107447. * Gets the mass of the physics body
  107448. * @param impostor imposter to get the mass from
  107449. * @returns mass
  107450. */
  107451. getBodyMass(impostor: PhysicsImpostor): number;
  107452. /**
  107453. * Gets friction of the impostor
  107454. * @param impostor impostor to get friction from
  107455. * @returns friction value
  107456. */
  107457. getBodyFriction(impostor: PhysicsImpostor): number;
  107458. /**
  107459. * Sets friction of the impostor
  107460. * @param impostor impostor to set friction on
  107461. * @param friction friction value
  107462. */
  107463. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107464. /**
  107465. * Gets restitution of the impostor
  107466. * @param impostor impostor to get restitution from
  107467. * @returns restitution value
  107468. */
  107469. getBodyRestitution(impostor: PhysicsImpostor): number;
  107470. /**
  107471. * Sets resitution of the impostor
  107472. * @param impostor impostor to set resitution on
  107473. * @param restitution resitution value
  107474. */
  107475. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107476. /**
  107477. * Sleeps the physics body and stops it from being active
  107478. * @param impostor impostor to sleep
  107479. */
  107480. sleepBody(impostor: PhysicsImpostor): void;
  107481. /**
  107482. * Activates the physics body
  107483. * @param impostor impostor to activate
  107484. */
  107485. wakeUpBody(impostor: PhysicsImpostor): void;
  107486. /**
  107487. * Updates the distance parameters of the joint
  107488. * @param joint joint to update
  107489. * @param maxDistance maximum distance of the joint
  107490. * @param minDistance minimum distance of the joint
  107491. */
  107492. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107493. /**
  107494. * Sets a motor on the joint
  107495. * @param joint joint to set motor on
  107496. * @param speed speed of the motor
  107497. * @param maxForce maximum force of the motor
  107498. * @param motorIndex index of the motor
  107499. */
  107500. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107501. /**
  107502. * Sets the motors limit
  107503. * @param joint joint to set limit on
  107504. * @param upperLimit upper limit
  107505. * @param lowerLimit lower limit
  107506. */
  107507. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107508. /**
  107509. * Syncs the position and rotation of a mesh with the impostor
  107510. * @param mesh mesh to sync
  107511. * @param impostor impostor to update the mesh with
  107512. */
  107513. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107514. /**
  107515. * Gets the radius of the impostor
  107516. * @param impostor impostor to get radius from
  107517. * @returns the radius
  107518. */
  107519. getRadius(impostor: PhysicsImpostor): number;
  107520. /**
  107521. * Gets the box size of the impostor
  107522. * @param impostor impostor to get box size from
  107523. * @param result the resulting box size
  107524. */
  107525. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107526. /**
  107527. * Disposes of the impostor
  107528. */
  107529. dispose(): void;
  107530. }
  107531. }
  107532. declare module BABYLON {
  107533. /** @hidden */
  107534. export var blackAndWhitePixelShader: {
  107535. name: string;
  107536. shader: string;
  107537. };
  107538. }
  107539. declare module BABYLON {
  107540. /**
  107541. * Post process used to render in black and white
  107542. */
  107543. export class BlackAndWhitePostProcess extends PostProcess {
  107544. /**
  107545. * Linear about to convert he result to black and white (default: 1)
  107546. */
  107547. degree: number;
  107548. /**
  107549. * Creates a black and white post process
  107550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107551. * @param name The name of the effect.
  107552. * @param options The required width/height ratio to downsize to before computing the render pass.
  107553. * @param camera The camera to apply the render pass to.
  107554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107555. * @param engine The engine which the post process will be applied. (default: current engine)
  107556. * @param reusable If the post process can be reused on the same frame. (default: false)
  107557. */
  107558. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107559. }
  107560. }
  107561. declare module BABYLON {
  107562. /**
  107563. * This represents a set of one or more post processes in Babylon.
  107564. * A post process can be used to apply a shader to a texture after it is rendered.
  107565. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107566. */
  107567. export class PostProcessRenderEffect {
  107568. private _postProcesses;
  107569. private _getPostProcesses;
  107570. private _singleInstance;
  107571. private _cameras;
  107572. private _indicesForCamera;
  107573. /**
  107574. * Name of the effect
  107575. * @hidden
  107576. */
  107577. _name: string;
  107578. /**
  107579. * Instantiates a post process render effect.
  107580. * A post process can be used to apply a shader to a texture after it is rendered.
  107581. * @param engine The engine the effect is tied to
  107582. * @param name The name of the effect
  107583. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  107584. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  107585. */
  107586. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  107587. /**
  107588. * Checks if all the post processes in the effect are supported.
  107589. */
  107590. readonly isSupported: boolean;
  107591. /**
  107592. * Updates the current state of the effect
  107593. * @hidden
  107594. */
  107595. _update(): void;
  107596. /**
  107597. * Attaches the effect on cameras
  107598. * @param cameras The camera to attach to.
  107599. * @hidden
  107600. */
  107601. _attachCameras(cameras: Camera): void;
  107602. /**
  107603. * Attaches the effect on cameras
  107604. * @param cameras The camera to attach to.
  107605. * @hidden
  107606. */
  107607. _attachCameras(cameras: Camera[]): void;
  107608. /**
  107609. * Detatches the effect on cameras
  107610. * @param cameras The camera to detatch from.
  107611. * @hidden
  107612. */
  107613. _detachCameras(cameras: Camera): void;
  107614. /**
  107615. * Detatches the effect on cameras
  107616. * @param cameras The camera to detatch from.
  107617. * @hidden
  107618. */
  107619. _detachCameras(cameras: Camera[]): void;
  107620. /**
  107621. * Enables the effect on given cameras
  107622. * @param cameras The camera to enable.
  107623. * @hidden
  107624. */
  107625. _enable(cameras: Camera): void;
  107626. /**
  107627. * Enables the effect on given cameras
  107628. * @param cameras The camera to enable.
  107629. * @hidden
  107630. */
  107631. _enable(cameras: Nullable<Camera[]>): void;
  107632. /**
  107633. * Disables the effect on the given cameras
  107634. * @param cameras The camera to disable.
  107635. * @hidden
  107636. */
  107637. _disable(cameras: Camera): void;
  107638. /**
  107639. * Disables the effect on the given cameras
  107640. * @param cameras The camera to disable.
  107641. * @hidden
  107642. */
  107643. _disable(cameras: Nullable<Camera[]>): void;
  107644. /**
  107645. * Gets a list of the post processes contained in the effect.
  107646. * @param camera The camera to get the post processes on.
  107647. * @returns The list of the post processes in the effect.
  107648. */
  107649. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  107650. }
  107651. }
  107652. declare module BABYLON {
  107653. /** @hidden */
  107654. export var extractHighlightsPixelShader: {
  107655. name: string;
  107656. shader: string;
  107657. };
  107658. }
  107659. declare module BABYLON {
  107660. /**
  107661. * 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.
  107662. */
  107663. export class ExtractHighlightsPostProcess extends PostProcess {
  107664. /**
  107665. * The luminance threshold, pixels below this value will be set to black.
  107666. */
  107667. threshold: number;
  107668. /** @hidden */
  107669. _exposure: number;
  107670. /**
  107671. * Post process which has the input texture to be used when performing highlight extraction
  107672. * @hidden
  107673. */
  107674. _inputPostProcess: Nullable<PostProcess>;
  107675. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107676. }
  107677. }
  107678. declare module BABYLON {
  107679. /** @hidden */
  107680. export var bloomMergePixelShader: {
  107681. name: string;
  107682. shader: string;
  107683. };
  107684. }
  107685. declare module BABYLON {
  107686. /**
  107687. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107688. */
  107689. export class BloomMergePostProcess extends PostProcess {
  107690. /** Weight of the bloom to be added to the original input. */
  107691. weight: number;
  107692. /**
  107693. * Creates a new instance of @see BloomMergePostProcess
  107694. * @param name The name of the effect.
  107695. * @param originalFromInput Post process which's input will be used for the merge.
  107696. * @param blurred Blurred highlights post process which's output will be used.
  107697. * @param weight Weight of the bloom to be added to the original input.
  107698. * @param options The required width/height ratio to downsize to before computing the render pass.
  107699. * @param camera The camera to apply the render pass to.
  107700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107701. * @param engine The engine which the post process will be applied. (default: current engine)
  107702. * @param reusable If the post process can be reused on the same frame. (default: false)
  107703. * @param textureType Type of textures used when performing the post process. (default: 0)
  107704. * @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)
  107705. */
  107706. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  107707. /** Weight of the bloom to be added to the original input. */
  107708. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107709. }
  107710. }
  107711. declare module BABYLON {
  107712. /**
  107713. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  107714. */
  107715. export class BloomEffect extends PostProcessRenderEffect {
  107716. private bloomScale;
  107717. /**
  107718. * @hidden Internal
  107719. */
  107720. _effects: Array<PostProcess>;
  107721. /**
  107722. * @hidden Internal
  107723. */
  107724. _downscale: ExtractHighlightsPostProcess;
  107725. private _blurX;
  107726. private _blurY;
  107727. private _merge;
  107728. /**
  107729. * The luminance threshold to find bright areas of the image to bloom.
  107730. */
  107731. threshold: number;
  107732. /**
  107733. * The strength of the bloom.
  107734. */
  107735. weight: number;
  107736. /**
  107737. * Specifies the size of the bloom blur kernel, relative to the final output size
  107738. */
  107739. kernel: number;
  107740. /**
  107741. * Creates a new instance of @see BloomEffect
  107742. * @param scene The scene the effect belongs to.
  107743. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  107744. * @param bloomKernel The size of the kernel to be used when applying the blur.
  107745. * @param bloomWeight The the strength of bloom.
  107746. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107747. * @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)
  107748. */
  107749. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  107750. /**
  107751. * Disposes each of the internal effects for a given camera.
  107752. * @param camera The camera to dispose the effect on.
  107753. */
  107754. disposeEffects(camera: Camera): void;
  107755. /**
  107756. * @hidden Internal
  107757. */
  107758. _updateEffects(): void;
  107759. /**
  107760. * Internal
  107761. * @returns if all the contained post processes are ready.
  107762. * @hidden
  107763. */
  107764. _isReady(): boolean;
  107765. }
  107766. }
  107767. declare module BABYLON {
  107768. /** @hidden */
  107769. export var chromaticAberrationPixelShader: {
  107770. name: string;
  107771. shader: string;
  107772. };
  107773. }
  107774. declare module BABYLON {
  107775. /**
  107776. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  107777. */
  107778. export class ChromaticAberrationPostProcess extends PostProcess {
  107779. /**
  107780. * The amount of seperation of rgb channels (default: 30)
  107781. */
  107782. aberrationAmount: number;
  107783. /**
  107784. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  107785. */
  107786. radialIntensity: number;
  107787. /**
  107788. * 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))
  107789. */
  107790. direction: Vector2;
  107791. /**
  107792. * 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))
  107793. */
  107794. centerPosition: Vector2;
  107795. /**
  107796. * Creates a new instance ChromaticAberrationPostProcess
  107797. * @param name The name of the effect.
  107798. * @param screenWidth The width of the screen to apply the effect on.
  107799. * @param screenHeight The height of the screen to apply the effect on.
  107800. * @param options The required width/height ratio to downsize to before computing the render pass.
  107801. * @param camera The camera to apply the render pass to.
  107802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107803. * @param engine The engine which the post process will be applied. (default: current engine)
  107804. * @param reusable If the post process can be reused on the same frame. (default: false)
  107805. * @param textureType Type of textures used when performing the post process. (default: 0)
  107806. * @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)
  107807. */
  107808. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107809. }
  107810. }
  107811. declare module BABYLON {
  107812. /** @hidden */
  107813. export var circleOfConfusionPixelShader: {
  107814. name: string;
  107815. shader: string;
  107816. };
  107817. }
  107818. declare module BABYLON {
  107819. /**
  107820. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  107821. */
  107822. export class CircleOfConfusionPostProcess extends PostProcess {
  107823. /**
  107824. * 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.
  107825. */
  107826. lensSize: number;
  107827. /**
  107828. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107829. */
  107830. fStop: number;
  107831. /**
  107832. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107833. */
  107834. focusDistance: number;
  107835. /**
  107836. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  107837. */
  107838. focalLength: number;
  107839. private _depthTexture;
  107840. /**
  107841. * Creates a new instance CircleOfConfusionPostProcess
  107842. * @param name The name of the effect.
  107843. * @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.
  107844. * @param options The required width/height ratio to downsize to before computing the render pass.
  107845. * @param camera The camera to apply the render pass to.
  107846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107847. * @param engine The engine which the post process will be applied. (default: current engine)
  107848. * @param reusable If the post process can be reused on the same frame. (default: false)
  107849. * @param textureType Type of textures used when performing the post process. (default: 0)
  107850. * @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)
  107851. */
  107852. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107853. /**
  107854. * 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.
  107855. */
  107856. depthTexture: RenderTargetTexture;
  107857. }
  107858. }
  107859. declare module BABYLON {
  107860. /** @hidden */
  107861. export var colorCorrectionPixelShader: {
  107862. name: string;
  107863. shader: string;
  107864. };
  107865. }
  107866. declare module BABYLON {
  107867. /**
  107868. *
  107869. * This post-process allows the modification of rendered colors by using
  107870. * a 'look-up table' (LUT). This effect is also called Color Grading.
  107871. *
  107872. * The object needs to be provided an url to a texture containing the color
  107873. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  107874. * Use an image editing software to tweak the LUT to match your needs.
  107875. *
  107876. * For an example of a color LUT, see here:
  107877. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  107878. * For explanations on color grading, see here:
  107879. * @see http://udn.epicgames.com/Three/ColorGrading.html
  107880. *
  107881. */
  107882. export class ColorCorrectionPostProcess extends PostProcess {
  107883. private _colorTableTexture;
  107884. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107885. }
  107886. }
  107887. declare module BABYLON {
  107888. /** @hidden */
  107889. export var convolutionPixelShader: {
  107890. name: string;
  107891. shader: string;
  107892. };
  107893. }
  107894. declare module BABYLON {
  107895. /**
  107896. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  107897. * input texture to perform effects such as edge detection or sharpening
  107898. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107899. */
  107900. export class ConvolutionPostProcess extends PostProcess {
  107901. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107902. kernel: number[];
  107903. /**
  107904. * Creates a new instance ConvolutionPostProcess
  107905. * @param name The name of the effect.
  107906. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107907. * @param options The required width/height ratio to downsize to before computing the render pass.
  107908. * @param camera The camera to apply the render pass to.
  107909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107910. * @param engine The engine which the post process will be applied. (default: current engine)
  107911. * @param reusable If the post process can be reused on the same frame. (default: false)
  107912. * @param textureType Type of textures used when performing the post process. (default: 0)
  107913. */
  107914. constructor(name: string,
  107915. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107916. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107917. /**
  107918. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107919. */
  107920. static EdgeDetect0Kernel: number[];
  107921. /**
  107922. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107923. */
  107924. static EdgeDetect1Kernel: number[];
  107925. /**
  107926. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107927. */
  107928. static EdgeDetect2Kernel: number[];
  107929. /**
  107930. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107931. */
  107932. static SharpenKernel: number[];
  107933. /**
  107934. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107935. */
  107936. static EmbossKernel: number[];
  107937. /**
  107938. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107939. */
  107940. static GaussianKernel: number[];
  107941. }
  107942. }
  107943. declare module BABYLON {
  107944. /**
  107945. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107946. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107947. * based on samples that have a large difference in distance than the center pixel.
  107948. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107949. */
  107950. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107951. direction: Vector2;
  107952. /**
  107953. * Creates a new instance CircleOfConfusionPostProcess
  107954. * @param name The name of the effect.
  107955. * @param scene The scene the effect belongs to.
  107956. * @param direction The direction the blur should be applied.
  107957. * @param kernel The size of the kernel used to blur.
  107958. * @param options The required width/height ratio to downsize to before computing the render pass.
  107959. * @param camera The camera to apply the render pass to.
  107960. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107961. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107963. * @param engine The engine which the post process will be applied. (default: current engine)
  107964. * @param reusable If the post process can be reused on the same frame. (default: false)
  107965. * @param textureType Type of textures used when performing the post process. (default: 0)
  107966. * @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)
  107967. */
  107968. 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);
  107969. }
  107970. }
  107971. declare module BABYLON {
  107972. /** @hidden */
  107973. export var depthOfFieldMergePixelShader: {
  107974. name: string;
  107975. shader: string;
  107976. };
  107977. }
  107978. declare module BABYLON {
  107979. /**
  107980. * Options to be set when merging outputs from the default pipeline.
  107981. */
  107982. export class DepthOfFieldMergePostProcessOptions {
  107983. /**
  107984. * The original image to merge on top of
  107985. */
  107986. originalFromInput: PostProcess;
  107987. /**
  107988. * Parameters to perform the merge of the depth of field effect
  107989. */
  107990. depthOfField?: {
  107991. circleOfConfusion: PostProcess;
  107992. blurSteps: Array<PostProcess>;
  107993. };
  107994. /**
  107995. * Parameters to perform the merge of bloom effect
  107996. */
  107997. bloom?: {
  107998. blurred: PostProcess;
  107999. weight: number;
  108000. };
  108001. }
  108002. /**
  108003. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108004. */
  108005. export class DepthOfFieldMergePostProcess extends PostProcess {
  108006. private blurSteps;
  108007. /**
  108008. * Creates a new instance of DepthOfFieldMergePostProcess
  108009. * @param name The name of the effect.
  108010. * @param originalFromInput Post process which's input will be used for the merge.
  108011. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108012. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108013. * @param options The required width/height ratio to downsize to before computing the render pass.
  108014. * @param camera The camera to apply the render pass to.
  108015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108016. * @param engine The engine which the post process will be applied. (default: current engine)
  108017. * @param reusable If the post process can be reused on the same frame. (default: false)
  108018. * @param textureType Type of textures used when performing the post process. (default: 0)
  108019. * @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)
  108020. */
  108021. 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);
  108022. /**
  108023. * Updates the effect with the current post process compile time values and recompiles the shader.
  108024. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108025. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108026. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108027. * @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
  108028. * @param onCompiled Called when the shader has been compiled.
  108029. * @param onError Called if there is an error when compiling a shader.
  108030. */
  108031. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108032. }
  108033. }
  108034. declare module BABYLON {
  108035. /**
  108036. * Specifies the level of max blur that should be applied when using the depth of field effect
  108037. */
  108038. export enum DepthOfFieldEffectBlurLevel {
  108039. /**
  108040. * Subtle blur
  108041. */
  108042. Low = 0,
  108043. /**
  108044. * Medium blur
  108045. */
  108046. Medium = 1,
  108047. /**
  108048. * Large blur
  108049. */
  108050. High = 2
  108051. }
  108052. /**
  108053. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108054. */
  108055. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108056. private _circleOfConfusion;
  108057. /**
  108058. * @hidden Internal, blurs from high to low
  108059. */
  108060. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108061. private _depthOfFieldBlurY;
  108062. private _dofMerge;
  108063. /**
  108064. * @hidden Internal post processes in depth of field effect
  108065. */
  108066. _effects: Array<PostProcess>;
  108067. /**
  108068. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108069. */
  108070. focalLength: number;
  108071. /**
  108072. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108073. */
  108074. fStop: number;
  108075. /**
  108076. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108077. */
  108078. focusDistance: number;
  108079. /**
  108080. * 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.
  108081. */
  108082. lensSize: number;
  108083. /**
  108084. * Creates a new instance DepthOfFieldEffect
  108085. * @param scene The scene the effect belongs to.
  108086. * @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.
  108087. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108088. * @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)
  108089. */
  108090. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108091. /**
  108092. * 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.
  108093. */
  108094. depthTexture: RenderTargetTexture;
  108095. /**
  108096. * Disposes each of the internal effects for a given camera.
  108097. * @param camera The camera to dispose the effect on.
  108098. */
  108099. disposeEffects(camera: Camera): void;
  108100. /**
  108101. * @hidden Internal
  108102. */
  108103. _updateEffects(): void;
  108104. /**
  108105. * Internal
  108106. * @returns if all the contained post processes are ready.
  108107. * @hidden
  108108. */
  108109. _isReady(): boolean;
  108110. }
  108111. }
  108112. declare module BABYLON {
  108113. /** @hidden */
  108114. export var displayPassPixelShader: {
  108115. name: string;
  108116. shader: string;
  108117. };
  108118. }
  108119. declare module BABYLON {
  108120. /**
  108121. * DisplayPassPostProcess which produces an output the same as it's input
  108122. */
  108123. export class DisplayPassPostProcess extends PostProcess {
  108124. /**
  108125. * Creates the DisplayPassPostProcess
  108126. * @param name The name of the effect.
  108127. * @param options The required width/height ratio to downsize to before computing the render pass.
  108128. * @param camera The camera to apply the render pass to.
  108129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108130. * @param engine The engine which the post process will be applied. (default: current engine)
  108131. * @param reusable If the post process can be reused on the same frame. (default: false)
  108132. */
  108133. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108134. }
  108135. }
  108136. declare module BABYLON {
  108137. /** @hidden */
  108138. export var filterPixelShader: {
  108139. name: string;
  108140. shader: string;
  108141. };
  108142. }
  108143. declare module BABYLON {
  108144. /**
  108145. * Applies a kernel filter to the image
  108146. */
  108147. export class FilterPostProcess extends PostProcess {
  108148. /** The matrix to be applied to the image */
  108149. kernelMatrix: Matrix;
  108150. /**
  108151. *
  108152. * @param name The name of the effect.
  108153. * @param kernelMatrix The matrix to be applied to the image
  108154. * @param options The required width/height ratio to downsize to before computing the render pass.
  108155. * @param camera The camera to apply the render pass to.
  108156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108157. * @param engine The engine which the post process will be applied. (default: current engine)
  108158. * @param reusable If the post process can be reused on the same frame. (default: false)
  108159. */
  108160. constructor(name: string,
  108161. /** The matrix to be applied to the image */
  108162. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108163. }
  108164. }
  108165. declare module BABYLON {
  108166. /** @hidden */
  108167. export var fxaaPixelShader: {
  108168. name: string;
  108169. shader: string;
  108170. };
  108171. }
  108172. declare module BABYLON {
  108173. /** @hidden */
  108174. export var fxaaVertexShader: {
  108175. name: string;
  108176. shader: string;
  108177. };
  108178. }
  108179. declare module BABYLON {
  108180. /**
  108181. * Fxaa post process
  108182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108183. */
  108184. export class FxaaPostProcess extends PostProcess {
  108185. /** @hidden */
  108186. texelWidth: number;
  108187. /** @hidden */
  108188. texelHeight: number;
  108189. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108190. private _getDefines;
  108191. }
  108192. }
  108193. declare module BABYLON {
  108194. /** @hidden */
  108195. export var grainPixelShader: {
  108196. name: string;
  108197. shader: string;
  108198. };
  108199. }
  108200. declare module BABYLON {
  108201. /**
  108202. * The GrainPostProcess adds noise to the image at mid luminance levels
  108203. */
  108204. export class GrainPostProcess extends PostProcess {
  108205. /**
  108206. * The intensity of the grain added (default: 30)
  108207. */
  108208. intensity: number;
  108209. /**
  108210. * If the grain should be randomized on every frame
  108211. */
  108212. animated: boolean;
  108213. /**
  108214. * Creates a new instance of @see GrainPostProcess
  108215. * @param name The name of the effect.
  108216. * @param options The required width/height ratio to downsize to before computing the render pass.
  108217. * @param camera The camera to apply the render pass to.
  108218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108219. * @param engine The engine which the post process will be applied. (default: current engine)
  108220. * @param reusable If the post process can be reused on the same frame. (default: false)
  108221. * @param textureType Type of textures used when performing the post process. (default: 0)
  108222. * @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)
  108223. */
  108224. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108225. }
  108226. }
  108227. declare module BABYLON {
  108228. /** @hidden */
  108229. export var highlightsPixelShader: {
  108230. name: string;
  108231. shader: string;
  108232. };
  108233. }
  108234. declare module BABYLON {
  108235. /**
  108236. * Extracts highlights from the image
  108237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108238. */
  108239. export class HighlightsPostProcess extends PostProcess {
  108240. /**
  108241. * Extracts highlights from the image
  108242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108243. * @param name The name of the effect.
  108244. * @param options The required width/height ratio to downsize to before computing the render pass.
  108245. * @param camera The camera to apply the render pass to.
  108246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108247. * @param engine The engine which the post process will be applied. (default: current engine)
  108248. * @param reusable If the post process can be reused on the same frame. (default: false)
  108249. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108250. */
  108251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108252. }
  108253. }
  108254. declare module BABYLON {
  108255. /** @hidden */
  108256. export var mrtFragmentDeclaration: {
  108257. name: string;
  108258. shader: string;
  108259. };
  108260. }
  108261. declare module BABYLON {
  108262. /** @hidden */
  108263. export var geometryPixelShader: {
  108264. name: string;
  108265. shader: string;
  108266. };
  108267. }
  108268. declare module BABYLON {
  108269. /** @hidden */
  108270. export var geometryVertexShader: {
  108271. name: string;
  108272. shader: string;
  108273. };
  108274. }
  108275. declare module BABYLON {
  108276. /**
  108277. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108278. */
  108279. export class GeometryBufferRenderer {
  108280. /**
  108281. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108282. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108283. */
  108284. static readonly POSITION_TEXTURE_TYPE: number;
  108285. /**
  108286. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108287. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108288. */
  108289. static readonly VELOCITY_TEXTURE_TYPE: number;
  108290. /**
  108291. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108292. * in order to compute objects velocities when enableVelocity is set to "true"
  108293. * @hidden
  108294. */
  108295. _previousTransformationMatrices: {
  108296. [index: number]: Matrix;
  108297. };
  108298. private _scene;
  108299. private _multiRenderTarget;
  108300. private _ratio;
  108301. private _enablePosition;
  108302. private _enableVelocity;
  108303. private _positionIndex;
  108304. private _velocityIndex;
  108305. protected _effect: Effect;
  108306. protected _cachedDefines: string;
  108307. /**
  108308. * Set the render list (meshes to be rendered) used in the G buffer.
  108309. */
  108310. renderList: Mesh[];
  108311. /**
  108312. * Gets wether or not G buffer are supported by the running hardware.
  108313. * This requires draw buffer supports
  108314. */
  108315. readonly isSupported: boolean;
  108316. /**
  108317. * Returns the index of the given texture type in the G-Buffer textures array
  108318. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108319. * @returns the index of the given texture type in the G-Buffer textures array
  108320. */
  108321. getTextureIndex(textureType: number): number;
  108322. /**
  108323. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108324. */
  108325. /**
  108326. * Sets whether or not objects positions are enabled for the G buffer.
  108327. */
  108328. enablePosition: boolean;
  108329. /**
  108330. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108331. */
  108332. /**
  108333. * Sets wether or not objects velocities are enabled for the G buffer.
  108334. */
  108335. enableVelocity: boolean;
  108336. /**
  108337. * Gets the scene associated with the buffer.
  108338. */
  108339. readonly scene: Scene;
  108340. /**
  108341. * Gets the ratio used by the buffer during its creation.
  108342. * How big is the buffer related to the main canvas.
  108343. */
  108344. readonly ratio: number;
  108345. /** @hidden */
  108346. static _SceneComponentInitialization: (scene: Scene) => void;
  108347. /**
  108348. * Creates a new G Buffer for the scene
  108349. * @param scene The scene the buffer belongs to
  108350. * @param ratio How big is the buffer related to the main canvas.
  108351. */
  108352. constructor(scene: Scene, ratio?: number);
  108353. /**
  108354. * Checks wether everything is ready to render a submesh to the G buffer.
  108355. * @param subMesh the submesh to check readiness for
  108356. * @param useInstances is the mesh drawn using instance or not
  108357. * @returns true if ready otherwise false
  108358. */
  108359. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108360. /**
  108361. * Gets the current underlying G Buffer.
  108362. * @returns the buffer
  108363. */
  108364. getGBuffer(): MultiRenderTarget;
  108365. /**
  108366. * Gets the number of samples used to render the buffer (anti aliasing).
  108367. */
  108368. /**
  108369. * Sets the number of samples used to render the buffer (anti aliasing).
  108370. */
  108371. samples: number;
  108372. /**
  108373. * Disposes the renderer and frees up associated resources.
  108374. */
  108375. dispose(): void;
  108376. protected _createRenderTargets(): void;
  108377. }
  108378. }
  108379. declare module BABYLON {
  108380. /** @hidden */
  108381. export var motionBlurPixelShader: {
  108382. name: string;
  108383. shader: string;
  108384. };
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108389. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108390. * As an example, all you have to do is to create the post-process:
  108391. * var mb = new BABYLON.MotionBlurPostProcess(
  108392. * 'mb', // The name of the effect.
  108393. * scene, // The scene containing the objects to blur according to their velocity.
  108394. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108395. * camera // The camera to apply the render pass to.
  108396. * );
  108397. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108398. */
  108399. export class MotionBlurPostProcess extends PostProcess {
  108400. /**
  108401. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108402. */
  108403. motionStrength: number;
  108404. /**
  108405. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108406. */
  108407. /**
  108408. * Sets the number of iterations to be used for motion blur quality
  108409. */
  108410. motionBlurSamples: number;
  108411. private _motionBlurSamples;
  108412. private _geometryBufferRenderer;
  108413. /**
  108414. * Creates a new instance MotionBlurPostProcess
  108415. * @param name The name of the effect.
  108416. * @param scene The scene containing the objects to blur according to their velocity.
  108417. * @param options The required width/height ratio to downsize to before computing the render pass.
  108418. * @param camera The camera to apply the render pass to.
  108419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108420. * @param engine The engine which the post process will be applied. (default: current engine)
  108421. * @param reusable If the post process can be reused on the same frame. (default: false)
  108422. * @param textureType Type of textures used when performing the post process. (default: 0)
  108423. * @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)
  108424. */
  108425. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108426. /**
  108427. * Disposes the post process.
  108428. * @param camera The camera to dispose the post process on.
  108429. */
  108430. dispose(camera?: Camera): void;
  108431. }
  108432. }
  108433. declare module BABYLON {
  108434. /** @hidden */
  108435. export var refractionPixelShader: {
  108436. name: string;
  108437. shader: string;
  108438. };
  108439. }
  108440. declare module BABYLON {
  108441. /**
  108442. * Post process which applies a refractin texture
  108443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108444. */
  108445. export class RefractionPostProcess extends PostProcess {
  108446. /** the base color of the refraction (used to taint the rendering) */
  108447. color: Color3;
  108448. /** simulated refraction depth */
  108449. depth: number;
  108450. /** the coefficient of the base color (0 to remove base color tainting) */
  108451. colorLevel: number;
  108452. private _refTexture;
  108453. private _ownRefractionTexture;
  108454. /**
  108455. * Gets or sets the refraction texture
  108456. * Please note that you are responsible for disposing the texture if you set it manually
  108457. */
  108458. refractionTexture: Texture;
  108459. /**
  108460. * Initializes the RefractionPostProcess
  108461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108462. * @param name The name of the effect.
  108463. * @param refractionTextureUrl Url of the refraction texture to use
  108464. * @param color the base color of the refraction (used to taint the rendering)
  108465. * @param depth simulated refraction depth
  108466. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108467. * @param camera The camera to apply the render pass to.
  108468. * @param options The required width/height ratio to downsize to before computing the render pass.
  108469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108470. * @param engine The engine which the post process will be applied. (default: current engine)
  108471. * @param reusable If the post process can be reused on the same frame. (default: false)
  108472. */
  108473. constructor(name: string, refractionTextureUrl: string,
  108474. /** the base color of the refraction (used to taint the rendering) */
  108475. color: Color3,
  108476. /** simulated refraction depth */
  108477. depth: number,
  108478. /** the coefficient of the base color (0 to remove base color tainting) */
  108479. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108480. /**
  108481. * Disposes of the post process
  108482. * @param camera Camera to dispose post process on
  108483. */
  108484. dispose(camera: Camera): void;
  108485. }
  108486. }
  108487. declare module BABYLON {
  108488. /** @hidden */
  108489. export var sharpenPixelShader: {
  108490. name: string;
  108491. shader: string;
  108492. };
  108493. }
  108494. declare module BABYLON {
  108495. /**
  108496. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108497. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108498. */
  108499. export class SharpenPostProcess extends PostProcess {
  108500. /**
  108501. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108502. */
  108503. colorAmount: number;
  108504. /**
  108505. * How much sharpness should be applied (default: 0.3)
  108506. */
  108507. edgeAmount: number;
  108508. /**
  108509. * Creates a new instance ConvolutionPostProcess
  108510. * @param name The name of the effect.
  108511. * @param options The required width/height ratio to downsize to before computing the render pass.
  108512. * @param camera The camera to apply the render pass to.
  108513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108514. * @param engine The engine which the post process will be applied. (default: current engine)
  108515. * @param reusable If the post process can be reused on the same frame. (default: false)
  108516. * @param textureType Type of textures used when performing the post process. (default: 0)
  108517. * @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)
  108518. */
  108519. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108520. }
  108521. }
  108522. declare module BABYLON {
  108523. /**
  108524. * PostProcessRenderPipeline
  108525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108526. */
  108527. export class PostProcessRenderPipeline {
  108528. private engine;
  108529. private _renderEffects;
  108530. private _renderEffectsForIsolatedPass;
  108531. /**
  108532. * @hidden
  108533. */
  108534. protected _cameras: Camera[];
  108535. /** @hidden */
  108536. _name: string;
  108537. /**
  108538. * Gets pipeline name
  108539. */
  108540. readonly name: string;
  108541. /**
  108542. * Initializes a PostProcessRenderPipeline
  108543. * @param engine engine to add the pipeline to
  108544. * @param name name of the pipeline
  108545. */
  108546. constructor(engine: Engine, name: string);
  108547. /**
  108548. * Gets the class name
  108549. * @returns "PostProcessRenderPipeline"
  108550. */
  108551. getClassName(): string;
  108552. /**
  108553. * If all the render effects in the pipeline are supported
  108554. */
  108555. readonly isSupported: boolean;
  108556. /**
  108557. * Adds an effect to the pipeline
  108558. * @param renderEffect the effect to add
  108559. */
  108560. addEffect(renderEffect: PostProcessRenderEffect): void;
  108561. /** @hidden */
  108562. _rebuild(): void;
  108563. /** @hidden */
  108564. _enableEffect(renderEffectName: string, cameras: Camera): void;
  108565. /** @hidden */
  108566. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  108567. /** @hidden */
  108568. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108569. /** @hidden */
  108570. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108571. /** @hidden */
  108572. _attachCameras(cameras: Camera, unique: boolean): void;
  108573. /** @hidden */
  108574. _attachCameras(cameras: Camera[], unique: boolean): void;
  108575. /** @hidden */
  108576. _detachCameras(cameras: Camera): void;
  108577. /** @hidden */
  108578. _detachCameras(cameras: Nullable<Camera[]>): void;
  108579. /** @hidden */
  108580. _update(): void;
  108581. /** @hidden */
  108582. _reset(): void;
  108583. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  108584. /**
  108585. * Disposes of the pipeline
  108586. */
  108587. dispose(): void;
  108588. }
  108589. }
  108590. declare module BABYLON {
  108591. /**
  108592. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  108593. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108594. */
  108595. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108596. private _scene;
  108597. private _camerasToBeAttached;
  108598. /**
  108599. * ID of the sharpen post process,
  108600. */
  108601. private readonly SharpenPostProcessId;
  108602. /**
  108603. * @ignore
  108604. * ID of the image processing post process;
  108605. */
  108606. readonly ImageProcessingPostProcessId: string;
  108607. /**
  108608. * @ignore
  108609. * ID of the Fast Approximate Anti-Aliasing post process;
  108610. */
  108611. readonly FxaaPostProcessId: string;
  108612. /**
  108613. * ID of the chromatic aberration post process,
  108614. */
  108615. private readonly ChromaticAberrationPostProcessId;
  108616. /**
  108617. * ID of the grain post process
  108618. */
  108619. private readonly GrainPostProcessId;
  108620. /**
  108621. * Sharpen post process which will apply a sharpen convolution to enhance edges
  108622. */
  108623. sharpen: SharpenPostProcess;
  108624. private _sharpenEffect;
  108625. private bloom;
  108626. /**
  108627. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  108628. */
  108629. depthOfField: DepthOfFieldEffect;
  108630. /**
  108631. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108632. */
  108633. fxaa: FxaaPostProcess;
  108634. /**
  108635. * Image post processing pass used to perform operations such as tone mapping or color grading.
  108636. */
  108637. imageProcessing: ImageProcessingPostProcess;
  108638. /**
  108639. * Chromatic aberration post process which will shift rgb colors in the image
  108640. */
  108641. chromaticAberration: ChromaticAberrationPostProcess;
  108642. private _chromaticAberrationEffect;
  108643. /**
  108644. * Grain post process which add noise to the image
  108645. */
  108646. grain: GrainPostProcess;
  108647. private _grainEffect;
  108648. /**
  108649. * Glow post process which adds a glow to emissive areas of the image
  108650. */
  108651. private _glowLayer;
  108652. /**
  108653. * Animations which can be used to tweak settings over a period of time
  108654. */
  108655. animations: Animation[];
  108656. private _imageProcessingConfigurationObserver;
  108657. private _sharpenEnabled;
  108658. private _bloomEnabled;
  108659. private _depthOfFieldEnabled;
  108660. private _depthOfFieldBlurLevel;
  108661. private _fxaaEnabled;
  108662. private _imageProcessingEnabled;
  108663. private _defaultPipelineTextureType;
  108664. private _bloomScale;
  108665. private _chromaticAberrationEnabled;
  108666. private _grainEnabled;
  108667. private _buildAllowed;
  108668. /**
  108669. * Gets active scene
  108670. */
  108671. readonly scene: Scene;
  108672. /**
  108673. * Enable or disable the sharpen process from the pipeline
  108674. */
  108675. sharpenEnabled: boolean;
  108676. private _resizeObserver;
  108677. private _hardwareScaleLevel;
  108678. private _bloomKernel;
  108679. /**
  108680. * Specifies the size of the bloom blur kernel, relative to the final output size
  108681. */
  108682. bloomKernel: number;
  108683. /**
  108684. * Specifies the weight of the bloom in the final rendering
  108685. */
  108686. private _bloomWeight;
  108687. /**
  108688. * Specifies the luma threshold for the area that will be blurred by the bloom
  108689. */
  108690. private _bloomThreshold;
  108691. private _hdr;
  108692. /**
  108693. * The strength of the bloom.
  108694. */
  108695. bloomWeight: number;
  108696. /**
  108697. * The strength of the bloom.
  108698. */
  108699. bloomThreshold: number;
  108700. /**
  108701. * The scale of the bloom, lower value will provide better performance.
  108702. */
  108703. bloomScale: number;
  108704. /**
  108705. * Enable or disable the bloom from the pipeline
  108706. */
  108707. bloomEnabled: boolean;
  108708. private _rebuildBloom;
  108709. /**
  108710. * If the depth of field is enabled.
  108711. */
  108712. depthOfFieldEnabled: boolean;
  108713. /**
  108714. * Blur level of the depth of field effect. (Higher blur will effect performance)
  108715. */
  108716. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  108717. /**
  108718. * If the anti aliasing is enabled.
  108719. */
  108720. fxaaEnabled: boolean;
  108721. private _samples;
  108722. /**
  108723. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108724. */
  108725. samples: number;
  108726. /**
  108727. * If image processing is enabled.
  108728. */
  108729. imageProcessingEnabled: boolean;
  108730. /**
  108731. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  108732. */
  108733. glowLayerEnabled: boolean;
  108734. /**
  108735. * Enable or disable the chromaticAberration process from the pipeline
  108736. */
  108737. chromaticAberrationEnabled: boolean;
  108738. /**
  108739. * Enable or disable the grain process from the pipeline
  108740. */
  108741. grainEnabled: boolean;
  108742. /**
  108743. * @constructor
  108744. * @param name - The rendering pipeline name (default: "")
  108745. * @param hdr - If high dynamic range textures should be used (default: true)
  108746. * @param scene - The scene linked to this pipeline (default: the last created scene)
  108747. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  108748. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  108749. */
  108750. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  108751. /**
  108752. * Get the class name
  108753. * @returns "DefaultRenderingPipeline"
  108754. */
  108755. getClassName(): string;
  108756. /**
  108757. * Force the compilation of the entire pipeline.
  108758. */
  108759. prepare(): void;
  108760. private _hasCleared;
  108761. private _prevPostProcess;
  108762. private _prevPrevPostProcess;
  108763. private _setAutoClearAndTextureSharing;
  108764. private _depthOfFieldSceneObserver;
  108765. private _buildPipeline;
  108766. private _disposePostProcesses;
  108767. /**
  108768. * Adds a camera to the pipeline
  108769. * @param camera the camera to be added
  108770. */
  108771. addCamera(camera: Camera): void;
  108772. /**
  108773. * Removes a camera from the pipeline
  108774. * @param camera the camera to remove
  108775. */
  108776. removeCamera(camera: Camera): void;
  108777. /**
  108778. * Dispose of the pipeline and stop all post processes
  108779. */
  108780. dispose(): void;
  108781. /**
  108782. * Serialize the rendering pipeline (Used when exporting)
  108783. * @returns the serialized object
  108784. */
  108785. serialize(): any;
  108786. /**
  108787. * Parse the serialized pipeline
  108788. * @param source Source pipeline.
  108789. * @param scene The scene to load the pipeline to.
  108790. * @param rootUrl The URL of the serialized pipeline.
  108791. * @returns An instantiated pipeline from the serialized object.
  108792. */
  108793. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  108794. }
  108795. }
  108796. declare module BABYLON {
  108797. /** @hidden */
  108798. export var lensHighlightsPixelShader: {
  108799. name: string;
  108800. shader: string;
  108801. };
  108802. }
  108803. declare module BABYLON {
  108804. /** @hidden */
  108805. export var depthOfFieldPixelShader: {
  108806. name: string;
  108807. shader: string;
  108808. };
  108809. }
  108810. declare module BABYLON {
  108811. /**
  108812. * BABYLON.JS Chromatic Aberration GLSL Shader
  108813. * Author: Olivier Guyot
  108814. * Separates very slightly R, G and B colors on the edges of the screen
  108815. * Inspired by Francois Tarlier & Martins Upitis
  108816. */
  108817. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  108818. /**
  108819. * @ignore
  108820. * The chromatic aberration PostProcess id in the pipeline
  108821. */
  108822. LensChromaticAberrationEffect: string;
  108823. /**
  108824. * @ignore
  108825. * The highlights enhancing PostProcess id in the pipeline
  108826. */
  108827. HighlightsEnhancingEffect: string;
  108828. /**
  108829. * @ignore
  108830. * The depth-of-field PostProcess id in the pipeline
  108831. */
  108832. LensDepthOfFieldEffect: string;
  108833. private _scene;
  108834. private _depthTexture;
  108835. private _grainTexture;
  108836. private _chromaticAberrationPostProcess;
  108837. private _highlightsPostProcess;
  108838. private _depthOfFieldPostProcess;
  108839. private _edgeBlur;
  108840. private _grainAmount;
  108841. private _chromaticAberration;
  108842. private _distortion;
  108843. private _highlightsGain;
  108844. private _highlightsThreshold;
  108845. private _dofDistance;
  108846. private _dofAperture;
  108847. private _dofDarken;
  108848. private _dofPentagon;
  108849. private _blurNoise;
  108850. /**
  108851. * @constructor
  108852. *
  108853. * Effect parameters are as follow:
  108854. * {
  108855. * chromatic_aberration: number; // from 0 to x (1 for realism)
  108856. * edge_blur: number; // from 0 to x (1 for realism)
  108857. * distortion: number; // from 0 to x (1 for realism)
  108858. * grain_amount: number; // from 0 to 1
  108859. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  108860. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  108861. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  108862. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  108863. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  108864. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  108865. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  108866. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  108867. * }
  108868. * Note: if an effect parameter is unset, effect is disabled
  108869. *
  108870. * @param name The rendering pipeline name
  108871. * @param parameters - An object containing all parameters (see above)
  108872. * @param scene The scene linked to this pipeline
  108873. * @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)
  108874. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108875. */
  108876. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  108877. /**
  108878. * Sets the amount of blur at the edges
  108879. * @param amount blur amount
  108880. */
  108881. setEdgeBlur(amount: number): void;
  108882. /**
  108883. * Sets edge blur to 0
  108884. */
  108885. disableEdgeBlur(): void;
  108886. /**
  108887. * Sets the amout of grain
  108888. * @param amount Amount of grain
  108889. */
  108890. setGrainAmount(amount: number): void;
  108891. /**
  108892. * Set grain amount to 0
  108893. */
  108894. disableGrain(): void;
  108895. /**
  108896. * Sets the chromatic aberration amount
  108897. * @param amount amount of chromatic aberration
  108898. */
  108899. setChromaticAberration(amount: number): void;
  108900. /**
  108901. * Sets chromatic aberration amount to 0
  108902. */
  108903. disableChromaticAberration(): void;
  108904. /**
  108905. * Sets the EdgeDistortion amount
  108906. * @param amount amount of EdgeDistortion
  108907. */
  108908. setEdgeDistortion(amount: number): void;
  108909. /**
  108910. * Sets edge distortion to 0
  108911. */
  108912. disableEdgeDistortion(): void;
  108913. /**
  108914. * Sets the FocusDistance amount
  108915. * @param amount amount of FocusDistance
  108916. */
  108917. setFocusDistance(amount: number): void;
  108918. /**
  108919. * Disables depth of field
  108920. */
  108921. disableDepthOfField(): void;
  108922. /**
  108923. * Sets the Aperture amount
  108924. * @param amount amount of Aperture
  108925. */
  108926. setAperture(amount: number): void;
  108927. /**
  108928. * Sets the DarkenOutOfFocus amount
  108929. * @param amount amount of DarkenOutOfFocus
  108930. */
  108931. setDarkenOutOfFocus(amount: number): void;
  108932. /**
  108933. * Creates a pentagon bokeh effect
  108934. */
  108935. enablePentagonBokeh(): void;
  108936. /**
  108937. * Disables the pentagon bokeh effect
  108938. */
  108939. disablePentagonBokeh(): void;
  108940. /**
  108941. * Enables noise blur
  108942. */
  108943. enableNoiseBlur(): void;
  108944. /**
  108945. * Disables noise blur
  108946. */
  108947. disableNoiseBlur(): void;
  108948. /**
  108949. * Sets the HighlightsGain amount
  108950. * @param amount amount of HighlightsGain
  108951. */
  108952. setHighlightsGain(amount: number): void;
  108953. /**
  108954. * Sets the HighlightsThreshold amount
  108955. * @param amount amount of HighlightsThreshold
  108956. */
  108957. setHighlightsThreshold(amount: number): void;
  108958. /**
  108959. * Disables highlights
  108960. */
  108961. disableHighlights(): void;
  108962. /**
  108963. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108964. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108965. */
  108966. dispose(disableDepthRender?: boolean): void;
  108967. private _createChromaticAberrationPostProcess;
  108968. private _createHighlightsPostProcess;
  108969. private _createDepthOfFieldPostProcess;
  108970. private _createGrainTexture;
  108971. }
  108972. }
  108973. declare module BABYLON {
  108974. /** @hidden */
  108975. export var ssao2PixelShader: {
  108976. name: string;
  108977. shader: string;
  108978. };
  108979. }
  108980. declare module BABYLON {
  108981. /** @hidden */
  108982. export var ssaoCombinePixelShader: {
  108983. name: string;
  108984. shader: string;
  108985. };
  108986. }
  108987. declare module BABYLON {
  108988. /**
  108989. * Render pipeline to produce ssao effect
  108990. */
  108991. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  108992. /**
  108993. * @ignore
  108994. * The PassPostProcess id in the pipeline that contains the original scene color
  108995. */
  108996. SSAOOriginalSceneColorEffect: string;
  108997. /**
  108998. * @ignore
  108999. * The SSAO PostProcess id in the pipeline
  109000. */
  109001. SSAORenderEffect: string;
  109002. /**
  109003. * @ignore
  109004. * The horizontal blur PostProcess id in the pipeline
  109005. */
  109006. SSAOBlurHRenderEffect: string;
  109007. /**
  109008. * @ignore
  109009. * The vertical blur PostProcess id in the pipeline
  109010. */
  109011. SSAOBlurVRenderEffect: string;
  109012. /**
  109013. * @ignore
  109014. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109015. */
  109016. SSAOCombineRenderEffect: string;
  109017. /**
  109018. * The output strength of the SSAO post-process. Default value is 1.0.
  109019. */
  109020. totalStrength: number;
  109021. /**
  109022. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109023. */
  109024. maxZ: number;
  109025. /**
  109026. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109027. */
  109028. minZAspect: number;
  109029. private _samples;
  109030. /**
  109031. * Number of samples used for the SSAO calculations. Default value is 8
  109032. */
  109033. samples: number;
  109034. private _textureSamples;
  109035. /**
  109036. * Number of samples to use for antialiasing
  109037. */
  109038. textureSamples: number;
  109039. /**
  109040. * Ratio object used for SSAO ratio and blur ratio
  109041. */
  109042. private _ratio;
  109043. /**
  109044. * Dynamically generated sphere sampler.
  109045. */
  109046. private _sampleSphere;
  109047. /**
  109048. * Blur filter offsets
  109049. */
  109050. private _samplerOffsets;
  109051. private _expensiveBlur;
  109052. /**
  109053. * If bilateral blur should be used
  109054. */
  109055. expensiveBlur: boolean;
  109056. /**
  109057. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109058. */
  109059. radius: number;
  109060. /**
  109061. * The base color of the SSAO post-process
  109062. * The final result is "base + ssao" between [0, 1]
  109063. */
  109064. base: number;
  109065. /**
  109066. * Support test.
  109067. */
  109068. static readonly IsSupported: boolean;
  109069. private _scene;
  109070. private _depthTexture;
  109071. private _normalTexture;
  109072. private _randomTexture;
  109073. private _originalColorPostProcess;
  109074. private _ssaoPostProcess;
  109075. private _blurHPostProcess;
  109076. private _blurVPostProcess;
  109077. private _ssaoCombinePostProcess;
  109078. private _firstUpdate;
  109079. /**
  109080. * Gets active scene
  109081. */
  109082. readonly scene: Scene;
  109083. /**
  109084. * @constructor
  109085. * @param name The rendering pipeline name
  109086. * @param scene The scene linked to this pipeline
  109087. * @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 }
  109088. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109089. */
  109090. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109091. /**
  109092. * Get the class name
  109093. * @returns "SSAO2RenderingPipeline"
  109094. */
  109095. getClassName(): string;
  109096. /**
  109097. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109098. */
  109099. dispose(disableGeometryBufferRenderer?: boolean): void;
  109100. private _createBlurPostProcess;
  109101. /** @hidden */
  109102. _rebuild(): void;
  109103. private _bits;
  109104. private _radicalInverse_VdC;
  109105. private _hammersley;
  109106. private _hemisphereSample_uniform;
  109107. private _generateHemisphere;
  109108. private _createSSAOPostProcess;
  109109. private _createSSAOCombinePostProcess;
  109110. private _createRandomTexture;
  109111. /**
  109112. * Serialize the rendering pipeline (Used when exporting)
  109113. * @returns the serialized object
  109114. */
  109115. serialize(): any;
  109116. /**
  109117. * Parse the serialized pipeline
  109118. * @param source Source pipeline.
  109119. * @param scene The scene to load the pipeline to.
  109120. * @param rootUrl The URL of the serialized pipeline.
  109121. * @returns An instantiated pipeline from the serialized object.
  109122. */
  109123. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109124. }
  109125. }
  109126. declare module BABYLON {
  109127. /** @hidden */
  109128. export var ssaoPixelShader: {
  109129. name: string;
  109130. shader: string;
  109131. };
  109132. }
  109133. declare module BABYLON {
  109134. /**
  109135. * Render pipeline to produce ssao effect
  109136. */
  109137. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109138. /**
  109139. * @ignore
  109140. * The PassPostProcess id in the pipeline that contains the original scene color
  109141. */
  109142. SSAOOriginalSceneColorEffect: string;
  109143. /**
  109144. * @ignore
  109145. * The SSAO PostProcess id in the pipeline
  109146. */
  109147. SSAORenderEffect: string;
  109148. /**
  109149. * @ignore
  109150. * The horizontal blur PostProcess id in the pipeline
  109151. */
  109152. SSAOBlurHRenderEffect: string;
  109153. /**
  109154. * @ignore
  109155. * The vertical blur PostProcess id in the pipeline
  109156. */
  109157. SSAOBlurVRenderEffect: string;
  109158. /**
  109159. * @ignore
  109160. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109161. */
  109162. SSAOCombineRenderEffect: string;
  109163. /**
  109164. * The output strength of the SSAO post-process. Default value is 1.0.
  109165. */
  109166. totalStrength: number;
  109167. /**
  109168. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109169. */
  109170. radius: number;
  109171. /**
  109172. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109173. * Must not be equal to fallOff and superior to fallOff.
  109174. * Default value is 0.0075
  109175. */
  109176. area: number;
  109177. /**
  109178. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109179. * Must not be equal to area and inferior to area.
  109180. * Default value is 0.000001
  109181. */
  109182. fallOff: number;
  109183. /**
  109184. * The base color of the SSAO post-process
  109185. * The final result is "base + ssao" between [0, 1]
  109186. */
  109187. base: number;
  109188. private _scene;
  109189. private _depthTexture;
  109190. private _randomTexture;
  109191. private _originalColorPostProcess;
  109192. private _ssaoPostProcess;
  109193. private _blurHPostProcess;
  109194. private _blurVPostProcess;
  109195. private _ssaoCombinePostProcess;
  109196. private _firstUpdate;
  109197. /**
  109198. * Gets active scene
  109199. */
  109200. readonly scene: Scene;
  109201. /**
  109202. * @constructor
  109203. * @param name - The rendering pipeline name
  109204. * @param scene - The scene linked to this pipeline
  109205. * @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 }
  109206. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109207. */
  109208. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109209. /**
  109210. * Get the class name
  109211. * @returns "SSAORenderingPipeline"
  109212. */
  109213. getClassName(): string;
  109214. /**
  109215. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109216. */
  109217. dispose(disableDepthRender?: boolean): void;
  109218. private _createBlurPostProcess;
  109219. /** @hidden */
  109220. _rebuild(): void;
  109221. private _createSSAOPostProcess;
  109222. private _createSSAOCombinePostProcess;
  109223. private _createRandomTexture;
  109224. }
  109225. }
  109226. declare module BABYLON {
  109227. /** @hidden */
  109228. export var standardPixelShader: {
  109229. name: string;
  109230. shader: string;
  109231. };
  109232. }
  109233. declare module BABYLON {
  109234. /**
  109235. * Standard rendering pipeline
  109236. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109237. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109238. */
  109239. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109240. /**
  109241. * Public members
  109242. */
  109243. /**
  109244. * Post-process which contains the original scene color before the pipeline applies all the effects
  109245. */
  109246. originalPostProcess: Nullable<PostProcess>;
  109247. /**
  109248. * Post-process used to down scale an image x4
  109249. */
  109250. downSampleX4PostProcess: Nullable<PostProcess>;
  109251. /**
  109252. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109253. */
  109254. brightPassPostProcess: Nullable<PostProcess>;
  109255. /**
  109256. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109257. */
  109258. blurHPostProcesses: PostProcess[];
  109259. /**
  109260. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109261. */
  109262. blurVPostProcesses: PostProcess[];
  109263. /**
  109264. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109265. */
  109266. textureAdderPostProcess: Nullable<PostProcess>;
  109267. /**
  109268. * Post-process used to create volumetric lighting effect
  109269. */
  109270. volumetricLightPostProcess: Nullable<PostProcess>;
  109271. /**
  109272. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109273. */
  109274. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109275. /**
  109276. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109277. */
  109278. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109279. /**
  109280. * Post-process used to merge the volumetric light effect and the real scene color
  109281. */
  109282. volumetricLightMergePostProces: Nullable<PostProcess>;
  109283. /**
  109284. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109285. */
  109286. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109287. /**
  109288. * Base post-process used to calculate the average luminance of the final image for HDR
  109289. */
  109290. luminancePostProcess: Nullable<PostProcess>;
  109291. /**
  109292. * Post-processes used to create down sample post-processes in order to get
  109293. * the average luminance of the final image for HDR
  109294. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109295. */
  109296. luminanceDownSamplePostProcesses: PostProcess[];
  109297. /**
  109298. * Post-process used to create a HDR effect (light adaptation)
  109299. */
  109300. hdrPostProcess: Nullable<PostProcess>;
  109301. /**
  109302. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109303. */
  109304. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109305. /**
  109306. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109307. */
  109308. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109309. /**
  109310. * Post-process used to merge the final HDR post-process and the real scene color
  109311. */
  109312. hdrFinalPostProcess: Nullable<PostProcess>;
  109313. /**
  109314. * Post-process used to create a lens flare effect
  109315. */
  109316. lensFlarePostProcess: Nullable<PostProcess>;
  109317. /**
  109318. * Post-process that merges the result of the lens flare post-process and the real scene color
  109319. */
  109320. lensFlareComposePostProcess: Nullable<PostProcess>;
  109321. /**
  109322. * Post-process used to create a motion blur effect
  109323. */
  109324. motionBlurPostProcess: Nullable<PostProcess>;
  109325. /**
  109326. * Post-process used to create a depth of field effect
  109327. */
  109328. depthOfFieldPostProcess: Nullable<PostProcess>;
  109329. /**
  109330. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109331. */
  109332. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109333. /**
  109334. * Represents the brightness threshold in order to configure the illuminated surfaces
  109335. */
  109336. brightThreshold: number;
  109337. /**
  109338. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109339. */
  109340. blurWidth: number;
  109341. /**
  109342. * Sets if the blur for highlighted surfaces must be only horizontal
  109343. */
  109344. horizontalBlur: boolean;
  109345. /**
  109346. * Sets the overall exposure used by the pipeline
  109347. */
  109348. exposure: number;
  109349. /**
  109350. * Texture used typically to simulate "dirty" on camera lens
  109351. */
  109352. lensTexture: Nullable<Texture>;
  109353. /**
  109354. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109355. */
  109356. volumetricLightCoefficient: number;
  109357. /**
  109358. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109359. */
  109360. volumetricLightPower: number;
  109361. /**
  109362. * Used the set the blur intensity to smooth the volumetric lights
  109363. */
  109364. volumetricLightBlurScale: number;
  109365. /**
  109366. * Light (spot or directional) used to generate the volumetric lights rays
  109367. * The source light must have a shadow generate so the pipeline can get its
  109368. * depth map
  109369. */
  109370. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109371. /**
  109372. * For eye adaptation, represents the minimum luminance the eye can see
  109373. */
  109374. hdrMinimumLuminance: number;
  109375. /**
  109376. * For eye adaptation, represents the decrease luminance speed
  109377. */
  109378. hdrDecreaseRate: number;
  109379. /**
  109380. * For eye adaptation, represents the increase luminance speed
  109381. */
  109382. hdrIncreaseRate: number;
  109383. /**
  109384. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109385. */
  109386. lensColorTexture: Nullable<Texture>;
  109387. /**
  109388. * The overall strengh for the lens flare effect
  109389. */
  109390. lensFlareStrength: number;
  109391. /**
  109392. * Dispersion coefficient for lens flare ghosts
  109393. */
  109394. lensFlareGhostDispersal: number;
  109395. /**
  109396. * Main lens flare halo width
  109397. */
  109398. lensFlareHaloWidth: number;
  109399. /**
  109400. * Based on the lens distortion effect, defines how much the lens flare result
  109401. * is distorted
  109402. */
  109403. lensFlareDistortionStrength: number;
  109404. /**
  109405. * Lens star texture must be used to simulate rays on the flares and is available
  109406. * in the documentation
  109407. */
  109408. lensStarTexture: Nullable<Texture>;
  109409. /**
  109410. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109411. * flare effect by taking account of the dirt texture
  109412. */
  109413. lensFlareDirtTexture: Nullable<Texture>;
  109414. /**
  109415. * Represents the focal length for the depth of field effect
  109416. */
  109417. depthOfFieldDistance: number;
  109418. /**
  109419. * Represents the blur intensity for the blurred part of the depth of field effect
  109420. */
  109421. depthOfFieldBlurWidth: number;
  109422. /**
  109423. * For motion blur, defines how much the image is blurred by the movement
  109424. */
  109425. motionStrength: number;
  109426. /**
  109427. * List of animations for the pipeline (IAnimatable implementation)
  109428. */
  109429. animations: Animation[];
  109430. /**
  109431. * Private members
  109432. */
  109433. private _scene;
  109434. private _currentDepthOfFieldSource;
  109435. private _basePostProcess;
  109436. private _hdrCurrentLuminance;
  109437. private _floatTextureType;
  109438. private _ratio;
  109439. private _bloomEnabled;
  109440. private _depthOfFieldEnabled;
  109441. private _vlsEnabled;
  109442. private _lensFlareEnabled;
  109443. private _hdrEnabled;
  109444. private _motionBlurEnabled;
  109445. private _fxaaEnabled;
  109446. private _motionBlurSamples;
  109447. private _volumetricLightStepsCount;
  109448. private _samples;
  109449. /**
  109450. * @ignore
  109451. * Specifies if the bloom pipeline is enabled
  109452. */
  109453. BloomEnabled: boolean;
  109454. /**
  109455. * @ignore
  109456. * Specifies if the depth of field pipeline is enabed
  109457. */
  109458. DepthOfFieldEnabled: boolean;
  109459. /**
  109460. * @ignore
  109461. * Specifies if the lens flare pipeline is enabed
  109462. */
  109463. LensFlareEnabled: boolean;
  109464. /**
  109465. * @ignore
  109466. * Specifies if the HDR pipeline is enabled
  109467. */
  109468. HDREnabled: boolean;
  109469. /**
  109470. * @ignore
  109471. * Specifies if the volumetric lights scattering effect is enabled
  109472. */
  109473. VLSEnabled: boolean;
  109474. /**
  109475. * @ignore
  109476. * Specifies if the motion blur effect is enabled
  109477. */
  109478. MotionBlurEnabled: boolean;
  109479. /**
  109480. * Specifies if anti-aliasing is enabled
  109481. */
  109482. fxaaEnabled: boolean;
  109483. /**
  109484. * Specifies the number of steps used to calculate the volumetric lights
  109485. * Typically in interval [50, 200]
  109486. */
  109487. volumetricLightStepsCount: number;
  109488. /**
  109489. * Specifies the number of samples used for the motion blur effect
  109490. * Typically in interval [16, 64]
  109491. */
  109492. motionBlurSamples: number;
  109493. /**
  109494. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109495. */
  109496. samples: number;
  109497. /**
  109498. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109499. * @constructor
  109500. * @param name The rendering pipeline name
  109501. * @param scene The scene linked to this pipeline
  109502. * @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)
  109503. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  109504. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109505. */
  109506. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  109507. private _buildPipeline;
  109508. private _createDownSampleX4PostProcess;
  109509. private _createBrightPassPostProcess;
  109510. private _createBlurPostProcesses;
  109511. private _createTextureAdderPostProcess;
  109512. private _createVolumetricLightPostProcess;
  109513. private _createLuminancePostProcesses;
  109514. private _createHdrPostProcess;
  109515. private _createLensFlarePostProcess;
  109516. private _createDepthOfFieldPostProcess;
  109517. private _createMotionBlurPostProcess;
  109518. private _getDepthTexture;
  109519. private _disposePostProcesses;
  109520. /**
  109521. * Dispose of the pipeline and stop all post processes
  109522. */
  109523. dispose(): void;
  109524. /**
  109525. * Serialize the rendering pipeline (Used when exporting)
  109526. * @returns the serialized object
  109527. */
  109528. serialize(): any;
  109529. /**
  109530. * Parse the serialized pipeline
  109531. * @param source Source pipeline.
  109532. * @param scene The scene to load the pipeline to.
  109533. * @param rootUrl The URL of the serialized pipeline.
  109534. * @returns An instantiated pipeline from the serialized object.
  109535. */
  109536. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  109537. /**
  109538. * Luminance steps
  109539. */
  109540. static LuminanceSteps: number;
  109541. }
  109542. }
  109543. declare module BABYLON {
  109544. /**
  109545. * PostProcessRenderPipelineManager class
  109546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109547. */
  109548. export class PostProcessRenderPipelineManager {
  109549. private _renderPipelines;
  109550. /**
  109551. * Initializes a PostProcessRenderPipelineManager
  109552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109553. */
  109554. constructor();
  109555. /**
  109556. * Gets the list of supported render pipelines
  109557. */
  109558. readonly supportedPipelines: PostProcessRenderPipeline[];
  109559. /**
  109560. * Adds a pipeline to the manager
  109561. * @param renderPipeline The pipeline to add
  109562. */
  109563. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109564. /**
  109565. * Attaches a camera to the pipeline
  109566. * @param renderPipelineName The name of the pipeline to attach to
  109567. * @param cameras the camera to attach
  109568. * @param unique if the camera can be attached multiple times to the pipeline
  109569. */
  109570. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109571. /**
  109572. * Detaches a camera from the pipeline
  109573. * @param renderPipelineName The name of the pipeline to detach from
  109574. * @param cameras the camera to detach
  109575. */
  109576. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109577. /**
  109578. * Enables an effect by name on a pipeline
  109579. * @param renderPipelineName the name of the pipeline to enable the effect in
  109580. * @param renderEffectName the name of the effect to enable
  109581. * @param cameras the cameras that the effect should be enabled on
  109582. */
  109583. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109584. /**
  109585. * Disables an effect by name on a pipeline
  109586. * @param renderPipelineName the name of the pipeline to disable the effect in
  109587. * @param renderEffectName the name of the effect to disable
  109588. * @param cameras the cameras that the effect should be disabled on
  109589. */
  109590. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109591. /**
  109592. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109593. */
  109594. update(): void;
  109595. /** @hidden */
  109596. _rebuild(): void;
  109597. /**
  109598. * Disposes of the manager and pipelines
  109599. */
  109600. dispose(): void;
  109601. }
  109602. }
  109603. declare module BABYLON {
  109604. interface Scene {
  109605. /** @hidden (Backing field) */
  109606. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109607. /**
  109608. * Gets the postprocess render pipeline manager
  109609. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109610. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109611. */
  109612. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109613. }
  109614. /**
  109615. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109616. */
  109617. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109618. /**
  109619. * The component name helpfull to identify the component in the list of scene components.
  109620. */
  109621. readonly name: string;
  109622. /**
  109623. * The scene the component belongs to.
  109624. */
  109625. scene: Scene;
  109626. /**
  109627. * Creates a new instance of the component for the given scene
  109628. * @param scene Defines the scene to register the component in
  109629. */
  109630. constructor(scene: Scene);
  109631. /**
  109632. * Registers the component in a given scene
  109633. */
  109634. register(): void;
  109635. /**
  109636. * Rebuilds the elements related to this component in case of
  109637. * context lost for instance.
  109638. */
  109639. rebuild(): void;
  109640. /**
  109641. * Disposes the component and the associated ressources
  109642. */
  109643. dispose(): void;
  109644. private _gatherRenderTargets;
  109645. }
  109646. }
  109647. declare module BABYLON {
  109648. /** @hidden */
  109649. export var tonemapPixelShader: {
  109650. name: string;
  109651. shader: string;
  109652. };
  109653. }
  109654. declare module BABYLON {
  109655. /** Defines operator used for tonemapping */
  109656. export enum TonemappingOperator {
  109657. /** Hable */
  109658. Hable = 0,
  109659. /** Reinhard */
  109660. Reinhard = 1,
  109661. /** HejiDawson */
  109662. HejiDawson = 2,
  109663. /** Photographic */
  109664. Photographic = 3
  109665. }
  109666. /**
  109667. * Defines a post process to apply tone mapping
  109668. */
  109669. export class TonemapPostProcess extends PostProcess {
  109670. private _operator;
  109671. /** Defines the required exposure adjustement */
  109672. exposureAdjustment: number;
  109673. /**
  109674. * Creates a new TonemapPostProcess
  109675. * @param name defines the name of the postprocess
  109676. * @param _operator defines the operator to use
  109677. * @param exposureAdjustment defines the required exposure adjustement
  109678. * @param camera defines the camera to use (can be null)
  109679. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  109680. * @param engine defines the hosting engine (can be ignore if camera is set)
  109681. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109682. */
  109683. constructor(name: string, _operator: TonemappingOperator,
  109684. /** Defines the required exposure adjustement */
  109685. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  109686. }
  109687. }
  109688. declare module BABYLON {
  109689. /** @hidden */
  109690. export var depthVertexShader: {
  109691. name: string;
  109692. shader: string;
  109693. };
  109694. }
  109695. declare module BABYLON {
  109696. /** @hidden */
  109697. export var volumetricLightScatteringPixelShader: {
  109698. name: string;
  109699. shader: string;
  109700. };
  109701. }
  109702. declare module BABYLON {
  109703. /** @hidden */
  109704. export var volumetricLightScatteringPassPixelShader: {
  109705. name: string;
  109706. shader: string;
  109707. };
  109708. }
  109709. declare module BABYLON {
  109710. /**
  109711. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  109712. */
  109713. export class VolumetricLightScatteringPostProcess extends PostProcess {
  109714. private _volumetricLightScatteringPass;
  109715. private _volumetricLightScatteringRTT;
  109716. private _viewPort;
  109717. private _screenCoordinates;
  109718. private _cachedDefines;
  109719. /**
  109720. * If not undefined, the mesh position is computed from the attached node position
  109721. */
  109722. attachedNode: {
  109723. position: Vector3;
  109724. };
  109725. /**
  109726. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  109727. */
  109728. customMeshPosition: Vector3;
  109729. /**
  109730. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  109731. */
  109732. useCustomMeshPosition: boolean;
  109733. /**
  109734. * If the post-process should inverse the light scattering direction
  109735. */
  109736. invert: boolean;
  109737. /**
  109738. * The internal mesh used by the post-process
  109739. */
  109740. mesh: Mesh;
  109741. /**
  109742. * @hidden
  109743. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  109744. */
  109745. useDiffuseColor: boolean;
  109746. /**
  109747. * Array containing the excluded meshes not rendered in the internal pass
  109748. */
  109749. excludedMeshes: AbstractMesh[];
  109750. /**
  109751. * Controls the overall intensity of the post-process
  109752. */
  109753. exposure: number;
  109754. /**
  109755. * Dissipates each sample's contribution in range [0, 1]
  109756. */
  109757. decay: number;
  109758. /**
  109759. * Controls the overall intensity of each sample
  109760. */
  109761. weight: number;
  109762. /**
  109763. * Controls the density of each sample
  109764. */
  109765. density: number;
  109766. /**
  109767. * @constructor
  109768. * @param name The post-process name
  109769. * @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)
  109770. * @param camera The camera that the post-process will be attached to
  109771. * @param mesh The mesh used to create the light scattering
  109772. * @param samples The post-process quality, default 100
  109773. * @param samplingModeThe post-process filtering mode
  109774. * @param engine The babylon engine
  109775. * @param reusable If the post-process is reusable
  109776. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  109777. */
  109778. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  109779. /**
  109780. * Returns the string "VolumetricLightScatteringPostProcess"
  109781. * @returns "VolumetricLightScatteringPostProcess"
  109782. */
  109783. getClassName(): string;
  109784. private _isReady;
  109785. /**
  109786. * Sets the new light position for light scattering effect
  109787. * @param position The new custom light position
  109788. */
  109789. setCustomMeshPosition(position: Vector3): void;
  109790. /**
  109791. * Returns the light position for light scattering effect
  109792. * @return Vector3 The custom light position
  109793. */
  109794. getCustomMeshPosition(): Vector3;
  109795. /**
  109796. * Disposes the internal assets and detaches the post-process from the camera
  109797. */
  109798. dispose(camera: Camera): void;
  109799. /**
  109800. * Returns the render target texture used by the post-process
  109801. * @return the render target texture used by the post-process
  109802. */
  109803. getPass(): RenderTargetTexture;
  109804. private _meshExcluded;
  109805. private _createPass;
  109806. private _updateMeshScreenCoordinates;
  109807. /**
  109808. * Creates a default mesh for the Volumeric Light Scattering post-process
  109809. * @param name The mesh name
  109810. * @param scene The scene where to create the mesh
  109811. * @return the default mesh
  109812. */
  109813. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  109814. }
  109815. }
  109816. declare module BABYLON {
  109817. interface Scene {
  109818. /** @hidden (Backing field) */
  109819. _boundingBoxRenderer: BoundingBoxRenderer;
  109820. /** @hidden (Backing field) */
  109821. _forceShowBoundingBoxes: boolean;
  109822. /**
  109823. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  109824. */
  109825. forceShowBoundingBoxes: boolean;
  109826. /**
  109827. * Gets the bounding box renderer associated with the scene
  109828. * @returns a BoundingBoxRenderer
  109829. */
  109830. getBoundingBoxRenderer(): BoundingBoxRenderer;
  109831. }
  109832. interface AbstractMesh {
  109833. /** @hidden (Backing field) */
  109834. _showBoundingBox: boolean;
  109835. /**
  109836. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  109837. */
  109838. showBoundingBox: boolean;
  109839. }
  109840. /**
  109841. * Component responsible of rendering the bounding box of the meshes in a scene.
  109842. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  109843. */
  109844. export class BoundingBoxRenderer implements ISceneComponent {
  109845. /**
  109846. * The component name helpfull to identify the component in the list of scene components.
  109847. */
  109848. readonly name: string;
  109849. /**
  109850. * The scene the component belongs to.
  109851. */
  109852. scene: Scene;
  109853. /**
  109854. * Color of the bounding box lines placed in front of an object
  109855. */
  109856. frontColor: Color3;
  109857. /**
  109858. * Color of the bounding box lines placed behind an object
  109859. */
  109860. backColor: Color3;
  109861. /**
  109862. * Defines if the renderer should show the back lines or not
  109863. */
  109864. showBackLines: boolean;
  109865. /**
  109866. * @hidden
  109867. */
  109868. renderList: SmartArray<BoundingBox>;
  109869. private _colorShader;
  109870. private _vertexBuffers;
  109871. private _indexBuffer;
  109872. /**
  109873. * Instantiates a new bounding box renderer in a scene.
  109874. * @param scene the scene the renderer renders in
  109875. */
  109876. constructor(scene: Scene);
  109877. /**
  109878. * Registers the component in a given scene
  109879. */
  109880. register(): void;
  109881. private _evaluateSubMesh;
  109882. private _activeMesh;
  109883. private _prepareRessources;
  109884. private _createIndexBuffer;
  109885. /**
  109886. * Rebuilds the elements related to this component in case of
  109887. * context lost for instance.
  109888. */
  109889. rebuild(): void;
  109890. /**
  109891. * @hidden
  109892. */
  109893. reset(): void;
  109894. /**
  109895. * Render the bounding boxes of a specific rendering group
  109896. * @param renderingGroupId defines the rendering group to render
  109897. */
  109898. render(renderingGroupId: number): void;
  109899. /**
  109900. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109901. * @param mesh Define the mesh to render the occlusion bounding box for
  109902. */
  109903. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109904. /**
  109905. * Dispose and release the resources attached to this renderer.
  109906. */
  109907. dispose(): void;
  109908. }
  109909. }
  109910. declare module BABYLON {
  109911. /** @hidden */
  109912. export var depthPixelShader: {
  109913. name: string;
  109914. shader: string;
  109915. };
  109916. }
  109917. declare module BABYLON {
  109918. /**
  109919. * This represents a depth renderer in Babylon.
  109920. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109921. */
  109922. export class DepthRenderer {
  109923. private _scene;
  109924. private _depthMap;
  109925. private _effect;
  109926. private _cachedDefines;
  109927. private _camera;
  109928. /**
  109929. * Specifiess that the depth renderer will only be used within
  109930. * the camera it is created for.
  109931. * This can help forcing its rendering during the camera processing.
  109932. */
  109933. useOnlyInActiveCamera: boolean;
  109934. /** @hidden */
  109935. static _SceneComponentInitialization: (scene: Scene) => void;
  109936. /**
  109937. * Instantiates a depth renderer
  109938. * @param scene The scene the renderer belongs to
  109939. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  109940. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  109941. */
  109942. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  109943. /**
  109944. * Creates the depth rendering effect and checks if the effect is ready.
  109945. * @param subMesh The submesh to be used to render the depth map of
  109946. * @param useInstances If multiple world instances should be used
  109947. * @returns if the depth renderer is ready to render the depth map
  109948. */
  109949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109950. /**
  109951. * Gets the texture which the depth map will be written to.
  109952. * @returns The depth map texture
  109953. */
  109954. getDepthMap(): RenderTargetTexture;
  109955. /**
  109956. * Disposes of the depth renderer.
  109957. */
  109958. dispose(): void;
  109959. }
  109960. }
  109961. declare module BABYLON {
  109962. interface Scene {
  109963. /** @hidden (Backing field) */
  109964. _depthRenderer: {
  109965. [id: string]: DepthRenderer;
  109966. };
  109967. /**
  109968. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109969. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109970. * @returns the created depth renderer
  109971. */
  109972. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109973. /**
  109974. * Disables a depth renderer for a given camera
  109975. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109976. */
  109977. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109978. }
  109979. /**
  109980. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109981. * in several rendering techniques.
  109982. */
  109983. export class DepthRendererSceneComponent implements ISceneComponent {
  109984. /**
  109985. * The component name helpfull to identify the component in the list of scene components.
  109986. */
  109987. readonly name: string;
  109988. /**
  109989. * The scene the component belongs to.
  109990. */
  109991. scene: Scene;
  109992. /**
  109993. * Creates a new instance of the component for the given scene
  109994. * @param scene Defines the scene to register the component in
  109995. */
  109996. constructor(scene: Scene);
  109997. /**
  109998. * Registers the component in a given scene
  109999. */
  110000. register(): void;
  110001. /**
  110002. * Rebuilds the elements related to this component in case of
  110003. * context lost for instance.
  110004. */
  110005. rebuild(): void;
  110006. /**
  110007. * Disposes the component and the associated ressources
  110008. */
  110009. dispose(): void;
  110010. private _gatherRenderTargets;
  110011. private _gatherActiveCameraRenderTargets;
  110012. }
  110013. }
  110014. declare module BABYLON {
  110015. interface Scene {
  110016. /** @hidden (Backing field) */
  110017. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110018. /**
  110019. * Gets or Sets the current geometry buffer associated to the scene.
  110020. */
  110021. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110022. /**
  110023. * Enables a GeometryBufferRender and associates it with the scene
  110024. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110025. * @returns the GeometryBufferRenderer
  110026. */
  110027. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110028. /**
  110029. * Disables the GeometryBufferRender associated with the scene
  110030. */
  110031. disableGeometryBufferRenderer(): void;
  110032. }
  110033. /**
  110034. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110035. * in several rendering techniques.
  110036. */
  110037. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110038. /**
  110039. * The component name helpful to identify the component in the list of scene components.
  110040. */
  110041. readonly name: string;
  110042. /**
  110043. * The scene the component belongs to.
  110044. */
  110045. scene: Scene;
  110046. /**
  110047. * Creates a new instance of the component for the given scene
  110048. * @param scene Defines the scene to register the component in
  110049. */
  110050. constructor(scene: Scene);
  110051. /**
  110052. * Registers the component in a given scene
  110053. */
  110054. register(): void;
  110055. /**
  110056. * Rebuilds the elements related to this component in case of
  110057. * context lost for instance.
  110058. */
  110059. rebuild(): void;
  110060. /**
  110061. * Disposes the component and the associated ressources
  110062. */
  110063. dispose(): void;
  110064. private _gatherRenderTargets;
  110065. }
  110066. }
  110067. declare module BABYLON {
  110068. /** @hidden */
  110069. export var outlinePixelShader: {
  110070. name: string;
  110071. shader: string;
  110072. };
  110073. }
  110074. declare module BABYLON {
  110075. /** @hidden */
  110076. export var outlineVertexShader: {
  110077. name: string;
  110078. shader: string;
  110079. };
  110080. }
  110081. declare module BABYLON {
  110082. interface Scene {
  110083. /** @hidden */
  110084. _outlineRenderer: OutlineRenderer;
  110085. /**
  110086. * Gets the outline renderer associated with the scene
  110087. * @returns a OutlineRenderer
  110088. */
  110089. getOutlineRenderer(): OutlineRenderer;
  110090. }
  110091. interface AbstractMesh {
  110092. /** @hidden (Backing field) */
  110093. _renderOutline: boolean;
  110094. /**
  110095. * Gets or sets a boolean indicating if the outline must be rendered as well
  110096. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110097. */
  110098. renderOutline: boolean;
  110099. /** @hidden (Backing field) */
  110100. _renderOverlay: boolean;
  110101. /**
  110102. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110103. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110104. */
  110105. renderOverlay: boolean;
  110106. }
  110107. /**
  110108. * This class is responsible to draw bothe outline/overlay of meshes.
  110109. * It should not be used directly but through the available method on mesh.
  110110. */
  110111. export class OutlineRenderer implements ISceneComponent {
  110112. /**
  110113. * The name of the component. Each component must have a unique name.
  110114. */
  110115. name: string;
  110116. /**
  110117. * The scene the component belongs to.
  110118. */
  110119. scene: Scene;
  110120. /**
  110121. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110122. */
  110123. zOffset: number;
  110124. private _engine;
  110125. private _effect;
  110126. private _cachedDefines;
  110127. private _savedDepthWrite;
  110128. /**
  110129. * Instantiates a new outline renderer. (There could be only one per scene).
  110130. * @param scene Defines the scene it belongs to
  110131. */
  110132. constructor(scene: Scene);
  110133. /**
  110134. * Register the component to one instance of a scene.
  110135. */
  110136. register(): void;
  110137. /**
  110138. * Rebuilds the elements related to this component in case of
  110139. * context lost for instance.
  110140. */
  110141. rebuild(): void;
  110142. /**
  110143. * Disposes the component and the associated ressources.
  110144. */
  110145. dispose(): void;
  110146. /**
  110147. * Renders the outline in the canvas.
  110148. * @param subMesh Defines the sumesh to render
  110149. * @param batch Defines the batch of meshes in case of instances
  110150. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110151. */
  110152. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110153. /**
  110154. * Returns whether or not the outline renderer is ready for a given submesh.
  110155. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110156. * @param subMesh Defines the submesh to check readyness for
  110157. * @param useInstances Defines wheter wee are trying to render instances or not
  110158. * @returns true if ready otherwise false
  110159. */
  110160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110161. private _beforeRenderingMesh;
  110162. private _afterRenderingMesh;
  110163. }
  110164. }
  110165. declare module BABYLON {
  110166. /**
  110167. * Defines the list of states available for a task inside a AssetsManager
  110168. */
  110169. export enum AssetTaskState {
  110170. /**
  110171. * Initialization
  110172. */
  110173. INIT = 0,
  110174. /**
  110175. * Running
  110176. */
  110177. RUNNING = 1,
  110178. /**
  110179. * Done
  110180. */
  110181. DONE = 2,
  110182. /**
  110183. * Error
  110184. */
  110185. ERROR = 3
  110186. }
  110187. /**
  110188. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110189. */
  110190. export abstract class AbstractAssetTask {
  110191. /**
  110192. * Task name
  110193. */ name: string;
  110194. /**
  110195. * Callback called when the task is successful
  110196. */
  110197. onSuccess: (task: any) => void;
  110198. /**
  110199. * Callback called when the task is not successful
  110200. */
  110201. onError: (task: any, message?: string, exception?: any) => void;
  110202. /**
  110203. * Creates a new AssetsManager
  110204. * @param name defines the name of the task
  110205. */
  110206. constructor(
  110207. /**
  110208. * Task name
  110209. */ name: string);
  110210. private _isCompleted;
  110211. private _taskState;
  110212. private _errorObject;
  110213. /**
  110214. * Get if the task is completed
  110215. */
  110216. readonly isCompleted: boolean;
  110217. /**
  110218. * Gets the current state of the task
  110219. */
  110220. readonly taskState: AssetTaskState;
  110221. /**
  110222. * Gets the current error object (if task is in error)
  110223. */
  110224. readonly errorObject: {
  110225. message?: string;
  110226. exception?: any;
  110227. };
  110228. /**
  110229. * Internal only
  110230. * @hidden
  110231. */
  110232. _setErrorObject(message?: string, exception?: any): void;
  110233. /**
  110234. * Execute the current task
  110235. * @param scene defines the scene where you want your assets to be loaded
  110236. * @param onSuccess is a callback called when the task is successfully executed
  110237. * @param onError is a callback called if an error occurs
  110238. */
  110239. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110240. /**
  110241. * Execute the current task
  110242. * @param scene defines the scene where you want your assets to be loaded
  110243. * @param onSuccess is a callback called when the task is successfully executed
  110244. * @param onError is a callback called if an error occurs
  110245. */
  110246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110247. /**
  110248. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110249. * This can be used with failed tasks that have the reason for failure fixed.
  110250. */
  110251. reset(): void;
  110252. private onErrorCallback;
  110253. private onDoneCallback;
  110254. }
  110255. /**
  110256. * Define the interface used by progress events raised during assets loading
  110257. */
  110258. export interface IAssetsProgressEvent {
  110259. /**
  110260. * Defines the number of remaining tasks to process
  110261. */
  110262. remainingCount: number;
  110263. /**
  110264. * Defines the total number of tasks
  110265. */
  110266. totalCount: number;
  110267. /**
  110268. * Defines the task that was just processed
  110269. */
  110270. task: AbstractAssetTask;
  110271. }
  110272. /**
  110273. * Class used to share progress information about assets loading
  110274. */
  110275. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110276. /**
  110277. * Defines the number of remaining tasks to process
  110278. */
  110279. remainingCount: number;
  110280. /**
  110281. * Defines the total number of tasks
  110282. */
  110283. totalCount: number;
  110284. /**
  110285. * Defines the task that was just processed
  110286. */
  110287. task: AbstractAssetTask;
  110288. /**
  110289. * Creates a AssetsProgressEvent
  110290. * @param remainingCount defines the number of remaining tasks to process
  110291. * @param totalCount defines the total number of tasks
  110292. * @param task defines the task that was just processed
  110293. */
  110294. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110295. }
  110296. /**
  110297. * Define a task used by AssetsManager to load meshes
  110298. */
  110299. export class MeshAssetTask extends AbstractAssetTask {
  110300. /**
  110301. * Defines the name of the task
  110302. */
  110303. name: string;
  110304. /**
  110305. * Defines the list of mesh's names you want to load
  110306. */
  110307. meshesNames: any;
  110308. /**
  110309. * Defines the root url to use as a base to load your meshes and associated resources
  110310. */
  110311. rootUrl: string;
  110312. /**
  110313. * Defines the filename of the scene to load from
  110314. */
  110315. sceneFilename: string;
  110316. /**
  110317. * Gets the list of loaded meshes
  110318. */
  110319. loadedMeshes: Array<AbstractMesh>;
  110320. /**
  110321. * Gets the list of loaded particle systems
  110322. */
  110323. loadedParticleSystems: Array<IParticleSystem>;
  110324. /**
  110325. * Gets the list of loaded skeletons
  110326. */
  110327. loadedSkeletons: Array<Skeleton>;
  110328. /**
  110329. * Gets the list of loaded animation groups
  110330. */
  110331. loadedAnimationGroups: Array<AnimationGroup>;
  110332. /**
  110333. * Callback called when the task is successful
  110334. */
  110335. onSuccess: (task: MeshAssetTask) => void;
  110336. /**
  110337. * Callback called when the task is successful
  110338. */
  110339. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110340. /**
  110341. * Creates a new MeshAssetTask
  110342. * @param name defines the name of the task
  110343. * @param meshesNames defines the list of mesh's names you want to load
  110344. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110345. * @param sceneFilename defines the filename of the scene to load from
  110346. */
  110347. constructor(
  110348. /**
  110349. * Defines the name of the task
  110350. */
  110351. name: string,
  110352. /**
  110353. * Defines the list of mesh's names you want to load
  110354. */
  110355. meshesNames: any,
  110356. /**
  110357. * Defines the root url to use as a base to load your meshes and associated resources
  110358. */
  110359. rootUrl: string,
  110360. /**
  110361. * Defines the filename of the scene to load from
  110362. */
  110363. sceneFilename: string);
  110364. /**
  110365. * Execute the current task
  110366. * @param scene defines the scene where you want your assets to be loaded
  110367. * @param onSuccess is a callback called when the task is successfully executed
  110368. * @param onError is a callback called if an error occurs
  110369. */
  110370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110371. }
  110372. /**
  110373. * Define a task used by AssetsManager to load text content
  110374. */
  110375. export class TextFileAssetTask extends AbstractAssetTask {
  110376. /**
  110377. * Defines the name of the task
  110378. */
  110379. name: string;
  110380. /**
  110381. * Defines the location of the file to load
  110382. */
  110383. url: string;
  110384. /**
  110385. * Gets the loaded text string
  110386. */
  110387. text: string;
  110388. /**
  110389. * Callback called when the task is successful
  110390. */
  110391. onSuccess: (task: TextFileAssetTask) => void;
  110392. /**
  110393. * Callback called when the task is successful
  110394. */
  110395. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110396. /**
  110397. * Creates a new TextFileAssetTask object
  110398. * @param name defines the name of the task
  110399. * @param url defines the location of the file to load
  110400. */
  110401. constructor(
  110402. /**
  110403. * Defines the name of the task
  110404. */
  110405. name: string,
  110406. /**
  110407. * Defines the location of the file to load
  110408. */
  110409. url: string);
  110410. /**
  110411. * Execute the current task
  110412. * @param scene defines the scene where you want your assets to be loaded
  110413. * @param onSuccess is a callback called when the task is successfully executed
  110414. * @param onError is a callback called if an error occurs
  110415. */
  110416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110417. }
  110418. /**
  110419. * Define a task used by AssetsManager to load binary data
  110420. */
  110421. export class BinaryFileAssetTask extends AbstractAssetTask {
  110422. /**
  110423. * Defines the name of the task
  110424. */
  110425. name: string;
  110426. /**
  110427. * Defines the location of the file to load
  110428. */
  110429. url: string;
  110430. /**
  110431. * Gets the lodaded data (as an array buffer)
  110432. */
  110433. data: ArrayBuffer;
  110434. /**
  110435. * Callback called when the task is successful
  110436. */
  110437. onSuccess: (task: BinaryFileAssetTask) => void;
  110438. /**
  110439. * Callback called when the task is successful
  110440. */
  110441. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110442. /**
  110443. * Creates a new BinaryFileAssetTask object
  110444. * @param name defines the name of the new task
  110445. * @param url defines the location of the file to load
  110446. */
  110447. constructor(
  110448. /**
  110449. * Defines the name of the task
  110450. */
  110451. name: string,
  110452. /**
  110453. * Defines the location of the file to load
  110454. */
  110455. url: string);
  110456. /**
  110457. * Execute the current task
  110458. * @param scene defines the scene where you want your assets to be loaded
  110459. * @param onSuccess is a callback called when the task is successfully executed
  110460. * @param onError is a callback called if an error occurs
  110461. */
  110462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110463. }
  110464. /**
  110465. * Define a task used by AssetsManager to load images
  110466. */
  110467. export class ImageAssetTask extends AbstractAssetTask {
  110468. /**
  110469. * Defines the name of the task
  110470. */
  110471. name: string;
  110472. /**
  110473. * Defines the location of the image to load
  110474. */
  110475. url: string;
  110476. /**
  110477. * Gets the loaded images
  110478. */
  110479. image: HTMLImageElement;
  110480. /**
  110481. * Callback called when the task is successful
  110482. */
  110483. onSuccess: (task: ImageAssetTask) => void;
  110484. /**
  110485. * Callback called when the task is successful
  110486. */
  110487. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110488. /**
  110489. * Creates a new ImageAssetTask
  110490. * @param name defines the name of the task
  110491. * @param url defines the location of the image to load
  110492. */
  110493. constructor(
  110494. /**
  110495. * Defines the name of the task
  110496. */
  110497. name: string,
  110498. /**
  110499. * Defines the location of the image to load
  110500. */
  110501. url: string);
  110502. /**
  110503. * Execute the current task
  110504. * @param scene defines the scene where you want your assets to be loaded
  110505. * @param onSuccess is a callback called when the task is successfully executed
  110506. * @param onError is a callback called if an error occurs
  110507. */
  110508. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110509. }
  110510. /**
  110511. * Defines the interface used by texture loading tasks
  110512. */
  110513. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110514. /**
  110515. * Gets the loaded texture
  110516. */
  110517. texture: TEX;
  110518. }
  110519. /**
  110520. * Define a task used by AssetsManager to load 2D textures
  110521. */
  110522. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110523. /**
  110524. * Defines the name of the task
  110525. */
  110526. name: string;
  110527. /**
  110528. * Defines the location of the file to load
  110529. */
  110530. url: string;
  110531. /**
  110532. * Defines if mipmap should not be generated (default is false)
  110533. */
  110534. noMipmap?: boolean | undefined;
  110535. /**
  110536. * Defines if texture must be inverted on Y axis (default is false)
  110537. */
  110538. invertY?: boolean | undefined;
  110539. /**
  110540. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110541. */
  110542. samplingMode: number;
  110543. /**
  110544. * Gets the loaded texture
  110545. */
  110546. texture: Texture;
  110547. /**
  110548. * Callback called when the task is successful
  110549. */
  110550. onSuccess: (task: TextureAssetTask) => void;
  110551. /**
  110552. * Callback called when the task is successful
  110553. */
  110554. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110555. /**
  110556. * Creates a new TextureAssetTask object
  110557. * @param name defines the name of the task
  110558. * @param url defines the location of the file to load
  110559. * @param noMipmap defines if mipmap should not be generated (default is false)
  110560. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110561. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110562. */
  110563. constructor(
  110564. /**
  110565. * Defines the name of the task
  110566. */
  110567. name: string,
  110568. /**
  110569. * Defines the location of the file to load
  110570. */
  110571. url: string,
  110572. /**
  110573. * Defines if mipmap should not be generated (default is false)
  110574. */
  110575. noMipmap?: boolean | undefined,
  110576. /**
  110577. * Defines if texture must be inverted on Y axis (default is false)
  110578. */
  110579. invertY?: boolean | undefined,
  110580. /**
  110581. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110582. */
  110583. samplingMode?: number);
  110584. /**
  110585. * Execute the current task
  110586. * @param scene defines the scene where you want your assets to be loaded
  110587. * @param onSuccess is a callback called when the task is successfully executed
  110588. * @param onError is a callback called if an error occurs
  110589. */
  110590. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110591. }
  110592. /**
  110593. * Define a task used by AssetsManager to load cube textures
  110594. */
  110595. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  110596. /**
  110597. * Defines the name of the task
  110598. */
  110599. name: string;
  110600. /**
  110601. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110602. */
  110603. url: string;
  110604. /**
  110605. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110606. */
  110607. extensions?: string[] | undefined;
  110608. /**
  110609. * Defines if mipmaps should not be generated (default is false)
  110610. */
  110611. noMipmap?: boolean | undefined;
  110612. /**
  110613. * Defines the explicit list of files (undefined by default)
  110614. */
  110615. files?: string[] | undefined;
  110616. /**
  110617. * Gets the loaded texture
  110618. */
  110619. texture: CubeTexture;
  110620. /**
  110621. * Callback called when the task is successful
  110622. */
  110623. onSuccess: (task: CubeTextureAssetTask) => void;
  110624. /**
  110625. * Callback called when the task is successful
  110626. */
  110627. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  110628. /**
  110629. * Creates a new CubeTextureAssetTask
  110630. * @param name defines the name of the task
  110631. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110632. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110633. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110634. * @param files defines the explicit list of files (undefined by default)
  110635. */
  110636. constructor(
  110637. /**
  110638. * Defines the name of the task
  110639. */
  110640. name: string,
  110641. /**
  110642. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110643. */
  110644. url: string,
  110645. /**
  110646. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110647. */
  110648. extensions?: string[] | undefined,
  110649. /**
  110650. * Defines if mipmaps should not be generated (default is false)
  110651. */
  110652. noMipmap?: boolean | undefined,
  110653. /**
  110654. * Defines the explicit list of files (undefined by default)
  110655. */
  110656. files?: string[] | undefined);
  110657. /**
  110658. * Execute the current task
  110659. * @param scene defines the scene where you want your assets to be loaded
  110660. * @param onSuccess is a callback called when the task is successfully executed
  110661. * @param onError is a callback called if an error occurs
  110662. */
  110663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110664. }
  110665. /**
  110666. * Define a task used by AssetsManager to load HDR cube textures
  110667. */
  110668. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  110669. /**
  110670. * Defines the name of the task
  110671. */
  110672. name: string;
  110673. /**
  110674. * Defines the location of the file to load
  110675. */
  110676. url: string;
  110677. /**
  110678. * Defines the desired size (the more it increases the longer the generation will be)
  110679. */
  110680. size: number;
  110681. /**
  110682. * Defines if mipmaps should not be generated (default is false)
  110683. */
  110684. noMipmap: boolean;
  110685. /**
  110686. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110687. */
  110688. generateHarmonics: boolean;
  110689. /**
  110690. * 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)
  110691. */
  110692. gammaSpace: boolean;
  110693. /**
  110694. * Internal Use Only
  110695. */
  110696. reserved: boolean;
  110697. /**
  110698. * Gets the loaded texture
  110699. */
  110700. texture: HDRCubeTexture;
  110701. /**
  110702. * Callback called when the task is successful
  110703. */
  110704. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  110705. /**
  110706. * Callback called when the task is successful
  110707. */
  110708. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  110709. /**
  110710. * Creates a new HDRCubeTextureAssetTask object
  110711. * @param name defines the name of the task
  110712. * @param url defines the location of the file to load
  110713. * @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.
  110714. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110715. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110716. * @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)
  110717. * @param reserved Internal use only
  110718. */
  110719. constructor(
  110720. /**
  110721. * Defines the name of the task
  110722. */
  110723. name: string,
  110724. /**
  110725. * Defines the location of the file to load
  110726. */
  110727. url: string,
  110728. /**
  110729. * Defines the desired size (the more it increases the longer the generation will be)
  110730. */
  110731. size: number,
  110732. /**
  110733. * Defines if mipmaps should not be generated (default is false)
  110734. */
  110735. noMipmap?: boolean,
  110736. /**
  110737. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110738. */
  110739. generateHarmonics?: boolean,
  110740. /**
  110741. * 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)
  110742. */
  110743. gammaSpace?: boolean,
  110744. /**
  110745. * Internal Use Only
  110746. */
  110747. reserved?: boolean);
  110748. /**
  110749. * Execute the current task
  110750. * @param scene defines the scene where you want your assets to be loaded
  110751. * @param onSuccess is a callback called when the task is successfully executed
  110752. * @param onError is a callback called if an error occurs
  110753. */
  110754. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110755. }
  110756. /**
  110757. * This class can be used to easily import assets into a scene
  110758. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  110759. */
  110760. export class AssetsManager {
  110761. private _scene;
  110762. private _isLoading;
  110763. protected _tasks: AbstractAssetTask[];
  110764. protected _waitingTasksCount: number;
  110765. protected _totalTasksCount: number;
  110766. /**
  110767. * Callback called when all tasks are processed
  110768. */
  110769. onFinish: (tasks: AbstractAssetTask[]) => void;
  110770. /**
  110771. * Callback called when a task is successful
  110772. */
  110773. onTaskSuccess: (task: AbstractAssetTask) => void;
  110774. /**
  110775. * Callback called when a task had an error
  110776. */
  110777. onTaskError: (task: AbstractAssetTask) => void;
  110778. /**
  110779. * Callback called when a task is done (whatever the result is)
  110780. */
  110781. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  110782. /**
  110783. * Observable called when all tasks are processed
  110784. */
  110785. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  110786. /**
  110787. * Observable called when a task had an error
  110788. */
  110789. onTaskErrorObservable: Observable<AbstractAssetTask>;
  110790. /**
  110791. * Observable called when a task is successful
  110792. */
  110793. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  110794. /**
  110795. * Observable called when a task is done (whatever the result is)
  110796. */
  110797. onProgressObservable: Observable<IAssetsProgressEvent>;
  110798. /**
  110799. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  110800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110801. */
  110802. useDefaultLoadingScreen: boolean;
  110803. /**
  110804. * Creates a new AssetsManager
  110805. * @param scene defines the scene to work on
  110806. */
  110807. constructor(scene: Scene);
  110808. /**
  110809. * Add a MeshAssetTask to the list of active tasks
  110810. * @param taskName defines the name of the new task
  110811. * @param meshesNames defines the name of meshes to load
  110812. * @param rootUrl defines the root url to use to locate files
  110813. * @param sceneFilename defines the filename of the scene file
  110814. * @returns a new MeshAssetTask object
  110815. */
  110816. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  110817. /**
  110818. * Add a TextFileAssetTask to the list of active tasks
  110819. * @param taskName defines the name of the new task
  110820. * @param url defines the url of the file to load
  110821. * @returns a new TextFileAssetTask object
  110822. */
  110823. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  110824. /**
  110825. * Add a BinaryFileAssetTask to the list of active tasks
  110826. * @param taskName defines the name of the new task
  110827. * @param url defines the url of the file to load
  110828. * @returns a new BinaryFileAssetTask object
  110829. */
  110830. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  110831. /**
  110832. * Add a ImageAssetTask to the list of active tasks
  110833. * @param taskName defines the name of the new task
  110834. * @param url defines the url of the file to load
  110835. * @returns a new ImageAssetTask object
  110836. */
  110837. addImageTask(taskName: string, url: string): ImageAssetTask;
  110838. /**
  110839. * Add a TextureAssetTask to the list of active tasks
  110840. * @param taskName defines the name of the new task
  110841. * @param url defines the url of the file to load
  110842. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110843. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  110844. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  110845. * @returns a new TextureAssetTask object
  110846. */
  110847. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  110848. /**
  110849. * Add a CubeTextureAssetTask to the list of active tasks
  110850. * @param taskName defines the name of the new task
  110851. * @param url defines the url of the file to load
  110852. * @param extensions defines the extension to use to load the cube map (can be null)
  110853. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110854. * @param files defines the list of files to load (can be null)
  110855. * @returns a new CubeTextureAssetTask object
  110856. */
  110857. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  110858. /**
  110859. *
  110860. * Add a HDRCubeTextureAssetTask to the list of active tasks
  110861. * @param taskName defines the name of the new task
  110862. * @param url defines the url of the file to load
  110863. * @param size defines the size you want for the cubemap (can be null)
  110864. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110865. * @param generateHarmonics defines if you want to automatically generate (true by default)
  110866. * @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)
  110867. * @param reserved Internal use only
  110868. * @returns a new HDRCubeTextureAssetTask object
  110869. */
  110870. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  110871. /**
  110872. * Remove a task from the assets manager.
  110873. * @param task the task to remove
  110874. */
  110875. removeTask(task: AbstractAssetTask): void;
  110876. private _decreaseWaitingTasksCount;
  110877. private _runTask;
  110878. /**
  110879. * Reset the AssetsManager and remove all tasks
  110880. * @return the current instance of the AssetsManager
  110881. */
  110882. reset(): AssetsManager;
  110883. /**
  110884. * Start the loading process
  110885. * @return the current instance of the AssetsManager
  110886. */
  110887. load(): AssetsManager;
  110888. }
  110889. }
  110890. declare module BABYLON {
  110891. /**
  110892. * Wrapper class for promise with external resolve and reject.
  110893. */
  110894. export class Deferred<T> {
  110895. /**
  110896. * The promise associated with this deferred object.
  110897. */
  110898. readonly promise: Promise<T>;
  110899. private _resolve;
  110900. private _reject;
  110901. /**
  110902. * The resolve method of the promise associated with this deferred object.
  110903. */
  110904. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110905. /**
  110906. * The reject method of the promise associated with this deferred object.
  110907. */
  110908. readonly reject: (reason?: any) => void;
  110909. /**
  110910. * Constructor for this deferred object.
  110911. */
  110912. constructor();
  110913. }
  110914. }
  110915. declare module BABYLON {
  110916. /**
  110917. * Class used to help managing file picking and drag'n'drop
  110918. */
  110919. export class FilesInput {
  110920. /**
  110921. * List of files ready to be loaded
  110922. */
  110923. static readonly FilesToLoad: {
  110924. [key: string]: File;
  110925. };
  110926. /**
  110927. * Callback called when a file is processed
  110928. */
  110929. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110930. private _engine;
  110931. private _currentScene;
  110932. private _sceneLoadedCallback;
  110933. private _progressCallback;
  110934. private _additionalRenderLoopLogicCallback;
  110935. private _textureLoadingCallback;
  110936. private _startingProcessingFilesCallback;
  110937. private _onReloadCallback;
  110938. private _errorCallback;
  110939. private _elementToMonitor;
  110940. private _sceneFileToLoad;
  110941. private _filesToLoad;
  110942. /**
  110943. * Creates a new FilesInput
  110944. * @param engine defines the rendering engine
  110945. * @param scene defines the hosting scene
  110946. * @param sceneLoadedCallback callback called when scene is loaded
  110947. * @param progressCallback callback called to track progress
  110948. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110949. * @param textureLoadingCallback callback called when a texture is loading
  110950. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110951. * @param onReloadCallback callback called when a reload is requested
  110952. * @param errorCallback callback call if an error occurs
  110953. */
  110954. 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);
  110955. private _dragEnterHandler;
  110956. private _dragOverHandler;
  110957. private _dropHandler;
  110958. /**
  110959. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110960. * @param elementToMonitor defines the DOM element to track
  110961. */
  110962. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110963. /**
  110964. * Release all associated resources
  110965. */
  110966. dispose(): void;
  110967. private renderFunction;
  110968. private drag;
  110969. private drop;
  110970. private _traverseFolder;
  110971. private _processFiles;
  110972. /**
  110973. * Load files from a drop event
  110974. * @param event defines the drop event to use as source
  110975. */
  110976. loadFiles(event: any): void;
  110977. private _processReload;
  110978. /**
  110979. * Reload the current scene from the loaded files
  110980. */
  110981. reload(): void;
  110982. }
  110983. }
  110984. declare module BABYLON {
  110985. /**
  110986. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110988. */
  110989. export class SceneOptimization {
  110990. /**
  110991. * Defines the priority of this optimization (0 by default which means first in the list)
  110992. */
  110993. priority: number;
  110994. /**
  110995. * Gets a string describing the action executed by the current optimization
  110996. * @returns description string
  110997. */
  110998. getDescription(): string;
  110999. /**
  111000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111001. * @param scene defines the current scene where to apply this optimization
  111002. * @param optimizer defines the current optimizer
  111003. * @returns true if everything that can be done was applied
  111004. */
  111005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111006. /**
  111007. * Creates the SceneOptimization object
  111008. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111009. * @param desc defines the description associated with the optimization
  111010. */
  111011. constructor(
  111012. /**
  111013. * Defines the priority of this optimization (0 by default which means first in the list)
  111014. */
  111015. priority?: number);
  111016. }
  111017. /**
  111018. * Defines an optimization used to reduce the size of render target textures
  111019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111020. */
  111021. export class TextureOptimization extends SceneOptimization {
  111022. /**
  111023. * Defines the priority of this optimization (0 by default which means first in the list)
  111024. */
  111025. priority: number;
  111026. /**
  111027. * 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
  111028. */
  111029. maximumSize: number;
  111030. /**
  111031. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111032. */
  111033. step: number;
  111034. /**
  111035. * Gets a string describing the action executed by the current optimization
  111036. * @returns description string
  111037. */
  111038. getDescription(): string;
  111039. /**
  111040. * Creates the TextureOptimization object
  111041. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111042. * @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
  111043. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111044. */
  111045. constructor(
  111046. /**
  111047. * Defines the priority of this optimization (0 by default which means first in the list)
  111048. */
  111049. priority?: number,
  111050. /**
  111051. * 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
  111052. */
  111053. maximumSize?: number,
  111054. /**
  111055. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111056. */
  111057. step?: number);
  111058. /**
  111059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111060. * @param scene defines the current scene where to apply this optimization
  111061. * @param optimizer defines the current optimizer
  111062. * @returns true if everything that can be done was applied
  111063. */
  111064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111065. }
  111066. /**
  111067. * Defines an optimization used to increase or decrease the rendering resolution
  111068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111069. */
  111070. export class HardwareScalingOptimization extends SceneOptimization {
  111071. /**
  111072. * Defines the priority of this optimization (0 by default which means first in the list)
  111073. */
  111074. priority: number;
  111075. /**
  111076. * Defines the maximum scale to use (2 by default)
  111077. */
  111078. maximumScale: number;
  111079. /**
  111080. * Defines the step to use between two passes (0.5 by default)
  111081. */
  111082. step: number;
  111083. private _currentScale;
  111084. private _directionOffset;
  111085. /**
  111086. * Gets a string describing the action executed by the current optimization
  111087. * @return description string
  111088. */
  111089. getDescription(): string;
  111090. /**
  111091. * Creates the HardwareScalingOptimization object
  111092. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111093. * @param maximumScale defines the maximum scale to use (2 by default)
  111094. * @param step defines the step to use between two passes (0.5 by default)
  111095. */
  111096. constructor(
  111097. /**
  111098. * Defines the priority of this optimization (0 by default which means first in the list)
  111099. */
  111100. priority?: number,
  111101. /**
  111102. * Defines the maximum scale to use (2 by default)
  111103. */
  111104. maximumScale?: number,
  111105. /**
  111106. * Defines the step to use between two passes (0.5 by default)
  111107. */
  111108. step?: number);
  111109. /**
  111110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111111. * @param scene defines the current scene where to apply this optimization
  111112. * @param optimizer defines the current optimizer
  111113. * @returns true if everything that can be done was applied
  111114. */
  111115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111116. }
  111117. /**
  111118. * Defines an optimization used to remove shadows
  111119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111120. */
  111121. export class ShadowsOptimization extends SceneOptimization {
  111122. /**
  111123. * Gets a string describing the action executed by the current optimization
  111124. * @return description string
  111125. */
  111126. getDescription(): string;
  111127. /**
  111128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111129. * @param scene defines the current scene where to apply this optimization
  111130. * @param optimizer defines the current optimizer
  111131. * @returns true if everything that can be done was applied
  111132. */
  111133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111134. }
  111135. /**
  111136. * Defines an optimization used to turn post-processes off
  111137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111138. */
  111139. export class PostProcessesOptimization extends SceneOptimization {
  111140. /**
  111141. * Gets a string describing the action executed by the current optimization
  111142. * @return description string
  111143. */
  111144. getDescription(): string;
  111145. /**
  111146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111147. * @param scene defines the current scene where to apply this optimization
  111148. * @param optimizer defines the current optimizer
  111149. * @returns true if everything that can be done was applied
  111150. */
  111151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111152. }
  111153. /**
  111154. * Defines an optimization used to turn lens flares off
  111155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111156. */
  111157. export class LensFlaresOptimization extends SceneOptimization {
  111158. /**
  111159. * Gets a string describing the action executed by the current optimization
  111160. * @return description string
  111161. */
  111162. getDescription(): string;
  111163. /**
  111164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111165. * @param scene defines the current scene where to apply this optimization
  111166. * @param optimizer defines the current optimizer
  111167. * @returns true if everything that can be done was applied
  111168. */
  111169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111170. }
  111171. /**
  111172. * Defines an optimization based on user defined callback.
  111173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111174. */
  111175. export class CustomOptimization extends SceneOptimization {
  111176. /**
  111177. * Callback called to apply the custom optimization.
  111178. */
  111179. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111180. /**
  111181. * Callback called to get custom description
  111182. */
  111183. onGetDescription: () => string;
  111184. /**
  111185. * Gets a string describing the action executed by the current optimization
  111186. * @returns description string
  111187. */
  111188. getDescription(): string;
  111189. /**
  111190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111191. * @param scene defines the current scene where to apply this optimization
  111192. * @param optimizer defines the current optimizer
  111193. * @returns true if everything that can be done was applied
  111194. */
  111195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111196. }
  111197. /**
  111198. * Defines an optimization used to turn particles off
  111199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111200. */
  111201. export class ParticlesOptimization extends SceneOptimization {
  111202. /**
  111203. * Gets a string describing the action executed by the current optimization
  111204. * @return description string
  111205. */
  111206. getDescription(): string;
  111207. /**
  111208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111209. * @param scene defines the current scene where to apply this optimization
  111210. * @param optimizer defines the current optimizer
  111211. * @returns true if everything that can be done was applied
  111212. */
  111213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111214. }
  111215. /**
  111216. * Defines an optimization used to turn render targets off
  111217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111218. */
  111219. export class RenderTargetsOptimization extends SceneOptimization {
  111220. /**
  111221. * Gets a string describing the action executed by the current optimization
  111222. * @return description string
  111223. */
  111224. getDescription(): string;
  111225. /**
  111226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111227. * @param scene defines the current scene where to apply this optimization
  111228. * @param optimizer defines the current optimizer
  111229. * @returns true if everything that can be done was applied
  111230. */
  111231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111232. }
  111233. /**
  111234. * Defines an optimization used to merge meshes with compatible materials
  111235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111236. */
  111237. export class MergeMeshesOptimization extends SceneOptimization {
  111238. private static _UpdateSelectionTree;
  111239. /**
  111240. * Gets or sets a boolean which defines if optimization octree has to be updated
  111241. */
  111242. /**
  111243. * Gets or sets a boolean which defines if optimization octree has to be updated
  111244. */
  111245. static UpdateSelectionTree: boolean;
  111246. /**
  111247. * Gets a string describing the action executed by the current optimization
  111248. * @return description string
  111249. */
  111250. getDescription(): string;
  111251. private _canBeMerged;
  111252. /**
  111253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111254. * @param scene defines the current scene where to apply this optimization
  111255. * @param optimizer defines the current optimizer
  111256. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111257. * @returns true if everything that can be done was applied
  111258. */
  111259. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111260. }
  111261. /**
  111262. * Defines a list of options used by SceneOptimizer
  111263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111264. */
  111265. export class SceneOptimizerOptions {
  111266. /**
  111267. * Defines the target frame rate to reach (60 by default)
  111268. */
  111269. targetFrameRate: number;
  111270. /**
  111271. * Defines the interval between two checkes (2000ms by default)
  111272. */
  111273. trackerDuration: number;
  111274. /**
  111275. * Gets the list of optimizations to apply
  111276. */
  111277. optimizations: SceneOptimization[];
  111278. /**
  111279. * Creates a new list of options used by SceneOptimizer
  111280. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111281. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111282. */
  111283. constructor(
  111284. /**
  111285. * Defines the target frame rate to reach (60 by default)
  111286. */
  111287. targetFrameRate?: number,
  111288. /**
  111289. * Defines the interval between two checkes (2000ms by default)
  111290. */
  111291. trackerDuration?: number);
  111292. /**
  111293. * Add a new optimization
  111294. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111295. * @returns the current SceneOptimizerOptions
  111296. */
  111297. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111298. /**
  111299. * Add a new custom optimization
  111300. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111301. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111302. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111303. * @returns the current SceneOptimizerOptions
  111304. */
  111305. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111306. /**
  111307. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111308. * @param targetFrameRate defines the target frame rate (60 by default)
  111309. * @returns a SceneOptimizerOptions object
  111310. */
  111311. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111312. /**
  111313. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111314. * @param targetFrameRate defines the target frame rate (60 by default)
  111315. * @returns a SceneOptimizerOptions object
  111316. */
  111317. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111318. /**
  111319. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111320. * @param targetFrameRate defines the target frame rate (60 by default)
  111321. * @returns a SceneOptimizerOptions object
  111322. */
  111323. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111324. }
  111325. /**
  111326. * Class used to run optimizations in order to reach a target frame rate
  111327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111328. */
  111329. export class SceneOptimizer implements IDisposable {
  111330. private _isRunning;
  111331. private _options;
  111332. private _scene;
  111333. private _currentPriorityLevel;
  111334. private _targetFrameRate;
  111335. private _trackerDuration;
  111336. private _currentFrameRate;
  111337. private _sceneDisposeObserver;
  111338. private _improvementMode;
  111339. /**
  111340. * Defines an observable called when the optimizer reaches the target frame rate
  111341. */
  111342. onSuccessObservable: Observable<SceneOptimizer>;
  111343. /**
  111344. * Defines an observable called when the optimizer enables an optimization
  111345. */
  111346. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111347. /**
  111348. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111349. */
  111350. onFailureObservable: Observable<SceneOptimizer>;
  111351. /**
  111352. * Gets a boolean indicating if the optimizer is in improvement mode
  111353. */
  111354. readonly isInImprovementMode: boolean;
  111355. /**
  111356. * Gets the current priority level (0 at start)
  111357. */
  111358. readonly currentPriorityLevel: number;
  111359. /**
  111360. * Gets the current frame rate checked by the SceneOptimizer
  111361. */
  111362. readonly currentFrameRate: number;
  111363. /**
  111364. * Gets or sets the current target frame rate (60 by default)
  111365. */
  111366. /**
  111367. * Gets or sets the current target frame rate (60 by default)
  111368. */
  111369. targetFrameRate: number;
  111370. /**
  111371. * Gets or sets the current interval between two checks (every 2000ms by default)
  111372. */
  111373. /**
  111374. * Gets or sets the current interval between two checks (every 2000ms by default)
  111375. */
  111376. trackerDuration: number;
  111377. /**
  111378. * Gets the list of active optimizations
  111379. */
  111380. readonly optimizations: SceneOptimization[];
  111381. /**
  111382. * Creates a new SceneOptimizer
  111383. * @param scene defines the scene to work on
  111384. * @param options defines the options to use with the SceneOptimizer
  111385. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111386. * @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)
  111387. */
  111388. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111389. /**
  111390. * Stops the current optimizer
  111391. */
  111392. stop(): void;
  111393. /**
  111394. * Reset the optimizer to initial step (current priority level = 0)
  111395. */
  111396. reset(): void;
  111397. /**
  111398. * Start the optimizer. By default it will try to reach a specific framerate
  111399. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111400. */
  111401. start(): void;
  111402. private _checkCurrentState;
  111403. /**
  111404. * Release all resources
  111405. */
  111406. dispose(): void;
  111407. /**
  111408. * Helper function to create a SceneOptimizer with one single line of code
  111409. * @param scene defines the scene to work on
  111410. * @param options defines the options to use with the SceneOptimizer
  111411. * @param onSuccess defines a callback to call on success
  111412. * @param onFailure defines a callback to call on failure
  111413. * @returns the new SceneOptimizer object
  111414. */
  111415. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111416. }
  111417. }
  111418. declare module BABYLON {
  111419. /**
  111420. * Class used to serialize a scene into a string
  111421. */
  111422. export class SceneSerializer {
  111423. /**
  111424. * Clear cache used by a previous serialization
  111425. */
  111426. static ClearCache(): void;
  111427. /**
  111428. * Serialize a scene into a JSON compatible object
  111429. * @param scene defines the scene to serialize
  111430. * @returns a JSON compatible object
  111431. */
  111432. static Serialize(scene: Scene): any;
  111433. /**
  111434. * Serialize a mesh into a JSON compatible object
  111435. * @param toSerialize defines the mesh to serialize
  111436. * @param withParents defines if parents must be serialized as well
  111437. * @param withChildren defines if children must be serialized as well
  111438. * @returns a JSON compatible object
  111439. */
  111440. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111441. }
  111442. }
  111443. declare module BABYLON {
  111444. /**
  111445. * This represents the different options avilable for the video capture.
  111446. */
  111447. export interface VideoRecorderOptions {
  111448. /** Defines the mime type of the video */
  111449. mimeType: string;
  111450. /** Defines the video the video should be recorded at */
  111451. fps: number;
  111452. /** Defines the chunk size for the recording data */
  111453. recordChunckSize: number;
  111454. /** The audio tracks to attach to the record */
  111455. audioTracks?: MediaStreamTrack[];
  111456. }
  111457. /**
  111458. * This can helps recording videos from BabylonJS.
  111459. * This is based on the available WebRTC functionalities of the browser.
  111460. *
  111461. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111462. */
  111463. export class VideoRecorder {
  111464. private static readonly _defaultOptions;
  111465. /**
  111466. * Returns wehther or not the VideoRecorder is available in your browser.
  111467. * @param engine Defines the Babylon Engine to check the support for
  111468. * @returns true if supported otherwise false
  111469. */
  111470. static IsSupported(engine: Engine): boolean;
  111471. private readonly _options;
  111472. private _canvas;
  111473. private _mediaRecorder;
  111474. private _recordedChunks;
  111475. private _fileName;
  111476. private _resolve;
  111477. private _reject;
  111478. /**
  111479. * True wether a recording is already in progress.
  111480. */
  111481. readonly isRecording: boolean;
  111482. /**
  111483. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111484. * a video file.
  111485. * @param engine Defines the BabylonJS Engine you wish to record
  111486. * @param options Defines options that can be used to customized the capture
  111487. */
  111488. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111489. /**
  111490. * Stops the current recording before the default capture timeout passed in the startRecording
  111491. * functions.
  111492. */
  111493. stopRecording(): void;
  111494. /**
  111495. * Starts recording the canvas for a max duration specified in parameters.
  111496. * @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.
  111497. * @param maxDuration Defines the maximum recording time in seconds.
  111498. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111499. * @return a promise callback at the end of the recording with the video data in Blob.
  111500. */
  111501. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111502. /**
  111503. * Releases internal resources used during the recording.
  111504. */
  111505. dispose(): void;
  111506. private _handleDataAvailable;
  111507. private _handleError;
  111508. private _handleStop;
  111509. }
  111510. }
  111511. declare module BABYLON {
  111512. /**
  111513. * Helper class to push actions to a pool of workers.
  111514. */
  111515. export class WorkerPool implements IDisposable {
  111516. private _workerInfos;
  111517. private _pendingActions;
  111518. /**
  111519. * Constructor
  111520. * @param workers Array of workers to use for actions
  111521. */
  111522. constructor(workers: Array<Worker>);
  111523. /**
  111524. * Terminates all workers and clears any pending actions.
  111525. */
  111526. dispose(): void;
  111527. /**
  111528. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111529. * pended until a worker has completed its action.
  111530. * @param action The action to perform. Call onComplete when the action is complete.
  111531. */
  111532. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111533. private _execute;
  111534. }
  111535. }
  111536. declare module BABYLON {
  111537. /**
  111538. * Class containing a set of static utilities functions for screenshots
  111539. */
  111540. export class ScreenshotTools {
  111541. /**
  111542. * Captures a screenshot of the current rendering
  111543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111544. * @param engine defines the rendering engine
  111545. * @param camera defines the source camera
  111546. * @param size This parameter can be set to a single number or to an object with the
  111547. * following (optional) properties: precision, width, height. If a single number is passed,
  111548. * it will be used for both width and height. If an object is passed, the screenshot size
  111549. * will be derived from the parameters. The precision property is a multiplier allowing
  111550. * rendering at a higher or lower resolution
  111551. * @param successCallback defines the callback receives a single parameter which contains the
  111552. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111553. * src parameter of an <img> to display it
  111554. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111555. * Check your browser for supported MIME types
  111556. */
  111557. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111558. /**
  111559. * Generates an image screenshot from the specified camera.
  111560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111561. * @param engine The engine to use for rendering
  111562. * @param camera The camera to use for rendering
  111563. * @param size This parameter can be set to a single number or to an object with the
  111564. * following (optional) properties: precision, width, height. If a single number is passed,
  111565. * it will be used for both width and height. If an object is passed, the screenshot size
  111566. * will be derived from the parameters. The precision property is a multiplier allowing
  111567. * rendering at a higher or lower resolution
  111568. * @param successCallback The callback receives a single parameter which contains the
  111569. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111570. * src parameter of an <img> to display it
  111571. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111572. * Check your browser for supported MIME types
  111573. * @param samples Texture samples (default: 1)
  111574. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111575. * @param fileName A name for for the downloaded file.
  111576. */
  111577. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111578. }
  111579. }
  111580. declare module BABYLON {
  111581. /**
  111582. * A cursor which tracks a point on a path
  111583. */
  111584. export class PathCursor {
  111585. private path;
  111586. /**
  111587. * Stores path cursor callbacks for when an onchange event is triggered
  111588. */
  111589. private _onchange;
  111590. /**
  111591. * The value of the path cursor
  111592. */
  111593. value: number;
  111594. /**
  111595. * The animation array of the path cursor
  111596. */
  111597. animations: Animation[];
  111598. /**
  111599. * Initializes the path cursor
  111600. * @param path The path to track
  111601. */
  111602. constructor(path: Path2);
  111603. /**
  111604. * Gets the cursor point on the path
  111605. * @returns A point on the path cursor at the cursor location
  111606. */
  111607. getPoint(): Vector3;
  111608. /**
  111609. * Moves the cursor ahead by the step amount
  111610. * @param step The amount to move the cursor forward
  111611. * @returns This path cursor
  111612. */
  111613. moveAhead(step?: number): PathCursor;
  111614. /**
  111615. * Moves the cursor behind by the step amount
  111616. * @param step The amount to move the cursor back
  111617. * @returns This path cursor
  111618. */
  111619. moveBack(step?: number): PathCursor;
  111620. /**
  111621. * Moves the cursor by the step amount
  111622. * If the step amount is greater than one, an exception is thrown
  111623. * @param step The amount to move the cursor
  111624. * @returns This path cursor
  111625. */
  111626. move(step: number): PathCursor;
  111627. /**
  111628. * Ensures that the value is limited between zero and one
  111629. * @returns This path cursor
  111630. */
  111631. private ensureLimits;
  111632. /**
  111633. * Runs onchange callbacks on change (used by the animation engine)
  111634. * @returns This path cursor
  111635. */
  111636. private raiseOnChange;
  111637. /**
  111638. * Executes a function on change
  111639. * @param f A path cursor onchange callback
  111640. * @returns This path cursor
  111641. */
  111642. onchange(f: (cursor: PathCursor) => void): PathCursor;
  111643. }
  111644. }
  111645. declare module BABYLON {
  111646. /** @hidden */
  111647. export var blurPixelShader: {
  111648. name: string;
  111649. shader: string;
  111650. };
  111651. }
  111652. declare module BABYLON {
  111653. /** @hidden */
  111654. export var bones300Declaration: {
  111655. name: string;
  111656. shader: string;
  111657. };
  111658. }
  111659. declare module BABYLON {
  111660. /** @hidden */
  111661. export var instances300Declaration: {
  111662. name: string;
  111663. shader: string;
  111664. };
  111665. }
  111666. declare module BABYLON {
  111667. /** @hidden */
  111668. export var pointCloudVertexDeclaration: {
  111669. name: string;
  111670. shader: string;
  111671. };
  111672. }
  111673. // Mixins
  111674. interface Window {
  111675. mozIndexedDB: IDBFactory;
  111676. webkitIndexedDB: IDBFactory;
  111677. msIndexedDB: IDBFactory;
  111678. webkitURL: typeof URL;
  111679. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  111680. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  111681. WebGLRenderingContext: WebGLRenderingContext;
  111682. MSGesture: MSGesture;
  111683. CANNON: any;
  111684. AudioContext: AudioContext;
  111685. webkitAudioContext: AudioContext;
  111686. PointerEvent: any;
  111687. Math: Math;
  111688. Uint8Array: Uint8ArrayConstructor;
  111689. Float32Array: Float32ArrayConstructor;
  111690. mozURL: typeof URL;
  111691. msURL: typeof URL;
  111692. VRFrameData: any; // WebVR, from specs 1.1
  111693. DracoDecoderModule: any;
  111694. setImmediate(handler: (...args: any[]) => void): number;
  111695. }
  111696. interface Document {
  111697. mozCancelFullScreen(): void;
  111698. msCancelFullScreen(): void;
  111699. webkitCancelFullScreen(): void;
  111700. requestPointerLock(): void;
  111701. exitPointerLock(): void;
  111702. mozFullScreen: boolean;
  111703. msIsFullScreen: boolean;
  111704. readonly webkitIsFullScreen: boolean;
  111705. readonly pointerLockElement: Element;
  111706. mozPointerLockElement: HTMLElement;
  111707. msPointerLockElement: HTMLElement;
  111708. webkitPointerLockElement: HTMLElement;
  111709. }
  111710. interface HTMLCanvasElement {
  111711. requestPointerLock(): void;
  111712. msRequestPointerLock?(): void;
  111713. mozRequestPointerLock?(): void;
  111714. webkitRequestPointerLock?(): void;
  111715. /** Track wether a record is in progress */
  111716. isRecording: boolean;
  111717. /** Capture Stream method defined by some browsers */
  111718. captureStream(fps?: number): MediaStream;
  111719. }
  111720. interface CanvasRenderingContext2D {
  111721. msImageSmoothingEnabled: boolean;
  111722. }
  111723. interface MouseEvent {
  111724. mozMovementX: number;
  111725. mozMovementY: number;
  111726. webkitMovementX: number;
  111727. webkitMovementY: number;
  111728. msMovementX: number;
  111729. msMovementY: number;
  111730. }
  111731. interface Navigator {
  111732. mozGetVRDevices: (any: any) => any;
  111733. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111734. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111735. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111736. webkitGetGamepads(): Gamepad[];
  111737. msGetGamepads(): Gamepad[];
  111738. webkitGamepads(): Gamepad[];
  111739. }
  111740. interface HTMLVideoElement {
  111741. mozSrcObject: any;
  111742. }
  111743. interface Math {
  111744. fround(x: number): number;
  111745. imul(a: number, b: number): number;
  111746. }
  111747. interface WebGLProgram {
  111748. context?: WebGLRenderingContext;
  111749. vertexShader?: WebGLShader;
  111750. fragmentShader?: WebGLShader;
  111751. isParallelCompiled: boolean;
  111752. onCompiled?: () => void;
  111753. }
  111754. interface WebGLRenderingContext {
  111755. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  111756. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  111757. vertexAttribDivisor(index: number, divisor: number): void;
  111758. createVertexArray(): any;
  111759. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  111760. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  111761. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  111762. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  111763. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  111764. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  111765. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  111766. // Queries
  111767. createQuery(): WebGLQuery;
  111768. deleteQuery(query: WebGLQuery): void;
  111769. beginQuery(target: number, query: WebGLQuery): void;
  111770. endQuery(target: number): void;
  111771. getQueryParameter(query: WebGLQuery, pname: number): any;
  111772. getQuery(target: number, pname: number): any;
  111773. MAX_SAMPLES: number;
  111774. RGBA8: number;
  111775. READ_FRAMEBUFFER: number;
  111776. DRAW_FRAMEBUFFER: number;
  111777. UNIFORM_BUFFER: number;
  111778. HALF_FLOAT_OES: number;
  111779. RGBA16F: number;
  111780. RGBA32F: number;
  111781. R32F: number;
  111782. RG32F: number;
  111783. RGB32F: number;
  111784. R16F: number;
  111785. RG16F: number;
  111786. RGB16F: number;
  111787. RED: number;
  111788. RG: number;
  111789. R8: number;
  111790. RG8: number;
  111791. UNSIGNED_INT_24_8: number;
  111792. DEPTH24_STENCIL8: number;
  111793. /* Multiple Render Targets */
  111794. drawBuffers(buffers: number[]): void;
  111795. readBuffer(src: number): void;
  111796. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  111797. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  111798. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  111799. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  111800. // Occlusion Query
  111801. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  111802. ANY_SAMPLES_PASSED: number;
  111803. QUERY_RESULT_AVAILABLE: number;
  111804. QUERY_RESULT: number;
  111805. }
  111806. interface WebGLBuffer {
  111807. references: number;
  111808. capacity: number;
  111809. is32Bits: boolean;
  111810. }
  111811. interface WebGLProgram {
  111812. transformFeedback?: WebGLTransformFeedback | null;
  111813. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111814. }
  111815. interface EXT_disjoint_timer_query {
  111816. QUERY_COUNTER_BITS_EXT: number;
  111817. TIME_ELAPSED_EXT: number;
  111818. TIMESTAMP_EXT: number;
  111819. GPU_DISJOINT_EXT: number;
  111820. QUERY_RESULT_EXT: number;
  111821. QUERY_RESULT_AVAILABLE_EXT: number;
  111822. queryCounterEXT(query: WebGLQuery, target: number): void;
  111823. createQueryEXT(): WebGLQuery;
  111824. beginQueryEXT(target: number, query: WebGLQuery): void;
  111825. endQueryEXT(target: number): void;
  111826. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  111827. deleteQueryEXT(query: WebGLQuery): void;
  111828. }
  111829. interface WebGLUniformLocation {
  111830. _currentState: any;
  111831. }
  111832. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  111833. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  111834. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  111835. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111836. interface WebGLRenderingContext {
  111837. readonly RASTERIZER_DISCARD: number;
  111838. readonly DEPTH_COMPONENT24: number;
  111839. readonly TEXTURE_3D: number;
  111840. readonly TEXTURE_2D_ARRAY: number;
  111841. readonly TEXTURE_COMPARE_FUNC: number;
  111842. readonly TEXTURE_COMPARE_MODE: number;
  111843. readonly COMPARE_REF_TO_TEXTURE: number;
  111844. readonly TEXTURE_WRAP_R: number;
  111845. readonly HALF_FLOAT: number;
  111846. readonly RGB8: number;
  111847. readonly RED_INTEGER: number;
  111848. readonly RG_INTEGER: number;
  111849. readonly RGB_INTEGER: number;
  111850. readonly RGBA_INTEGER: number;
  111851. readonly R8_SNORM: number;
  111852. readonly RG8_SNORM: number;
  111853. readonly RGB8_SNORM: number;
  111854. readonly RGBA8_SNORM: number;
  111855. readonly R8I: number;
  111856. readonly RG8I: number;
  111857. readonly RGB8I: number;
  111858. readonly RGBA8I: number;
  111859. readonly R8UI: number;
  111860. readonly RG8UI: number;
  111861. readonly RGB8UI: number;
  111862. readonly RGBA8UI: number;
  111863. readonly R16I: number;
  111864. readonly RG16I: number;
  111865. readonly RGB16I: number;
  111866. readonly RGBA16I: number;
  111867. readonly R16UI: number;
  111868. readonly RG16UI: number;
  111869. readonly RGB16UI: number;
  111870. readonly RGBA16UI: number;
  111871. readonly R32I: number;
  111872. readonly RG32I: number;
  111873. readonly RGB32I: number;
  111874. readonly RGBA32I: number;
  111875. readonly R32UI: number;
  111876. readonly RG32UI: number;
  111877. readonly RGB32UI: number;
  111878. readonly RGBA32UI: number;
  111879. readonly RGB10_A2UI: number;
  111880. readonly R11F_G11F_B10F: number;
  111881. readonly RGB9_E5: number;
  111882. readonly RGB10_A2: number;
  111883. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  111884. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  111885. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  111886. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  111887. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  111888. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  111889. 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;
  111890. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  111891. readonly TRANSFORM_FEEDBACK: number;
  111892. readonly INTERLEAVED_ATTRIBS: number;
  111893. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  111894. createTransformFeedback(): WebGLTransformFeedback;
  111895. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  111896. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  111897. beginTransformFeedback(primitiveMode: number): void;
  111898. endTransformFeedback(): void;
  111899. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111900. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111901. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111902. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111903. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111904. }
  111905. interface ImageBitmap {
  111906. readonly width: number;
  111907. readonly height: number;
  111908. close(): void;
  111909. }
  111910. interface WebGLQuery extends WebGLObject {
  111911. }
  111912. declare var WebGLQuery: {
  111913. prototype: WebGLQuery;
  111914. new(): WebGLQuery;
  111915. };
  111916. interface WebGLSampler extends WebGLObject {
  111917. }
  111918. declare var WebGLSampler: {
  111919. prototype: WebGLSampler;
  111920. new(): WebGLSampler;
  111921. };
  111922. interface WebGLSync extends WebGLObject {
  111923. }
  111924. declare var WebGLSync: {
  111925. prototype: WebGLSync;
  111926. new(): WebGLSync;
  111927. };
  111928. interface WebGLTransformFeedback extends WebGLObject {
  111929. }
  111930. declare var WebGLTransformFeedback: {
  111931. prototype: WebGLTransformFeedback;
  111932. new(): WebGLTransformFeedback;
  111933. };
  111934. interface WebGLVertexArrayObject extends WebGLObject {
  111935. }
  111936. declare var WebGLVertexArrayObject: {
  111937. prototype: WebGLVertexArrayObject;
  111938. new(): WebGLVertexArrayObject;
  111939. };
  111940. // Type definitions for WebVR API
  111941. // Project: https://w3c.github.io/webvr/
  111942. // Definitions by: six a <https://github.com/lostfictions>
  111943. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111944. interface VRDisplay extends EventTarget {
  111945. /**
  111946. * Dictionary of capabilities describing the VRDisplay.
  111947. */
  111948. readonly capabilities: VRDisplayCapabilities;
  111949. /**
  111950. * z-depth defining the far plane of the eye view frustum
  111951. * enables mapping of values in the render target depth
  111952. * attachment to scene coordinates. Initially set to 10000.0.
  111953. */
  111954. depthFar: number;
  111955. /**
  111956. * z-depth defining the near plane of the eye view frustum
  111957. * enables mapping of values in the render target depth
  111958. * attachment to scene coordinates. Initially set to 0.01.
  111959. */
  111960. depthNear: number;
  111961. /**
  111962. * An identifier for this distinct VRDisplay. Used as an
  111963. * association point in the Gamepad API.
  111964. */
  111965. readonly displayId: number;
  111966. /**
  111967. * A display name, a user-readable name identifying it.
  111968. */
  111969. readonly displayName: string;
  111970. readonly isConnected: boolean;
  111971. readonly isPresenting: boolean;
  111972. /**
  111973. * If this VRDisplay supports room-scale experiences, the optional
  111974. * stage attribute contains details on the room-scale parameters.
  111975. */
  111976. readonly stageParameters: VRStageParameters | null;
  111977. /**
  111978. * Passing the value returned by `requestAnimationFrame` to
  111979. * `cancelAnimationFrame` will unregister the callback.
  111980. * @param handle Define the hanle of the request to cancel
  111981. */
  111982. cancelAnimationFrame(handle: number): void;
  111983. /**
  111984. * Stops presenting to the VRDisplay.
  111985. * @returns a promise to know when it stopped
  111986. */
  111987. exitPresent(): Promise<void>;
  111988. /**
  111989. * Return the current VREyeParameters for the given eye.
  111990. * @param whichEye Define the eye we want the parameter for
  111991. * @returns the eye parameters
  111992. */
  111993. getEyeParameters(whichEye: string): VREyeParameters;
  111994. /**
  111995. * Populates the passed VRFrameData with the information required to render
  111996. * the current frame.
  111997. * @param frameData Define the data structure to populate
  111998. * @returns true if ok otherwise false
  111999. */
  112000. getFrameData(frameData: VRFrameData): boolean;
  112001. /**
  112002. * Get the layers currently being presented.
  112003. * @returns the list of VR layers
  112004. */
  112005. getLayers(): VRLayer[];
  112006. /**
  112007. * Return a VRPose containing the future predicted pose of the VRDisplay
  112008. * when the current frame will be presented. The value returned will not
  112009. * change until JavaScript has returned control to the browser.
  112010. *
  112011. * The VRPose will contain the position, orientation, velocity,
  112012. * and acceleration of each of these properties.
  112013. * @returns the pose object
  112014. */
  112015. getPose(): VRPose;
  112016. /**
  112017. * Return the current instantaneous pose of the VRDisplay, with no
  112018. * prediction applied.
  112019. * @returns the current instantaneous pose
  112020. */
  112021. getImmediatePose(): VRPose;
  112022. /**
  112023. * The callback passed to `requestAnimationFrame` will be called
  112024. * any time a new frame should be rendered. When the VRDisplay is
  112025. * presenting the callback will be called at the native refresh
  112026. * rate of the HMD. When not presenting this function acts
  112027. * identically to how window.requestAnimationFrame acts. Content should
  112028. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112029. * asynchronously from other displays and at differing refresh rates.
  112030. * @param callback Define the eaction to run next frame
  112031. * @returns the request handle it
  112032. */
  112033. requestAnimationFrame(callback: FrameRequestCallback): number;
  112034. /**
  112035. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112036. * Repeat calls while already presenting will update the VRLayers being displayed.
  112037. * @param layers Define the list of layer to present
  112038. * @returns a promise to know when the request has been fulfilled
  112039. */
  112040. requestPresent(layers: VRLayer[]): Promise<void>;
  112041. /**
  112042. * Reset the pose for this display, treating its current position and
  112043. * orientation as the "origin/zero" values. VRPose.position,
  112044. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112045. * updated when calling resetPose(). This should be called in only
  112046. * sitting-space experiences.
  112047. */
  112048. resetPose(): void;
  112049. /**
  112050. * The VRLayer provided to the VRDisplay will be captured and presented
  112051. * in the HMD. Calling this function has the same effect on the source
  112052. * canvas as any other operation that uses its source image, and canvases
  112053. * created without preserveDrawingBuffer set to true will be cleared.
  112054. * @param pose Define the pose to submit
  112055. */
  112056. submitFrame(pose?: VRPose): void;
  112057. }
  112058. declare var VRDisplay: {
  112059. prototype: VRDisplay;
  112060. new(): VRDisplay;
  112061. };
  112062. interface VRLayer {
  112063. leftBounds?: number[] | Float32Array | null;
  112064. rightBounds?: number[] | Float32Array | null;
  112065. source?: HTMLCanvasElement | null;
  112066. }
  112067. interface VRDisplayCapabilities {
  112068. readonly canPresent: boolean;
  112069. readonly hasExternalDisplay: boolean;
  112070. readonly hasOrientation: boolean;
  112071. readonly hasPosition: boolean;
  112072. readonly maxLayers: number;
  112073. }
  112074. interface VREyeParameters {
  112075. /** @deprecated */
  112076. readonly fieldOfView: VRFieldOfView;
  112077. readonly offset: Float32Array;
  112078. readonly renderHeight: number;
  112079. readonly renderWidth: number;
  112080. }
  112081. interface VRFieldOfView {
  112082. readonly downDegrees: number;
  112083. readonly leftDegrees: number;
  112084. readonly rightDegrees: number;
  112085. readonly upDegrees: number;
  112086. }
  112087. interface VRFrameData {
  112088. readonly leftProjectionMatrix: Float32Array;
  112089. readonly leftViewMatrix: Float32Array;
  112090. readonly pose: VRPose;
  112091. readonly rightProjectionMatrix: Float32Array;
  112092. readonly rightViewMatrix: Float32Array;
  112093. readonly timestamp: number;
  112094. }
  112095. interface VRPose {
  112096. readonly angularAcceleration: Float32Array | null;
  112097. readonly angularVelocity: Float32Array | null;
  112098. readonly linearAcceleration: Float32Array | null;
  112099. readonly linearVelocity: Float32Array | null;
  112100. readonly orientation: Float32Array | null;
  112101. readonly position: Float32Array | null;
  112102. readonly timestamp: number;
  112103. }
  112104. interface VRStageParameters {
  112105. sittingToStandingTransform?: Float32Array;
  112106. sizeX?: number;
  112107. sizeY?: number;
  112108. }
  112109. interface Navigator {
  112110. getVRDisplays(): Promise<VRDisplay[]>;
  112111. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112112. }
  112113. interface Window {
  112114. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112115. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112116. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112117. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112118. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112119. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112120. }
  112121. interface Gamepad {
  112122. readonly displayId: number;
  112123. }
  112124. interface XRDevice {
  112125. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112126. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112127. }
  112128. interface XRSession {
  112129. getInputSources(): Array<any>;
  112130. baseLayer: XRWebGLLayer;
  112131. requestFrameOfReference(type: string): Promise<void>;
  112132. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112133. end(): Promise<void>;
  112134. requestAnimationFrame: Function;
  112135. addEventListener: Function;
  112136. }
  112137. interface XRSessionCreationOptions {
  112138. outputContext?: WebGLRenderingContext | null;
  112139. immersive?: boolean;
  112140. environmentIntegration?: boolean;
  112141. }
  112142. interface XRLayer {
  112143. getViewport: Function;
  112144. framebufferWidth: number;
  112145. framebufferHeight: number;
  112146. }
  112147. interface XRView {
  112148. projectionMatrix: Float32Array;
  112149. }
  112150. interface XRFrame {
  112151. getDevicePose: Function;
  112152. getInputPose: Function;
  112153. views: Array<XRView>;
  112154. baseLayer: XRLayer;
  112155. }
  112156. interface XRFrameOfReference {
  112157. }
  112158. interface XRWebGLLayer extends XRLayer {
  112159. framebuffer: WebGLFramebuffer;
  112160. }
  112161. declare var XRWebGLLayer: {
  112162. prototype: XRWebGLLayer;
  112163. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112164. };